Skip to content

Commit cbf794d

Browse files
authored
{curve,ed}25519-dalek: clippy fixes (#710)
Clippy 1.81 brings new lints, this fixes those warnings
1 parent d5ef57a commit cbf794d

File tree

6 files changed

+33
-25
lines changed

6 files changed

+33
-25
lines changed

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
@@ -215,10 +215,10 @@ impl MontgomeryPoint {
215215
/// # Return
216216
///
217217
/// * `Some(EdwardsPoint)` if `self` is the \\(u\\)-coordinate of a
218-
/// point on (the Montgomery form of) Curve25519;
218+
/// point on (the Montgomery form of) Curve25519;
219219
///
220220
/// * `None` if `self` is the \\(u\\)-coordinate of a point on the
221-
/// twist of (the Montgomery form of) Curve25519;
221+
/// twist of (the Montgomery form of) Curve25519;
222222
///
223223
pub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint> {
224224
// 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/src/signing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)