Skip to content

Commit

Permalink
ecdsa: use newly refactored sec1::EncodedPoint (#131)
Browse files Browse the repository at this point in the history
Uses the new `sec1::EncodedPoint` type introduced in
RustCrypto/traits#264
  • Loading branch information
tarcieri committed Aug 24, 2020
1 parent bcb96b0 commit ae1062a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[workspace]
members = ["ecdsa", "ed25519"]

[patch.crates-io]
elliptic-curve = { git = "https://github.com/RustCrypto/traits" }
11 changes: 3 additions & 8 deletions ecdsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ readme = "README.md"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "ecc", "nist", "secp256k1", "signature"]

[dependencies.elliptic-curve]
version = "0.5"
default-features = false
features = ["weierstrass"]

[dependencies.signature]
version = ">= 1.2.2, < 1.3.0"
default-features = false
[dependencies]
elliptic-curve = { version = "0.5", default-features = false, features = ["weierstrass"] }
signature = { version = ">= 1.2.2, < 1.3.0", default-features = false }

[features]
default = ["digest", "std"]
Expand Down
6 changes: 1 addition & 5 deletions ecdsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ pub mod signer;
pub mod verifier;

// Re-export the `elliptic-curve` crate (and select types)
pub use elliptic_curve::{
self, generic_array,
weierstrass::{Curve, PublicKey},
SecretKey,
};
pub use elliptic_curve::{self, generic_array, sec1::EncodedPoint, weierstrass::Curve, SecretKey};

// Re-export the `signature` crate (and select types)
pub use signature::{self, Error};
Expand Down
17 changes: 6 additions & 11 deletions ecdsa/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ use core::ops::Add;
use elliptic_curve::{
consts::U1,
generic_array::ArrayLength,
weierstrass::{
point::{CompressedPointSize, UncompressedPointSize},
public_key::{FromPublicKey, PublicKey},
Curve,
},
sec1::{EncodedPoint, FromEncodedPoint, UncompressedPointSize, UntaggedPointSize},
weierstrass::Curve,
Arithmetic,
};
use signature::{digest::Digest, DigestVerifier};
Expand All @@ -28,16 +25,14 @@ pub struct Verifier<C: Curve + Arithmetic> {
impl<C> Verifier<C>
where
C: Curve + Arithmetic,
C::AffinePoint: VerifyPrimitive<C> + FromPublicKey<C>,
C::ElementSize: Add<U1>,
<C::ElementSize as Add>::Output: Add<U1>,
CompressedPointSize<C>: ArrayLength<u8>,
C::AffinePoint: VerifyPrimitive<C> + FromEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
SignatureSize<C>: ArrayLength<u8>,
{
/// Create a new verifier
pub fn new(public_key: &PublicKey<C>) -> Result<Self, Error> {
let affine_point = C::AffinePoint::from_public_key(public_key);
pub fn new(public_key: &EncodedPoint<C>) -> Result<Self, Error> {
let affine_point = C::AffinePoint::from_encoded_point(public_key);

if affine_point.is_some().into() {
Ok(Self {
Expand Down

0 comments on commit ae1062a

Please sign in to comment.