pub trait AcirField:
Sized
+ Display
+ Debug
+ Default
+ Clone
+ Copy
+ Neg<Output = Self>
+ Add<Self, Output = Self>
+ Sub<Self, Output = Self>
+ Mul<Self, Output = Self>
+ Div<Self, Output = Self>
+ AddAssign<Self>
+ SubAssign<Self>
+ PartialOrd
+ From<usize>
+ From<u128>
+ From<u32>
+ From<bool>
+ Hash
+ Eq
+ 'static {
Show 23 methods
// Required methods
fn one() -> Self;
fn zero() -> Self;
fn is_zero(&self) -> bool;
fn is_one(&self) -> bool;
fn pow(&self, exponent: &Self) -> Self;
fn max_num_bits() -> u32;
fn max_num_bytes() -> u32;
fn modulus() -> BigUint;
fn num_bits(&self) -> u32;
fn to_u128(self) -> u128;
fn try_into_u128(self) -> Option<u128>;
fn to_i128(self) -> i128;
fn try_into_i128(self) -> Option<i128>;
fn try_to_u64(&self) -> Option<u64>;
fn try_to_u32(&self) -> Option<u32>;
fn inverse(&self) -> Self;
fn to_hex(self) -> String;
fn from_hex(hex_str: &str) -> Option<Self>;
fn to_be_bytes(self) -> Vec<u8>;
fn from_be_bytes_reduce(bytes: &[u8]) -> Self;
fn from_le_bytes_reduce(bytes: &[u8]) -> Self;
fn to_le_bytes(self) -> Vec<u8>;
fn fetch_nearest_bytes(&self, num_bits: usize) -> Vec<u8>;
}
Expand description
This trait is extremely unstable and WILL have breaking changes.
Required Methods§
fn one() -> Self
fn zero() -> Self
fn is_zero(&self) -> bool
fn is_one(&self) -> bool
fn pow(&self, exponent: &Self) -> Self
Sourcefn max_num_bits() -> u32
fn max_num_bits() -> u32
Maximum number of bits needed to represent a field element This is not the amount of bits being used to represent a field element Example, you only need 254 bits to represent a field element in BN256 But the representation uses 256 bits, so the top two bits are always zero This method would return 254
Sourcefn max_num_bytes() -> u32
fn max_num_bytes() -> u32
Maximum numbers of bytes needed to represent a field element We are not guaranteed that the number of bits being used to represent a field element will always be divisible by 8. If the case that it is not, we add one to the max number of bytes For example, a max bit size of 254 would give a max byte size of 32.
fn modulus() -> BigUint
Sourcefn num_bits(&self) -> u32
fn num_bits(&self) -> u32
This is the number of bits required to represent this specific field element
fn to_u128(self) -> u128
fn try_into_u128(self) -> Option<u128>
fn to_i128(self) -> i128
fn try_into_i128(self) -> Option<i128>
fn try_to_u64(&self) -> Option<u64>
fn try_to_u32(&self) -> Option<u32>
Sourcefn inverse(&self) -> Self
fn inverse(&self) -> Self
Computes the inverse or returns zero if the inverse does not exist Before using this FieldElement, please ensure that this behavior is necessary
fn to_hex(self) -> String
fn from_hex(hex_str: &str) -> Option<Self>
fn to_be_bytes(self) -> Vec<u8>
Sourcefn from_be_bytes_reduce(bytes: &[u8]) -> Self
fn from_be_bytes_reduce(bytes: &[u8]) -> Self
Converts bytes into a FieldElement and applies a reduction if needed.
Sourcefn from_le_bytes_reduce(bytes: &[u8]) -> Self
fn from_le_bytes_reduce(bytes: &[u8]) -> Self
Converts bytes in little-endian order into a FieldElement and applies a reduction if needed.
Sourcefn to_le_bytes(self) -> Vec<u8>
fn to_le_bytes(self) -> Vec<u8>
Converts the field element to a vector of bytes in little-endian order
Sourcefn fetch_nearest_bytes(&self, num_bits: usize) -> Vec<u8>
fn fetch_nearest_bytes(&self, num_bits: usize) -> Vec<u8>
Returns the closest number of bytes to the bits specified This method truncates
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.