Skip to content

Commit e7d61b5

Browse files
authored
ed25519-dalek: fixup pkcs8 API break (#709)
1 parent 44508ba commit e7d61b5

File tree

10 files changed

+41
-31
lines changed

10 files changed

+41
-31
lines changed

.github/workflows/ed25519-dalek.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
jobs:
2121

2222
msrv:
23-
name: Current MSRV is 1.60.0
23+
name: Current MSRV is 1.72.0
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v3
@@ -29,5 +29,5 @@ jobs:
2929
- run: cargo update -Z minimal-versions
3030
# Now check that `cargo build` works with respect to the oldest possible
3131
# deps and the stated MSRV
32-
- uses: dtolnay/rust-toolchain@1.60.0
32+
- uses: dtolnay/rust-toolchain@1.72.0
3333
- run: cargo build

.github/workflows/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
runs-on: ubuntu-latest
8686
steps:
8787
- uses: actions/checkout@v3
88-
- uses: dtolnay/rust-toolchain@1.73.0
88+
- uses: dtolnay/rust-toolchain@1.81.0
8989
with:
9090
components: clippy
9191
- run: cargo clippy --target x86_64-unknown-linux-gnu --all-features

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ resolver = "2"
1010
[profile.dev]
1111
opt-level = 2
1212

13+
[patch.crates-io]
14+
ed25519 = { git = "https://github.com/RustCrypto/signatures.git" }

curve25519-dalek/src/backend/vector/avx2/edwards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! This module currently has two point types:
1515
//!
1616
//! * `ExtendedPoint`: a point stored in vector-friendly format, with
17-
//! vectorized doubling and addition;
17+
//! vectorized doubling and addition;
1818
//!
1919
//! * `CachedPoint`: used for readdition.
2020
//!

curve25519-dalek/src/backend/vector/packed_simd.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ impl u64x4 {
240240
pub const fn new_const(x0: u64, x1: u64, x2: u64, x3: u64) -> Self {
241241
// SAFETY: Transmuting between an array and a SIMD type is safe
242242
// https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
243-
unsafe { Self(core::mem::transmute([x0, x1, x2, x3])) }
243+
unsafe {
244+
Self(core::mem::transmute::<[u64; 4], core::arch::x86_64::__m256i>([x0, x1, x2, x3]))
245+
}
244246
}
245247

246248
/// A constified variant of `splat`.
@@ -290,7 +292,13 @@ impl u32x8 {
290292
) -> Self {
291293
// SAFETY: Transmuting between an array and a SIMD type is safe
292294
// https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
293-
unsafe { Self(core::mem::transmute([x0, x1, x2, x3, x4, x5, x6, x7])) }
295+
unsafe {
296+
Self(
297+
core::mem::transmute::<[u32; 8], core::arch::x86_64::__m256i>([
298+
x0, x1, x2, x3, x4, x5, x6, x7,
299+
]),
300+
)
301+
}
294302
}
295303

296304
/// A constified variant of `splat`.

curve25519-dalek/src/edwards.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@
5252
//! Scalar multiplication on Edwards points is provided by:
5353
//!
5454
//! * the `*` operator between a `Scalar` and a `EdwardsPoint`, which
55-
//! performs constant-time variable-base scalar multiplication;
55+
//! performs constant-time variable-base scalar multiplication;
5656
//!
5757
//! * the `*` operator between a `Scalar` and a
58-
//! `EdwardsBasepointTable`, which performs constant-time fixed-base
59-
//! scalar multiplication;
58+
//! `EdwardsBasepointTable`, which performs constant-time fixed-base
59+
//! scalar multiplication;
6060
//!
6161
//! * an implementation of the
62-
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
63-
//! constant-time variable-base multiscalar multiplication;
62+
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
63+
//! constant-time variable-base multiscalar multiplication;
6464
//!
6565
//! * an implementation of the
66-
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
67-
//! trait for variable-time variable-base multiscalar multiplication;
66+
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
67+
//! trait for variable-time variable-base multiscalar multiplication;
6868
//!
6969
//! ## Implementation
7070
//!
@@ -1234,9 +1234,9 @@ impl EdwardsPoint {
12341234
/// # Return
12351235
///
12361236
/// * `true` if `self` has zero torsion component and is in the
1237-
/// prime-order subgroup;
1237+
/// prime-order subgroup;
12381238
/// * `false` if `self` has a nonzero torsion component and is not
1239-
/// in the prime-order subgroup.
1239+
/// in the prime-order subgroup.
12401240
///
12411241
/// # Example
12421242
///

curve25519-dalek/src/montgomery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ impl MontgomeryPoint {
209209
/// # Return
210210
///
211211
/// * `Some(EdwardsPoint)` if `self` is the \\(u\\)-coordinate of a
212-
/// point on (the Montgomery form of) Curve25519;
212+
/// point on (the Montgomery form of) Curve25519;
213213
///
214214
/// * `None` if `self` is the \\(u\\)-coordinate of a point on the
215-
/// twist of (the Montgomery form of) Curve25519;
215+
/// twist of (the Montgomery form of) Curve25519;
216216
///
217217
pub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint> {
218218
// To decompress the Montgomery u coordinate to an

curve25519-dalek/src/ristretto.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,31 @@
9393
//! Scalar multiplication on Ristretto points is provided by:
9494
//!
9595
//! * the `*` operator between a `Scalar` and a `RistrettoPoint`, which
96-
//! performs constant-time variable-base scalar multiplication;
96+
//! performs constant-time variable-base scalar multiplication;
9797
//!
9898
//! * the `*` operator between a `Scalar` and a
99-
//! `RistrettoBasepointTable`, which performs constant-time fixed-base
100-
//! scalar multiplication;
99+
//! `RistrettoBasepointTable`, which performs constant-time fixed-base
100+
//! scalar multiplication;
101101
//!
102102
//! * an implementation of the
103-
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
104-
//! constant-time variable-base multiscalar multiplication;
103+
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
104+
//! constant-time variable-base multiscalar multiplication;
105105
//!
106106
//! * an implementation of the
107-
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
108-
//! trait for variable-time variable-base multiscalar multiplication;
107+
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
108+
//! trait for variable-time variable-base multiscalar multiplication;
109109
//!
110110
//! ## Random Points and Hashing to Ristretto
111111
//!
112112
//! The Ristretto group comes equipped with an Elligator map. This is
113113
//! used to implement
114114
//!
115115
//! * `RistrettoPoint::random()`, which generates random points from an
116-
//! RNG - enabled by `rand_core` feature;
116+
//! RNG - enabled by `rand_core` feature;
117117
//!
118118
//! * `RistrettoPoint::from_hash()` and
119-
//! `RistrettoPoint::hash_from_bytes()`, which perform hashing to the
120-
//! group.
119+
//! `RistrettoPoint::hash_from_bytes()`, which perform hashing to the
120+
//! group.
121121
//!
122122
//! The Elligator map itself is not currently exposed.
123123
//!

ed25519-dalek/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ keywords = ["cryptography", "ed25519", "curve25519", "signature", "ECC"]
1616
categories = ["cryptography", "no-std"]
1717
description = "Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust."
1818
exclude = [ ".gitignore", "TESTVECTORS", "VALIDATIONVECTORS", "res/*" ]
19-
rust-version = "1.60"
19+
rust-version = "1.72"
2020

2121
[package.metadata.docs.rs]
2222
rustdoc-args = [

ed25519-dalek/src/signing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,10 @@ impl From<&SigningKey> for pkcs8::KeypairBytes {
713713
}
714714

715715
#[cfg(feature = "pkcs8")]
716-
impl TryFrom<pkcs8::PrivateKeyInfo<'_>> for SigningKey {
716+
impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for SigningKey {
717717
type Error = pkcs8::Error;
718718

719-
fn try_from(private_key: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
719+
fn try_from(private_key: pkcs8::PrivateKeyInfoRef<'_>) -> pkcs8::Result<Self> {
720720
pkcs8::KeypairBytes::try_from(private_key)?.try_into()
721721
}
722722
}
@@ -774,7 +774,7 @@ impl<'d> Deserialize<'d> for SigningKey {
774774
));
775775
}
776776

777-
SigningKey::try_from(bytes).map_err(serde::de::Error::custom)
777+
Ok(SigningKey::from(bytes))
778778
}
779779
}
780780

0 commit comments

Comments
 (0)