Skip to content

Commit 616b20c

Browse files
authored
Bump elliptic-curve to v0.11.0-pre (#402)
Sourced from git. This includes transitive updates to ff and group v0.11. A major notable change of these updates is switching several APIs to use `subtle::Choice` and `subtle::CtOption` instead of `bool`/`Option`. Fortunately, the crates in this repo are already written with constant-time implementations internally, so this was an easy change.
1 parent eda5854 commit 616b20c

File tree

23 files changed

+142
-208
lines changed

23 files changed

+142
-208
lines changed

.github/workflows/k256.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -99,37 +99,38 @@ jobs:
9999
- run: cargo test --release --target ${{ matrix.target }} --features field-montgomery
100100
- run: cargo test --release --target ${{ matrix.target }} --all-features
101101

102-
cross:
103-
strategy:
104-
matrix:
105-
include:
106-
# ARM32
107-
- target: armv7-unknown-linux-gnueabihf
108-
rust: 1.51.0 # MSRV
109-
- target: armv7-unknown-linux-gnueabihf
110-
rust: stable
111-
112-
# ARM64
113-
- target: aarch64-unknown-linux-gnu
114-
rust: 1.51.0 # MSRV
115-
- target: aarch64-unknown-linux-gnu
116-
rust: stable
117-
118-
# PPC32
119-
- target: powerpc-unknown-linux-gnu
120-
rust: 1.51.0 # MSRV
121-
- target: powerpc-unknown-linux-gnu
122-
rust: stable
123-
124-
runs-on: ubuntu-latest
125-
steps:
126-
- uses: actions/checkout@v2
127-
- run: ${{ matrix.deps }}
128-
- uses: actions-rs/toolchain@v1
129-
with:
130-
profile: minimal
131-
toolchain: ${{ matrix.rust }}
132-
target: ${{ matrix.target }}
133-
override: true
134-
- run: cargo install cross
135-
- run: cross test --release --target ${{ matrix.target }} --all-features
102+
# TODO(tarcieri): re-enable when new `elliptic-curve` and `ecdsa` crates are released
103+
# cross:
104+
# strategy:
105+
# matrix:
106+
# include:
107+
# # ARM32
108+
# - target: armv7-unknown-linux-gnueabihf
109+
# rust: 1.51.0 # MSRV
110+
# - target: armv7-unknown-linux-gnueabihf
111+
# rust: stable
112+
#
113+
# # ARM64
114+
# - target: aarch64-unknown-linux-gnu
115+
# rust: 1.51.0 # MSRV
116+
# - target: aarch64-unknown-linux-gnu
117+
# rust: stable
118+
#
119+
# # PPC32
120+
# - target: powerpc-unknown-linux-gnu
121+
# rust: 1.51.0 # MSRV
122+
# - target: powerpc-unknown-linux-gnu
123+
# rust: stable
124+
#
125+
# runs-on: ubuntu-latest
126+
# steps:
127+
# - uses: actions/checkout@v2
128+
# - run: ${{ matrix.deps }}
129+
# - uses: actions-rs/toolchain@v1
130+
# with:
131+
# profile: minimal
132+
# toolchain: ${{ matrix.rust }}
133+
# target: ${{ matrix.target }}
134+
# override: true
135+
# - run: cargo install cross
136+
# - run: cross test --release --target ${{ matrix.target }} --all-features

.github/workflows/p256.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,37 +80,38 @@ jobs:
8080
- run: cargo test --release --target ${{ matrix.target }}
8181
- run: cargo test --release --target ${{ matrix.target }} --all-features
8282

83-
cross:
84-
strategy:
85-
matrix:
86-
include:
87-
# ARM32
88-
- target: armv7-unknown-linux-gnueabihf
89-
rust: 1.51.0 # MSRV
90-
- target: armv7-unknown-linux-gnueabihf
91-
rust: stable
92-
93-
# ARM64
94-
- target: aarch64-unknown-linux-gnu
95-
rust: 1.51.0 # MSRV
96-
- target: aarch64-unknown-linux-gnu
97-
rust: stable
98-
99-
# PPC32
100-
- target: powerpc-unknown-linux-gnu
101-
rust: 1.51.0 # MSRV
102-
- target: powerpc-unknown-linux-gnu
103-
rust: stable
104-
105-
runs-on: ubuntu-latest
106-
steps:
107-
- uses: actions/checkout@v2
108-
- run: ${{ matrix.deps }}
109-
- uses: actions-rs/toolchain@v1
110-
with:
111-
profile: minimal
112-
toolchain: ${{ matrix.rust }}
113-
target: ${{ matrix.target }}
114-
override: true
115-
- run: cargo install cross
116-
- run: cross test --release --target ${{ matrix.target }} --all-features
83+
# TODO(tarcieri): re-enable when new `elliptic-curve` and `ecdsa` crates are released
84+
# cross:
85+
# strategy:
86+
# matrix:
87+
# include:
88+
# # ARM32
89+
# - target: armv7-unknown-linux-gnueabihf
90+
# rust: 1.51.0 # MSRV
91+
# - target: armv7-unknown-linux-gnueabihf
92+
# rust: stable
93+
#
94+
# # ARM64
95+
# - target: aarch64-unknown-linux-gnu
96+
# rust: 1.51.0 # MSRV
97+
# - target: aarch64-unknown-linux-gnu
98+
# rust: stable
99+
#
100+
# # PPC32
101+
# - target: powerpc-unknown-linux-gnu
102+
# rust: 1.51.0 # MSRV
103+
# - target: powerpc-unknown-linux-gnu
104+
# rust: stable
105+
#
106+
# runs-on: ubuntu-latest
107+
# steps:
108+
# - uses: actions/checkout@v2
109+
# - run: ${{ matrix.deps }}
110+
# - uses: actions-rs/toolchain@v1
111+
# with:
112+
# profile: minimal
113+
# toolchain: ${{ matrix.rust }}
114+
# target: ${{ matrix.target }}
115+
# override: true
116+
# - run: cargo install cross
117+
# - run: cross test --release --target ${{ matrix.target }} --all-features

Cargo.lock

Lines changed: 13 additions & 15 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ members = [
77
"p256",
88
"p384",
99
]
10+
11+
[patch.crates-io]
12+
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
13+
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }

