Skip to content

Commit 443d4ee

Browse files
authored
elliptic-curve: bump sec1 to v0.8.0-rc.11 (#2164)
1 parent f33be2a commit 443d4ee

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

Cargo.lock

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elliptic-curve/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ hex-literal = { version = "1", optional = true }
3939
once_cell = { version = "1.21", optional = true, default-features = false }
4040
pem-rfc7468 = { version = "1.0.0-rc.2", optional = true, features = ["alloc"] }
4141
pkcs8 = { version = "0.11.0-rc.8", optional = true, default-features = false }
42-
sec1 = { version = "0.8.0-rc.10", optional = true, features = ["subtle", "zeroize"] }
42+
sec1 = { version = "0.8.0-rc.11", optional = true, features = ["ctutils", "zeroize"] }
4343
serdect = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }
4444

4545
[dev-dependencies]

elliptic-curve/src/dev.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{
77
BatchNormalize, Curve, CurveArithmetic, CurveGroup, FieldBytesEncoding, PrimeCurve,
88
array::typenum::U32,
99
bigint::{Limb, Odd, U256},
10+
ctutils,
1011
error::{Error, Result},
1112
ops::{Invert, LinearCombination, Reduce, ShrAssign},
1213
point::{AffineCoordinates, NonIdentity},
@@ -516,14 +517,14 @@ impl From<NonIdentity<AffinePoint>> for AffinePoint {
516517
}
517518

518519
impl FromEncodedPoint<MockCurve> for AffinePoint {
519-
fn from_encoded_point(encoded_point: &EncodedPoint) -> CtOption<Self> {
520+
fn from_encoded_point(encoded_point: &EncodedPoint) -> ctutils::CtOption<Self> {
520521
let point = if encoded_point.is_identity() {
521522
Self::Identity
522523
} else {
523524
Self::Other(*encoded_point)
524525
};
525526

526-
CtOption::new(point, Choice::from(1))
527+
ctutils::CtOption::new(point, ctutils::Choice::TRUE)
527528
}
528529
}
529530

@@ -642,7 +643,7 @@ impl From<ProjectivePoint> for AffinePoint {
642643
}
643644

644645
impl FromEncodedPoint<MockCurve> for ProjectivePoint {
645-
fn from_encoded_point(_point: &EncodedPoint) -> CtOption<Self> {
646+
fn from_encoded_point(_point: &EncodedPoint) -> ctutils::CtOption<Self> {
646647
unimplemented!();
647648
}
648649
}
@@ -690,12 +691,14 @@ impl group::GroupEncoding for AffinePoint {
690691

691692
fn from_bytes(bytes: &Self::Repr) -> CtOption<Self> {
692693
EncodedPoint::from_bytes(bytes)
693-
.map(|point| CtOption::new(point, Choice::from(1)))
694+
.map(|point| ctutils::CtOption::new(point, ctutils::Choice::TRUE))
694695
.unwrap_or_else(|_| {
695-
let is_identity = bytes.ct_eq(&Self::Repr::default());
696-
CtOption::new(EncodedPoint::identity(), is_identity)
696+
let is_identity =
697+
ctutils::CtEq::ct_eq(bytes.as_slice(), Self::Repr::default().as_slice());
698+
ctutils::CtOption::new(EncodedPoint::identity(), is_identity)
697699
})
698700
.and_then(|point| Self::from_encoded_point(&point))
701+
.into()
699702
}
700703

701704
fn from_bytes_unchecked(bytes: &Self::Repr) -> CtOption<Self> {

elliptic-curve/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub use crate::{
114114
pub use array;
115115
pub use array::typenum::consts;
116116
pub use bigint;
117+
pub use bigint::ctutils;
117118
pub use rand_core;
118119
pub use subtle;
119120
pub use zeroize;

elliptic-curve/src/public_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use {
2020
use {
2121
crate::{
2222
FieldBytesSize,
23+
ctutils::{Choice, CtOption},
2324
point::PointCompression,
2425
sec1::{CompressedPoint, EncodedPoint, FromEncodedPoint, ModulusSize, ToEncodedPoint},
2526
},
2627
core::cmp::Ordering,
27-
subtle::{Choice, CtOption},
2828
};
2929

3030
#[cfg(feature = "serde")]
@@ -181,7 +181,7 @@ where
181181
fn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self> {
182182
AffinePoint::<C>::from_encoded_point(encoded_point).and_then(|point| {
183183
// Defeating the point of `subtle`, but the use case is specifically a public key
184-
let is_identity = Choice::from(u8::from(encoded_point.is_identity()));
184+
let is_identity = Choice::from_u8_lsb(u8::from(encoded_point.is_identity()));
185185
CtOption::new(PublicKey { point }, !is_identity)
186186
})
187187
}

elliptic-curve/src/sec1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
55
pub use sec1::point::{Coordinates, ModulusSize, Tag};
66

7-
use crate::{Curve, FieldBytesSize, Result, SecretKey};
7+
use crate::{Curve, FieldBytesSize, Result, SecretKey, ctutils::CtOption};
88
use array::Array;
9-
use subtle::CtOption;
109

1110
#[cfg(feature = "arithmetic")]
1211
use crate::{AffinePoint, CurveArithmetic, Error};

0 commit comments

Comments
 (0)