Add FieldElement::wide_reduce to dalek-ff-group

This commit is contained in:
Luke Parker
2025-08-19 13:48:54 -04:00
parent f2c13a0040
commit cfd1cb3a37

View File

@@ -223,6 +223,13 @@ impl FieldElement {
FieldElement(Residue::new(u256))
}
/// Create a `FieldElement` from the reduction of a 512-bit number.
///
/// The bytes are interpreted in little-endian format.
pub fn wide_reduce(value: [u8; 64]) -> Self {
FieldElement(reduce(U512::from_le_bytes(value)))
}
/// Interpret the value as a little-endian integer, square it, and reduce it into a FieldElement.
pub fn from_square(value: [u8; 32]) -> FieldElement {
let value = U256::from_le_bytes(value);