Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ hex-literal = { version = "1", optional = true }
once_cell = { version = "1.21", optional = true, default-features = false }
pem-rfc7468 = { version = "1.0.0-rc.2", optional = true, features = ["alloc"] }
pkcs8 = { version = "0.11.0-rc.8", optional = true, default-features = false }
sec1 = { version = "0.8.0-rc.10", optional = true, features = ["subtle", "zeroize"] }
sec1 = { version = "0.8.0-rc.11", optional = true, features = ["ctutils", "zeroize"] }
serdect = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }

[dev-dependencies]
Expand Down
15 changes: 9 additions & 6 deletions elliptic-curve/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
BatchNormalize, Curve, CurveArithmetic, CurveGroup, FieldBytesEncoding, PrimeCurve,
array::typenum::U32,
bigint::{Limb, Odd, U256},
ctutils,
error::{Error, Result},
ops::{Invert, LinearCombination, Reduce, ShrAssign},
point::{AffineCoordinates, NonIdentity},
Expand Down Expand Up @@ -516,14 +517,14 @@ impl From<NonIdentity<AffinePoint>> for AffinePoint {
}

impl FromEncodedPoint<MockCurve> for AffinePoint {
fn from_encoded_point(encoded_point: &EncodedPoint) -> CtOption<Self> {
fn from_encoded_point(encoded_point: &EncodedPoint) -> ctutils::CtOption<Self> {
let point = if encoded_point.is_identity() {
Self::Identity
} else {
Self::Other(*encoded_point)
};

CtOption::new(point, Choice::from(1))
ctutils::CtOption::new(point, ctutils::Choice::TRUE)
}
}

Expand Down Expand Up @@ -642,7 +643,7 @@ impl From<ProjectivePoint> for AffinePoint {
}

impl FromEncodedPoint<MockCurve> for ProjectivePoint {
fn from_encoded_point(_point: &EncodedPoint) -> CtOption<Self> {
fn from_encoded_point(_point: &EncodedPoint) -> ctutils::CtOption<Self> {
unimplemented!();
}
}
Expand Down Expand Up @@ -690,12 +691,14 @@ impl group::GroupEncoding for AffinePoint {

fn from_bytes(bytes: &Self::Repr) -> CtOption<Self> {
EncodedPoint::from_bytes(bytes)
.map(|point| CtOption::new(point, Choice::from(1)))
.map(|point| ctutils::CtOption::new(point, ctutils::Choice::TRUE))
.unwrap_or_else(|_| {
let is_identity = bytes.ct_eq(&Self::Repr::default());
CtOption::new(EncodedPoint::identity(), is_identity)
let is_identity =
ctutils::CtEq::ct_eq(bytes.as_slice(), Self::Repr::default().as_slice());
ctutils::CtOption::new(EncodedPoint::identity(), is_identity)
})
.and_then(|point| Self::from_encoded_point(&point))
.into()
}

fn from_bytes_unchecked(bytes: &Self::Repr) -> CtOption<Self> {
Expand Down
1 change: 1 addition & 0 deletions elliptic-curve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub use crate::{
pub use array;
pub use array::typenum::consts;
pub use bigint;
pub use bigint::ctutils;
pub use rand_core;
pub use subtle;
pub use zeroize;
Expand Down
4 changes: 2 additions & 2 deletions elliptic-curve/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use {
use {
crate::{
FieldBytesSize,
ctutils::{Choice, CtOption},
point::PointCompression,
sec1::{CompressedPoint, EncodedPoint, FromEncodedPoint, ModulusSize, ToEncodedPoint},
},
core::cmp::Ordering,
subtle::{Choice, CtOption},
};

#[cfg(feature = "serde")]
Expand Down Expand Up @@ -181,7 +181,7 @@ where
fn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self> {
AffinePoint::<C>::from_encoded_point(encoded_point).and_then(|point| {
// Defeating the point of `subtle`, but the use case is specifically a public key
let is_identity = Choice::from(u8::from(encoded_point.is_identity()));
let is_identity = Choice::from_u8_lsb(u8::from(encoded_point.is_identity()));
CtOption::new(PublicKey { point }, !is_identity)
})
}
Expand Down
3 changes: 1 addition & 2 deletions elliptic-curve/src/sec1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

pub use sec1::point::{Coordinates, ModulusSize, Tag};

use crate::{Curve, FieldBytesSize, Result, SecretKey};
use crate::{Curve, FieldBytesSize, Result, SecretKey, ctutils::CtOption};
use array::Array;
use subtle::CtOption;

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