pub struct FieldElement {
limbs: [u64; 4],
curve: Curve,
}Expand description
A 256-bit prime field element stored as four little-endian 64-bit limbs.
Fields§
§limbs: [u64; 4]§curve: CurveImplementations§
Source§impl FieldElement
impl FieldElement
Sourcepub fn from_limbs(limbs: [u64; 4], curve: Curve) -> Result<Self, Error>
pub fn from_limbs(limbs: [u64; 4], curve: Curve) -> Result<Self, Error>
Constructs a field element from little-endian limbs.
§Errors
Returns Error::OutOfRange if the value is not less than the modulus.
Sourcepub fn from_u64(val: u64, curve: Curve) -> Self
pub fn from_u64(val: u64, curve: Curve) -> Self
Constructs a field element from a single u64, placed in the
lowest limb.
Sourcepub fn pow(self, exp: &[u64; 4], num_bits: usize) -> Self
pub fn pow(self, exp: &[u64; 4], num_bits: usize) -> Self
Modular exponentiation via square-and-multiply.
The exponent is given as little-endian limbs with num_bits
significant bits.
Sourcepub fn fifth_root(self) -> Self
pub fn fifth_root(self) -> Self
Computes the fifth root: self^((4p-3)/5) mod p.
Trait Implementations§
Source§impl Add for FieldElement
impl Add for FieldElement
Source§impl Clone for FieldElement
impl Clone for FieldElement
Source§fn clone(&self) -> FieldElement
fn clone(&self) -> FieldElement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FieldElement
impl Debug for FieldElement
Source§impl Hash for FieldElement
impl Hash for FieldElement
Source§impl Mul for FieldElement
impl Mul for FieldElement
Source§impl PartialEq for FieldElement
impl PartialEq for FieldElement
Source§impl Sub for FieldElement
impl Sub for FieldElement
impl Copy for FieldElement
impl Eq for FieldElement
impl StructuralPartialEq for FieldElement
Auto Trait Implementations§
impl Freeze for FieldElement
impl RefUnwindSafe for FieldElement
impl Send for FieldElement
impl Sync for FieldElement
impl Unpin for FieldElement
impl UnsafeUnpin for FieldElement
impl UnwindSafe for FieldElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more