{curve,ed}25519-dalek: clippy fixes (#710)

Clippy 1.81 brings new lints, this fixes those warnings
This commit is contained in:
Arthur Gautier 2024-09-30 14:09:28 -07:00 committed by GitHub
parent d5ef57a3c2
commit cbf794d883
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 25 deletions

View file

@ -14,7 +14,7 @@
//! This module currently has two point types: //! This module currently has two point types:
//! //!
//! * `ExtendedPoint`: a point stored in vector-friendly format, with //! * `ExtendedPoint`: a point stored in vector-friendly format, with
//! vectorized doubling and addition; //! vectorized doubling and addition;
//! //!
//! * `CachedPoint`: used for readdition. //! * `CachedPoint`: used for readdition.
//! //!

View file

@ -240,7 +240,9 @@ impl u64x4 {
pub const fn new_const(x0: u64, x1: u64, x2: u64, x3: u64) -> Self { pub const fn new_const(x0: u64, x1: u64, x2: u64, x3: u64) -> Self {
// SAFETY: Transmuting between an array and a SIMD type is safe // SAFETY: Transmuting between an array and a SIMD type is safe
// https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html // https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
unsafe { Self(core::mem::transmute([x0, x1, x2, x3])) } unsafe {
Self(core::mem::transmute::<[u64; 4], core::arch::x86_64::__m256i>([x0, x1, x2, x3]))
}
} }
/// A constified variant of `splat`. /// A constified variant of `splat`.
@ -290,7 +292,13 @@ impl u32x8 {
) -> Self { ) -> Self {
// SAFETY: Transmuting between an array and a SIMD type is safe // SAFETY: Transmuting between an array and a SIMD type is safe
// https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html // https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
unsafe { Self(core::mem::transmute([x0, x1, x2, x3, x4, x5, x6, x7])) } unsafe {
Self(
core::mem::transmute::<[u32; 8], core::arch::x86_64::__m256i>([
x0, x1, x2, x3, x4, x5, x6, x7,
]),
)
}
} }
/// A constified variant of `splat`. /// A constified variant of `splat`.

View file

@ -52,19 +52,19 @@
//! Scalar multiplication on Edwards points is provided by: //! Scalar multiplication on Edwards points is provided by:
//! //!
//! * the `*` operator between a `Scalar` and a `EdwardsPoint`, which //! * the `*` operator between a `Scalar` and a `EdwardsPoint`, which
//! performs constant-time variable-base scalar multiplication; //! performs constant-time variable-base scalar multiplication;
//! //!
//! * the `*` operator between a `Scalar` and a //! * the `*` operator between a `Scalar` and a
//! `EdwardsBasepointTable`, which performs constant-time fixed-base //! `EdwardsBasepointTable`, which performs constant-time fixed-base
//! scalar multiplication; //! scalar multiplication;
//! //!
//! * an implementation of the //! * an implementation of the
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for //! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
//! constant-time variable-base multiscalar multiplication; //! constant-time variable-base multiscalar multiplication;
//! //!
//! * an implementation of the //! * an implementation of the
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html) //! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
//! trait for variable-time variable-base multiscalar multiplication; //! trait for variable-time variable-base multiscalar multiplication;
//! //!
//! ## Implementation //! ## Implementation
//! //!
@ -1234,9 +1234,9 @@ impl EdwardsPoint {
/// # Return /// # Return
/// ///
/// * `true` if `self` has zero torsion component and is in the /// * `true` if `self` has zero torsion component and is in the
/// prime-order subgroup; /// prime-order subgroup;
/// * `false` if `self` has a nonzero torsion component and is not /// * `false` if `self` has a nonzero torsion component and is not
/// in the prime-order subgroup. /// in the prime-order subgroup.
/// ///
/// # Example /// # Example
/// ///

View file

@ -215,10 +215,10 @@ impl MontgomeryPoint {
/// # Return /// # Return
/// ///
/// * `Some(EdwardsPoint)` if `self` is the \\(u\\)-coordinate of a /// * `Some(EdwardsPoint)` if `self` is the \\(u\\)-coordinate of a
/// point on (the Montgomery form of) Curve25519; /// point on (the Montgomery form of) Curve25519;
/// ///
/// * `None` if `self` is the \\(u\\)-coordinate of a point on the /// * `None` if `self` is the \\(u\\)-coordinate of a point on the
/// twist of (the Montgomery form of) Curve25519; /// twist of (the Montgomery form of) Curve25519;
/// ///
pub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint> { pub fn to_edwards(&self, sign: u8) -> Option<EdwardsPoint> {
// To decompress the Montgomery u coordinate to an // To decompress the Montgomery u coordinate to an

View file

@ -93,19 +93,19 @@
//! Scalar multiplication on Ristretto points is provided by: //! Scalar multiplication on Ristretto points is provided by:
//! //!
//! * the `*` operator between a `Scalar` and a `RistrettoPoint`, which //! * the `*` operator between a `Scalar` and a `RistrettoPoint`, which
//! performs constant-time variable-base scalar multiplication; //! performs constant-time variable-base scalar multiplication;
//! //!
//! * the `*` operator between a `Scalar` and a //! * the `*` operator between a `Scalar` and a
//! `RistrettoBasepointTable`, which performs constant-time fixed-base //! `RistrettoBasepointTable`, which performs constant-time fixed-base
//! scalar multiplication; //! scalar multiplication;
//! //!
//! * an implementation of the //! * an implementation of the
//! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for //! [`MultiscalarMul`](../traits/trait.MultiscalarMul.html) trait for
//! constant-time variable-base multiscalar multiplication; //! constant-time variable-base multiscalar multiplication;
//! //!
//! * an implementation of the //! * an implementation of the
//! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html) //! [`VartimeMultiscalarMul`](../traits/trait.VartimeMultiscalarMul.html)
//! trait for variable-time variable-base multiscalar multiplication; //! trait for variable-time variable-base multiscalar multiplication;
//! //!
//! ## Random Points and Hashing to Ristretto //! ## Random Points and Hashing to Ristretto
//! //!
@ -113,11 +113,11 @@
//! used to implement //! used to implement
//! //!
//! * `RistrettoPoint::random()`, which generates random points from an //! * `RistrettoPoint::random()`, which generates random points from an
//! RNG - enabled by `rand_core` feature; //! RNG - enabled by `rand_core` feature;
//! //!
//! * `RistrettoPoint::from_hash()` and //! * `RistrettoPoint::from_hash()` and
//! `RistrettoPoint::hash_from_bytes()`, which perform hashing to the //! `RistrettoPoint::hash_from_bytes()`, which perform hashing to the
//! group. //! group.
//! //!
//! The Elligator map itself is not currently exposed. //! The Elligator map itself is not currently exposed.
//! //!

View file

@ -774,7 +774,7 @@ impl<'d> Deserialize<'d> for SigningKey {
)); ));
} }
SigningKey::try_from(bytes).map_err(serde::de::Error::custom) Ok(SigningKey::from(bytes))
} }
} }