pub struct FieldElement(/* private fields */);
Expand description
A field element in GF(2^283) represented by 5 u64 limbs (320 bits).
Implementations§
Source§impl FieldElement
impl FieldElement
Sourcepub fn from_bytes(bytes: &[u8; 36]) -> Result<Self>
pub fn from_bytes(bytes: &[u8; 36]) -> Result<Self>
Create a field element from its canonical byte representation.
The bytes are interpreted as a big-endian representation of the field element.
Sourcepub fn to_bytes(&self) -> [u8; 36]
pub fn to_bytes(&self) -> [u8; 36]
Convert this field element to its canonical byte representation.
The bytes are a big-endian representation of the field element.
Sourcepub fn add(&self, other: &Self) -> Self
pub fn add(&self, other: &Self) -> Self
Add two field elements in GF(2^283).
In binary fields, addition is performed using XOR.
Sourcepub fn mul(&self, other: &Self) -> Self
pub fn mul(&self, other: &Self) -> Self
Multiply two field elements in GF(2^283).
Uses the irreducible polynomial for reduction.
Sourcepub fn invert(&self) -> Result<Self>
pub fn invert(&self) -> Result<Self>
Compute the multiplicative inverse of a field element.
Uses Fermat’s Little Theorem: a^(2^m - 2) = a^(-1) in GF(2^m). Returns an error if the element is zero.
Trait Implementations§
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 PartialEq for FieldElement
impl PartialEq 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 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