Skip to content

Commit aba0980

Browse files
authored
Bump elliptic-curve; make ORDER a NonZero; remove JWK
- Bumps `crypto-bigint` from 0.7.0-rc.0 to 0.7.0-rc.1 - Make ORDER a NonZero - Use `NonZero::from_be_byte_array` whenever available - Bumps the pin for `elliptic-curve` to latest master - Removes the support for JWK in the crates. JWK consumers are invited to use `jose-jwk` instead: https://github.com/RustCrypto/JOSE/tree/master/jose-jwk
1 parent e797acd commit aba0980

File tree

61 files changed

+157
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+157
-141
lines changed

.github/workflows/k256.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ jobs:
5050
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa-core
5151
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa
5252
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features hash2curve
53-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features jwk
5453
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem
5554
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
5655
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features schnorr
5756
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
5857
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha256
5958
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa
6059
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa,sha256
61-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features bits,critical-section,ecdh,ecdsa,hash2curve,jwk,pem,pkcs8,schnorr,serde,sha256
60+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features bits,critical-section,ecdh,ecdsa,hash2curve,pem,pkcs8,schnorr,serde,sha256
6261

6362
benches:
6463
runs-on: ubuntu-latest

.github/workflows/p256.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ jobs:
4949
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa-core
5050
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa
5151
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features hash2curve
52-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features jwk
5352
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features oprf
5453
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem
5554
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
5655
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
5756
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha256
58-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,hash2curve,jwk,oprf,pem,pkcs8,serde,sha256
57+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,hash2curve,oprf,pem,pkcs8,serde,sha256
5958

6059
benches:
6160
runs-on: ubuntu-latest

.github/workflows/p384.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ jobs:
4646
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic
4747
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa-core
4848
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features hash2curve
49-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features jwk
5049
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features oprf
5150
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem
5251
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
5352
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
5453
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha384
55-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa-core,hash2curve,jwk,oprf,pem,pkcs8,serde,sha384
54+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa-core,hash2curve,oprf,pem,pkcs8,serde,sha384
5655

5756
benches:
5857
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ members = [
2121
opt-level = 2
2222

2323
[patch.crates-io]
24-
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
24+
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint" }
25+
26+
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
27+
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
2528

2629
hash2curve = { path = "hash2curve" }
2730
primefield = { path = "primefield" }

bign256/src/arithmetic/field.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ use self::field_impl::*;
3333
use crate::{BignP256, FieldBytes, U256};
3434
use elliptic_curve::{
3535
FieldBytesEncoding,
36+
bigint::NonZero,
3637
ff::PrimeField,
3738
subtle::{Choice, ConstantTimeEq, CtOption},
3839
};
3940

4041
/// Constant representing the modulus
4142
/// p = 2^{256} − 189
42-
pub(crate) const MODULUS: U256 =
43-
U256::from_be_hex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF43");
43+
pub(crate) const MODULUS: NonZero<U256> = NonZero::<U256>::from_be_hex(
44+
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF43",
45+
);
4446

4547
/// Element of the bign-256 base field used for curve coordinates.
4648
#[derive(Clone, Copy)]

bign256/src/arithmetic/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl FromUintUnchecked for Scalar {
122122

123123
impl IsHigh for Scalar {
124124
fn is_high(&self) -> Choice {
125-
const MODULUS_SHR1: U256 = BignP256::ORDER.shr_vartime(1);
125+
const MODULUS_SHR1: U256 = BignP256::ORDER.as_ref().shr_vartime(1);
126126
self.to_canonical().ct_gt(&MODULUS_SHR1)
127127
}
128128
}

bign256/src/ecdsa/signing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl PrehashSigner<Signature> for SigningKey {
114114
//2. Generate 𝑘 ← rand(1,..,𝑞-1)
115115
let k = Scalar::from_repr(rfc6979::generate_k::<BeltHash, _>(
116116
&self.secret_scalar.to_repr(),
117-
&FieldBytesEncoding::<BignP256>::encode_field_bytes(&BignP256::ORDER),
117+
&FieldBytesEncoding::<BignP256>::encode_field_bytes(BignP256::ORDER.as_ref()),
118118
&h.to_bytes(),
119119
&[],
120120
))

bign256/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
extern crate alloc;
3131

3232
pub use elliptic_curve::{self, bigint::U256};
33-
use elliptic_curve::{Error, FieldBytesEncoding, bigint::ArrayEncoding, consts::U32};
33+
use elliptic_curve::{
34+
Error, FieldBytesEncoding,
35+
bigint::{ArrayEncoding, NonZero},
36+
consts::U32,
37+
};
3438

3539
#[cfg(feature = "arithmetic")]
3640
pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar};
@@ -89,7 +93,7 @@ impl elliptic_curve::Curve for BignP256 {
8993
type Uint = U256;
9094

9195
/// Order of BIGN P-256's elliptic curve group (i.e. scalar modulus).
92-
const ORDER: U256 = U256::from_be_hex(ORDER_HEX);
96+
const ORDER: NonZero<U256> = NonZero::<U256>::from_be_hex(ORDER_HEX);
9397
}
9498

9599
impl elliptic_curve::PrimeCurve for BignP256 {}

bp256/src/arithmetic/field.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ mod field_impl;
1717
use self::field_impl::*;
1818
use crate::{FieldBytes, U256};
1919
use elliptic_curve::{
20+
bigint::NonZero,
2021
ff::PrimeField,
2122
subtle::{Choice, ConstantTimeEq, CtOption},
2223
};
2324

2425
/// Constant representing the modulus serialized as hex.
2526
const MODULUS_HEX: &str = "a9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377";
2627

27-
const MODULUS: U256 = U256::from_be_hex(MODULUS_HEX);
28+
const MODULUS: NonZero<U256> = NonZero::<U256>::from_be_hex(MODULUS_HEX);
2829

2930
/// Element of the brainpoolP256's base field used for curve point coordinates.
3031
#[derive(Clone, Copy)]

0 commit comments

Comments
 (0)