Skip to content

Commit

Permalink
elliptic-curve: faster PublicKey::from_encoded_point (#1310)
Browse files Browse the repository at this point in the history
Checks if the SEC1 point is using the identity encoding directly, rather
than round tripping through `ProjectivePoint`.
  • Loading branch information
tarcieri committed May 18, 2023
1 parent a7a62e2 commit 808fa1e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions elliptic-curve/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use {
FieldBytesSize,
},
core::cmp::Ordering,
subtle::CtOption,
subtle::{Choice, CtOption},
};

#[cfg(all(feature = "alloc", feature = "pkcs8"))]
Expand Down Expand Up @@ -231,7 +231,7 @@ where
/// Initialize [`PublicKey`] from an [`EncodedPoint`]
fn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self> {
AffinePoint::<C>::from_encoded_point(encoded_point).and_then(|point| {
let is_identity = ProjectivePoint::<C>::from(point).is_identity();
let is_identity = Choice::from(encoded_point.is_identity() as u8);
CtOption::new(PublicKey { point }, !is_identity)
})
}
Expand Down

0 comments on commit 808fa1e

Please sign in to comment.