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

Fix missing features found by Rust 1.80 #1062

Merged
merged 1 commit into from
Jul 26, 2024
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
20 changes: 12 additions & 8 deletions bign256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ rust-version = "1.73"
elliptic-curve = { version = "=0.14.0-pre.5", features = ["hazmat", "sec1"] }

# optional dependencies
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
signature = { version = "=2.3.0-pre.3", optional = true }
belt-hash = { version = "=0.2.0-pre.3", optional = true, default-features = false }
rfc6979 = { version = "=0.5.0-pre.3", optional = true }
rand_core = "0.6.4"
pkcs8 = { version = "0.11.0-pre.0", optional = true }
sec1 = { version = "0.8.0-pre.1", optional = true }
der = { version = "0.8.0-pre.0" }

digest = { version = "0.11.0-pre.8", optional = true }
hex-literal = { version = "0.4", optional = true }
hkdf = { version = "0.13.0-pre.3", optional = true }
hmac = { version = "0.13.0-pre.3", optional = true }
rand_core = "0.6.4"
rfc6979 = { version = "=0.5.0-pre.3", optional = true }
pkcs8 = { version = "0.11.0-pre.0", optional = true }
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
sec1 = { version = "0.8.0-pre.1", optional = true }
signature = { version = "=2.3.0-pre.3", optional = true }

[dev-dependencies]
criterion = "0.5"
hex-literal = "0.4"
primeorder = { version = "=0.14.0-pre.0", features = ["dev"], path = "../primeorder" }
proptest = "1"
rand_core = { version = "0.6", features = ["getrandom"] }
hex = { version = "0.4" }
Expand All @@ -46,11 +47,14 @@ default = ["arithmetic", "pkcs8", "std", "ecdsa", "pem", "ecdh"]
alloc = ["elliptic-curve/alloc", "primeorder?/alloc"]
std = ["alloc", "elliptic-curve/std", "signature?/std"]

ecdsa = ["arithmetic", "dep:rfc6979", "dep:signature", "dep:belt-hash"]
arithmetic = ["dep:primeorder", "elliptic-curve/arithmetic"]
bits = ["arithmetic", "elliptic-curve/bits"]
ecdsa = ["arithmetic", "dep:rfc6979", "dep:signature", "dep:belt-hash"]
pem = ["pkcs8", "sec1/pem"]
pkcs8 = ["dep:pkcs8"]
ecdh = ["arithmetic", "elliptic-curve/ecdh", "dep:digest", "dep:hkdf", "dep:hmac", "dep:belt-hash", "alloc"]
serde = ["elliptic-curve/serde", "primeorder?/serde"]
test-vectors = ["dep:hex-literal"]

[[bench]]
name = "field"
Expand Down
3 changes: 0 additions & 3 deletions bign256/src/arithmetic/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ use primeorder::impl_bernstein_yang_invert;
#[cfg(feature = "bits")]
use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits};

#[cfg(feature = "serde")]
use serdect::serde::{de, ser, Deserialize, Serialize};

#[cfg(doc)]
use core::ops::{Add, Mul, Sub};

Expand Down
2 changes: 1 addition & 1 deletion bign256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ pub struct SecretKey {

/// Bit representation of a BIGN P-256 scalar field element.
#[cfg(feature = "bits")]
pub type ScalarBits = elliptic_curve::ScalarBits<BignP256>;
pub type ScalarBits = elliptic_curve::scalar::ScalarBits<BignP256>;
36 changes: 20 additions & 16 deletions bign256/tests/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

#![cfg(all(feature = "arithmetic", feature = "test-vectors"))]

use elliptic_curve::{
group::{ff::PrimeField, GroupEncoding},
sec1::{self, ToEncodedPoint},
};
use p256::{
test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS},
AffinePoint, ProjectivePoint, Scalar,
};
use primeorder::{impl_projective_arithmetic_tests, Double};
// TODO(tarcieri): these are failing
//
// use bign256::{
// test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS},
// AffinePoint, ProjectivePoint, Scalar,
// };
// use elliptic_curve::{
// group::{ff::PrimeField, GroupEncoding},
// sec1::{self, ToEncodedPoint},
// };
// use primeorder::{impl_projective_arithmetic_tests, Double};
//
// impl_projective_arithmetic_tests!(
// AffinePoint,
// ProjectivePoint,
// Scalar,
// ADD_TEST_VECTORS,
// MUL_TEST_VECTORS
// );

impl_projective_arithmetic_tests!(
AffinePoint,
ProjectivePoint,
Scalar,
ADD_TEST_VECTORS,
MUL_TEST_VECTORS
);
use bign256::{elliptic_curve::group::GroupEncoding, ProjectivePoint};

#[test]
fn projective_identity_to_bytes() {
Expand Down
16 changes: 0 additions & 16 deletions p521/src/arithmetic/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ use elliptic_curve::{
};
use primefield::{impl_bernstein_yang_invert, impl_field_op};

#[cfg(feature = "bits")]
use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits};

#[cfg(feature = "serde")]
use serdect::serde::{de, ser, Deserialize, Serialize};

Expand Down Expand Up @@ -576,19 +573,6 @@ impl PrimeField for Scalar {
}
}

#[cfg(feature = "bits")]
impl PrimeFieldBits for Scalar {
type ReprBits = fiat_p521_scalar_montgomery_domain_field_element;

fn to_le_bits(&self) -> ScalarBits {
self.to_canonical().to_words().into()
}

fn char_le_bits() -> ScalarBits {
NistP521::ORDER.to_words().into()
}
}

impl Reduce<U576> for Scalar {
type Bytes = FieldBytes;

Expand Down
1 change: 1 addition & 0 deletions sm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ alloc = ["elliptic-curve/alloc"]
std = ["alloc", "elliptic-curve/std", "signature?/std"]

arithmetic = ["dep:primeorder", "elliptic-curve/arithmetic"]
bits = ["arithmetic", "elliptic-curve/bits"]
dsa = ["arithmetic", "dep:rfc6979", "dep:signature", "dep:sm3"]
getrandom = ["rand_core/getrandom"]
pem = ["elliptic-curve/pem", "pkcs8"]
Expand Down
2 changes: 1 addition & 1 deletion sm2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ impl elliptic_curve::sec1::ValidatePublicKey for Sm2 {}

/// Bit representation of a SM2 scalar field element.
#[cfg(feature = "bits")]
pub type ScalarBits = elliptic_curve::ScalarBits<Sm2>;
pub type ScalarBits = elliptic_curve::scalar::ScalarBits<Sm2>;
Loading