Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecdsa: use newly refactored sec1::EncodedPoint #131

Merged
merged 1 commit into from
Aug 24, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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