diff --git a/curve25519-dalek/src/scalar.rs b/curve25519-dalek/src/scalar.rs index 6afd74eef..9d78e90d6 100644 --- a/curve25519-dalek/src/scalar.rs +++ b/curve25519-dalek/src/scalar.rs @@ -1362,7 +1362,17 @@ fn read_le_u64_into(src: &[u8], dst: &mut [u64]) { ); } } +// Implementing the Reduce trait for curve25519_dalek::Scalar +impl Reduce for Scalar { + fn reduce(value: U256) -> Self { + Self::from_bytes_mod_order(value.to_bytes()) + } +} +impl Reduce for Scalar { + fn reduce(value: U512) -> Self { + Self::from_bytes_mod_order_wide(value.to_bytes()) + /// _Clamps_ the given little-endian representation of a 32-byte integer. Clamping the value puts /// it in the range: /// diff --git a/curve25519-dalek/src/traits.rs b/curve25519-dalek/src/traits.rs index ea7ca3be7..98df01d97 100644 --- a/curve25519-dalek/src/traits.rs +++ b/curve25519-dalek/src/traits.rs @@ -421,3 +421,9 @@ pub(crate) trait ValidityCheck { /// Checks whether the point is on the curve. Not CT. fn is_valid(&self) -> bool; } + +// Reduce trait + +pub trait Reduce{ + fn reduce(value:T) -> Self +} \ No newline at end of file