Sane char_le_bits

This commit is contained in:
Luke Parker 2023-09-12 09:37:48 -04:00
parent 24bdd7ed9b
commit 6f8a5d0ede
No known key found for this signature in database

View file

@ -22,7 +22,7 @@ use subtle::{Choice, CtOption};
pub use curve25519_dalek as dalek; pub use curve25519_dalek as dalek;
use dalek::{ use dalek::{
constants, constants::{self, BASEPOINT_ORDER},
scalar::Scalar as DScalar, scalar::Scalar as DScalar,
edwards::{EdwardsPoint as DEdwardsPoint, EdwardsBasepointTable, CompressedEdwardsY}, edwards::{EdwardsPoint as DEdwardsPoint, EdwardsBasepointTable, CompressedEdwardsY},
ristretto::{RistrettoPoint as DRistrettoPoint, RistrettoBasepointTable, CompressedRistretto}, ristretto::{RistrettoPoint as DRistrettoPoint, RistrettoBasepointTable, CompressedRistretto},
@ -300,10 +300,7 @@ impl PrimeFieldBits for Scalar {
} }
fn char_le_bits() -> FieldBits<Self::ReprBits> { fn char_le_bits() -> FieldBits<Self::ReprBits> {
let mut bytes = (Scalar::ZERO - Scalar::ONE).to_repr(); BASEPOINT_ORDER.to_bytes().into()
bytes[0] += 1;
debug_assert_eq!(DScalar::from_bytes_mod_order(bytes), DScalar::ZERO);
bytes.into()
} }
} }