bp256/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bp256"
33
description = "Brainpool P-256 (brainpoolP256r1 and brainpoolP256t1) elliptic curves"
4-
version = "0.2.0" # Also update html_root_url in lib.rs when bumping this
4+
version = "0.3.0-pre" # Also update html_root_url in lib.rs when bumping this
55
authors = ["RustCrypto Developers"]
66
license = "Apache-2.0 OR MIT"
77
documentation = "https://docs.rs/elliptic-curve"
@@ -12,10 +12,10 @@ categories = ["cryptography", "no-std"]
1212
keywords = ["brainpool", "crypto", "ecc"]
1313

1414
[dependencies]
15-
elliptic-curve = { version = "0.10", default-features = false, features = ["hazmat"] }
15+
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
1616

1717
# optional dependencies
18-
ecdsa = { version = "0.12", optional = true, default-features = false, features = ["der"] }
18+
ecdsa = { version = "=0.13.0-pre", optional = true, default-features = false, features = ["der"] }
1919
sha2 = { version = "0.9", optional = true, default-features = false }
2020

2121
[features]

bp256/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#![doc(
1313
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
1414
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
15-
html_root_url = "https://docs.rs/bp256/0.2.0"
15+
html_root_url = "https://docs.rs/bp256/0.3.0-pre"
1616
)]
1717
#![forbid(unsafe_code)]
1818
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]

bp384/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bp384"
33
description = "Brainpool P-384 (brainpoolP384r1 and brainpoolP384t1) elliptic curves"
4-
version = "0.2.0" # Also update html_root_url in lib.rs when bumping this
4+
version = "0.3.0-pre" # Also update html_root_url in lib.rs when bumping this
55
authors = ["RustCrypto Developers"]
66
license = "Apache-2.0 OR MIT"
77
documentation = "https://docs.rs/elliptic-curve"
@@ -12,10 +12,10 @@ categories = ["cryptography", "no-std"]
1212
keywords = ["brainpool", "crypto", "ecc"]
1313

1414
[dependencies]
15-
elliptic-curve = { version = "0.10", default-features = false, features = ["hazmat"] }
15+
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
1616

