From 6f8a5d0edeff6a3890b1dfff15c0f9db216bd837 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 12 Sep 2023 09:37:48 -0400 Subject: [PATCH] Sane char_le_bits --- crypto/dalek-ff-group/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crypto/dalek-ff-group/src/lib.rs b/crypto/dalek-ff-group/src/lib.rs index 84bdd67c..a88ef306 100644 --- a/crypto/dalek-ff-group/src/lib.rs +++ b/crypto/dalek-ff-group/src/lib.rs @@ -22,7 +22,7 @@ use subtle::{Choice, CtOption}; pub use curve25519_dalek as dalek; use dalek::{ - constants, + constants::{self, BASEPOINT_ORDER}, scalar::Scalar as DScalar, edwards::{EdwardsPoint as DEdwardsPoint, EdwardsBasepointTable, CompressedEdwardsY}, ristretto::{RistrettoPoint as DRistrettoPoint, RistrettoBasepointTable, CompressedRistretto}, @@ -300,10 +300,7 @@ impl PrimeFieldBits for Scalar { } fn char_le_bits() -> FieldBits { - let mut bytes = (Scalar::ZERO - Scalar::ONE).to_repr(); - bytes[0] += 1; - debug_assert_eq!(DScalar::from_bytes_mod_order(bytes), DScalar::ZERO); - bytes.into() + BASEPOINT_ORDER.to_bytes().into() } }