pub struct MontgomeryElement {
standard: FieldElement,
}Expand description
A field element that tracks both standard and Montgomery forms.
Internally stores the standard value. Arithmetic is performed
in standard form for correctness. The Montgomery representation
(aR mod p) is available for hardware comparison.
Fields§
§standard: FieldElementThe standard (non-Montgomery) value.
Implementations§
Source§impl MontgomeryElement
impl MontgomeryElement
Sourcepub fn from_field(a: FieldElement) -> Self
pub fn from_field(a: FieldElement) -> Self
Wraps a standard field element for Montgomery-domain operations.
Sourcepub fn to_field(self) -> FieldElement
pub fn to_field(self) -> FieldElement
Returns the standard (non-Montgomery) field element.
Sourcepub fn to_mont_repr(self) -> FieldElement
pub fn to_mont_repr(self) -> FieldElement
Returns the Montgomery representation aR mod p.
This is what the hardware stores internally.
Sourcepub fn from_mont_repr(mont_repr: FieldElement) -> Self
pub fn from_mont_repr(mont_repr: FieldElement) -> Self
Constructs from a Montgomery representation aR mod p.
Recovers the standard value a by halving 128 times
(each halving computes x * 2^{-1} mod p).
Sourcepub fn fifth_root(self) -> Self
pub fn fifth_root(self) -> Self
Computes the fifth root.
Sourcepub fn from_raw_mont_limbs(limbs: [u64; 4], curve: Curve) -> Result<Self, Error>
pub fn from_raw_mont_limbs(limbs: [u64; 4], curve: Curve) -> Result<Self, Error>
Constructs from raw limbs in Montgomery representation.
The limbs are interpreted as aR mod p and converted to
the standard value internally.
§Errors
Returns Error::OutOfRange if the limbs are not less than the modulus.
Trait Implementations§
Source§impl Clone for MontgomeryElement
impl Clone for MontgomeryElement
Source§fn clone(&self) -> MontgomeryElement
fn clone(&self) -> MontgomeryElement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more