1717
# optional dependencies
18-
ecdsa = { version = "0.12", optional = true, default-features = false, features = ["der"] }
18+
ecdsa = { version = "=0.13.0-pre", optional = true, default-features = false, features = ["der"] }
1919
sha2 = { version = "0.9", optional = true, default-features = false }
2020

2121
[features]

bp384/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#![doc(
1313
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
1414
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
15-
html_root_url = "https://docs.rs/bp384/0.2.0"
15+
html_root_url = "https://docs.rs/bp384/0.3.0-pre"
1616
)]
1717
#![forbid(unsafe_code)]
1818
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]

k256/Cargo.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ signing/verification (including Ethereum-style signatures with public-key
66
recovery), Elliptic Curve Diffie-Hellman (ECDH), and general purpose secp256k1
77
curve arithmetic useful for implementing arbitrary group-based protocols.
88
"""
9-
version = "0.9.6" # Also update html_root_url in lib.rs when bumping this
9+
version = "0.10.0-pre" # Also update html_root_url in lib.rs when bumping this
1010
authors = ["RustCrypto Developers"]
1111
license = "Apache-2.0 OR MIT"
1212
documentation = "https://docs.rs/elliptic-curve"
@@ -18,24 +18,18 @@ keywords = ["bitcoin", "crypto", "ecc", "ethereum", "secp256k1"]
1818

1919
[dependencies]
2020
cfg-if = "1.0"
21-
elliptic-curve = { version = "0.10.6", default-features = false, features = ["hazmat"] }
21+
elliptic-curve = { version = "=0.11.0-pre", default-features = false, features = ["hazmat"] }
2222

2323
# optional dependencies
24+
ecdsa-core = { version = "=0.13.0-pre", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
2425
hex-literal = { version = "0.3", optional = true }
2526
sha2 = { version = "0.9", optional = true, default-features = false }
2627
sha3 = { version = "0.9", optional = true, default-features = false }
2728

28-
[dependencies.ecdsa-core]
29-
version = "0.12.1"
30-
package = "ecdsa"
31-
optional = true
32-
default-features = false
33-
features = ["der"]
34-
3529
[dev-dependencies]
3630
blobby = "0.3"
3731
criterion = "0.3"
38-
ecdsa-core = { version = "0.12.1", package = "ecdsa", default-features = false, features = ["dev"] }
32+
ecdsa-core = { version = "=0.13.0-pre", package = "ecdsa", default-features = false, features = ["dev"] }
3933
hex-literal = "0.3"
4034
num-bigint = "0.4"
4135
num-traits = "0.2"

k256/src/arithmetic/scalar.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ impl Field for Scalar {
9595
Scalar::one()
9696
}
9797

98-
fn is_zero(&self) -> bool {
99-
self.0.is_zero().into()
100-
}
101-
10298
#[must_use]
10399
fn square(&self) -> Self {
104100
Scalar::square(self)
@@ -493,16 +489,16 @@ impl PrimeField for Scalar {
493489
///
494490
/// Returns None if the byte array does not contain a big-endian integer in the range
495491
/// [0, p).
496-
fn from_repr(bytes: FieldBytes) -> Option<Self> {
497-
ScalarImpl::from_bytes(bytes.as_ref()).map(Self).into()
492+
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
493+
ScalarImpl::from_bytes(bytes.as_ref()).map(Self)
498494
}
499495

500496
fn to_repr(&self) -> FieldBytes {
501497
self.to_bytes()
502498
}
503499

504-
fn is_odd(&self) -> bool {
505-
self.0.is_odd().into()
500+
fn is_odd(&self) -> Choice {
501+
self.0.is_odd()
506502
}
507503

508504
fn multiplicative_generator() -> Self {
@@ -707,7 +703,7 @@ impl Scalar {
707703
// TODO: pre-generate several scalars to bring the probability of non-constant-timeness down?
708704
loop {
709705
rng.fill_bytes(&mut bytes);
710-
if let Some(scalar) = Scalar::from_repr(bytes) {
706+
if let Some(scalar) = Scalar::from_repr(bytes).into() {
711707
return scalar;
712708
}
713709
}

0 commit comments

Comments
 (0)