Skip to content

Commit

Permalink
Updates for sec1 crate (#435)
Browse files Browse the repository at this point in the history
These code changes are necessary to support a migration to the `sec1`
crate, which extracted types like `EncodedPoint` into a separate
reusable crate.

Relevant `elliptic-curve` PR:

RustCrypto/traits#771
  • Loading branch information
tarcieri authored Sep 20, 2021
1 parent 9f5675d commit 10ee318
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 27 deletions.
12 changes: 7 additions & 5 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 bp256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["cryptography", "no-std"]
keywords = ["brainpool", "crypto", "ecc"]

[dependencies]
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa = { version = "=0.13.0-pre", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion bp384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["cryptography", "no-std"]
keywords = ["brainpool", "crypto", "ecc"]

[dependencies]
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa = { version = "=0.13.0-pre", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion k256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ keywords = ["bitcoin", "crypto", "ecc", "ethereum", "secp256k1"]

[dependencies]
cfg-if = "1.0"
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.13.0-pre", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
7 changes: 0 additions & 7 deletions k256/src/arithmetic/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,6 @@ mod tests {
assert_eq!(res.as_bytes(), UNCOMPRESSED_BASEPOINT);
}

#[test]
fn decompress() {
let encoded = EncodedPoint::from_bytes(COMPRESSED_BASEPOINT).unwrap();
let decompressed = encoded.decompress().unwrap();
assert_eq!(decompressed.as_bytes(), UNCOMPRESSED_BASEPOINT);
}

#[test]
fn affine_negation() {
let basepoint = AffinePoint::generator();
Expand Down
6 changes: 3 additions & 3 deletions k256/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ impl ecdsa_core::hazmat::DigestPrimitive for Secp256k1 {
#[cfg(all(test, feature = "ecdsa", feature = "arithmetic"))]
mod tests {
mod wycheproof {
use crate::Secp256k1;
use ecdsa_core::{elliptic_curve::sec1::EncodedPoint, signature::Verifier, Signature};
use crate::{EncodedPoint, Secp256k1};
use ecdsa_core::{signature::Verifier, Signature};

#[test]
fn wycheproof() {
Expand Down Expand Up @@ -135,7 +135,7 @@ mod tests {
) -> Option<&'static str> {
let x = element_from_padded_slice::<Secp256k1>(wx);
let y = element_from_padded_slice::<Secp256k1>(wy);
let q_encoded: EncodedPoint<Secp256k1> =
let q_encoded =
EncodedPoint::from_affine_coordinates(&x, &y, /* compress= */ false);
let verifying_key =
ecdsa_core::VerifyingKey::from_encoded_point(&q_encoded).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion p256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["cryptography", "no-std"]
keywords = ["crypto", "ecc", "nist", "prime256v1", "secp256r1"]

[dependencies]
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.13.0-pre", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
7 changes: 0 additions & 7 deletions p256/src/arithmetic/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,6 @@ mod tests {
assert_eq!(res.as_bytes(), UNCOMPRESSED_BASEPOINT);
}

#[test]
fn decompress() {
let encoded = EncodedPoint::from_bytes(COMPRESSED_BASEPOINT).unwrap();
let decompressed = encoded.decompress().unwrap();
assert_eq!(decompressed.as_bytes(), UNCOMPRESSED_BASEPOINT);
}

#[test]
fn affine_negation() {
let basepoint = AffinePoint::generator();
Expand Down
2 changes: 1 addition & 1 deletion p384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["crypto", "ecc", "nist", "secp384r1"]

[dependencies]
ecdsa = { version = "=0.13.0-pre", optional = true, default-features = false, features = ["der"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat", "sec1"] }
sha2 = { version = "0.9", optional = true, default-features = false }

[features]
Expand Down

0 comments on commit 10ee318

Please sign in to comment.