Primitive type Field
Implementations
impl Field
pub fn assert_max_bit_size<let BIT_SIZE: u32>(self)
pub fn to_le_bits<let N: u32>(self) -> [u1; N]
Decomposes self into its little endian bit decomposition as a [u1; N] array.
This slice will be zero padded should not all bits be necessary to represent self.
Failures
Causes a constraint failure for Field values exceeding 2^N as the resulting slice will not
be able to represent the original Field.
Safety
The bit decomposition returned is canonical and is guaranteed to not overflow the modulus.
pub fn to_be_bits<let N: u32>(self) -> [u1; N]
Decomposes self into its big endian bit decomposition as a [u1; N] array.
This array will be zero padded should not all bits be necessary to represent self.
Failures
Causes a constraint failure for Field values exceeding 2^N as the resulting slice will not
be able to represent the original Field.
Safety
The bit decomposition returned is canonical and is guaranteed to not overflow the modulus.
pub fn to_le_bytes<let N: u32>(self) -> [u8; N]
Decomposes self into its little endian byte decomposition as a [u8;N] array
This array will be zero padded should not all bytes be necessary to represent self.
Failures
The length N of the array must be big enough to contain all the bytes of the 'self', and no more than the number of bytes required to represent the field modulus
Safety
The result is ensured to be the canonical decomposition of the field element
pub fn to_be_bytes<let N: u32>(self) -> [u8; N]
Decomposes self into its big endian byte decomposition as a [u8;N] array of length required to represent the field modulus
This array will be zero padded should not all bytes be necessary to represent self.
Failures
The length N of the array must be big enough to contain all the bytes of the 'self', and no more than the number of bytes required to represent the field modulus
Safety
The result is ensured to be the canonical decomposition of the field element
pub fn pow_32(self, exponent: Self) -> Self
pub fn sgn0(self) -> u1
pub fn lt(self, another: Self) -> bool
pub fn from_le_bytes<let N: u32>(bytes: [u8; N]) -> Self
Convert a little endian byte array to a field element. If the provided byte array overflows the field modulus then the Field will silently wrap around.
pub fn from_be_bytes<let N: u32>(bytes: [u8; N]) -> Self
Convert a big endian byte array to a field element. If the provided byte array overflows the field modulus then the Field will silently wrap around.
Trait implementations
impl Add for Field
pub fn add(self, other: Self) -> Self
impl AsPrimitive<bool> for Field
pub fn as_(self) -> bool
impl AsPrimitive<u128> for Field
pub fn as_(self) -> u128
impl AsPrimitive<u16> for Field
pub fn as_(self) -> u16
impl AsPrimitive<u32> for Field
pub fn as_(self) -> u32
impl AsPrimitive<u64> for Field
pub fn as_(self) -> u64
impl AsPrimitive<u8> for Field
pub fn as_(self) -> u8
impl Default for Field
pub fn default() -> Self
impl Div for Field
pub fn div(self, other: Self) -> Self
impl Eq for Field
pub fn eq(self, other: Self) -> bool
impl From<bool> for Field
pub fn from(value: bool) -> Self
impl From<u128> for Field
pub fn from(value: u128) -> Self
impl From<u16> for Field
pub fn from(value: u16) -> Self
impl From<u32> for Field
pub fn from(value: u32) -> Self
impl From<u64> for Field
pub fn from(value: u64) -> Self
impl From<u8> for Field
pub fn from(value: u8) -> Self
impl Hash for Field
pub fn hash<H>(self, state: &mut H)
where
H: Hasher
impl Mul for Field
pub fn mul(self, other: Self) -> Self
impl Neg for Field
pub fn neg(self) -> Self
impl Sub for Field
pub fn sub(self, other: Self) -> Self
impl WrappingAdd for Field
pub fn wrapping_add(self, y: Self) -> Self
impl WrappingMul for Field
pub fn wrapping_mul(self, y: Self) -> Self
impl WrappingSub for Field
pub fn wrapping_sub(self, y: Self) -> Self
Asserts that
selfcan be represented inbit_sizebits.Failures
Causes a constraint failure for
Fieldvalues exceeding2^{bit_size}.