pub struct GenericFieldElement<F: PrimeField>(F);
Expand description
Temporarily exported generic field to aid migration to AcirField
Tuple Fields§
§0: F
Implementations§
Source§impl<F: PrimeField> FieldElement<F>
impl<F: PrimeField> FieldElement<F>
pub fn from_repr(field: F) -> Self
pub fn into_repr(self) -> F
fn fits_in_u128(&self) -> bool
Sourcepub fn try_from_str(input: &str) -> Option<FieldElement<F>>
pub fn try_from_str(input: &str) -> Option<FieldElement<F>>
Returns None, if the string is not a canonical representation of a field element; less than the order or if the hex string is invalid. This method can be used for both hex and decimal representations.
Trait Implementations§
Source§impl<F: PrimeField> AcirField for FieldElement<F>
impl<F: PrimeField> AcirField for FieldElement<F>
Source§fn 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
Source§fn 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.
Source§fn num_bits(&self) -> u32
fn num_bits(&self) -> u32
This is the number of bits required to represent this specific field element
Source§fn inverse(&self) -> FieldElement<F>
fn inverse(&self) -> FieldElement<F>
Computes the inverse or returns zero if the inverse does not exist Before using this FieldElement, please ensure that this behavior is necessary
Source§fn 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
Source§fn from_be_bytes_reduce(bytes: &[u8]) -> FieldElement<F>
fn from_be_bytes_reduce(bytes: &[u8]) -> FieldElement<F>
Converts bytes into a FieldElement and applies a reduction if needed.
Source§fn from_le_bytes_reduce(bytes: &[u8]) -> FieldElement<F>
fn from_le_bytes_reduce(bytes: &[u8]) -> FieldElement<F>
Converts bytes in little-endian order into a FieldElement and applies a reduction if needed.
Source§fn 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
fn one() -> FieldElement<F>
fn zero() -> FieldElement<F>
fn is_zero(&self) -> bool
fn is_one(&self) -> bool
fn pow(&self, exponent: &Self) -> Self
fn modulus() -> BigUint
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 to_hex(self) -> String
fn from_hex(hex_str: &str) -> Option<FieldElement<F>>
fn to_be_bytes(self) -> Vec<u8>
Source§impl<F: PrimeField> Add for FieldElement<F>
impl<F: PrimeField> Add for FieldElement<F>
Source§type Output = FieldElement<F>
type Output = FieldElement<F>
+
operator.Source§impl<F: PrimeField> AddAssign for FieldElement<F>
impl<F: PrimeField> AddAssign for FieldElement<F>
Source§fn add_assign(&mut self, rhs: FieldElement<F>)
fn add_assign(&mut self, rhs: FieldElement<F>)
+=
operation. Read moreSource§impl<F: Clone + PrimeField> Clone for FieldElement<F>
impl<F: Clone + PrimeField> Clone for FieldElement<F>
Source§fn clone(&self) -> FieldElement<F>
fn clone(&self) -> FieldElement<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<F: PrimeField> Debug for FieldElement<F>
impl<F: PrimeField> Debug for FieldElement<F>
Source§impl<F: Default + PrimeField> Default for FieldElement<F>
impl<F: Default + PrimeField> Default for FieldElement<F>
Source§fn default() -> FieldElement<F>
fn default() -> FieldElement<F>
Source§impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T>
impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<F: PrimeField> Display for FieldElement<F>
impl<F: PrimeField> Display for FieldElement<F>
Source§impl<F: PrimeField> Div for FieldElement<F>
impl<F: PrimeField> Div for FieldElement<F>
Source§type Output = FieldElement<F>
type Output = FieldElement<F>
/
operator.Source§impl<F: PrimeField> From<bool> for FieldElement<F>
impl<F: PrimeField> From<bool> for FieldElement<F>
Source§fn from(boolean: bool) -> FieldElement<F>
fn from(boolean: bool) -> FieldElement<F>
Source§impl<F: PrimeField> From<i128> for FieldElement<F>
impl<F: PrimeField> From<i128> for FieldElement<F>
Source§fn from(a: i128) -> FieldElement<F>
fn from(a: i128) -> FieldElement<F>
Source§impl<F: PrimeField> From<u128> for FieldElement<F>
impl<F: PrimeField> From<u128> for FieldElement<F>
Source§fn from(a: u128) -> FieldElement<F>
fn from(a: u128) -> FieldElement<F>
Source§impl<F: PrimeField> From<u32> for FieldElement<F>
impl<F: PrimeField> From<u32> for FieldElement<F>
Source§fn from(a: u32) -> FieldElement<F>
fn from(a: u32) -> FieldElement<F>
Source§impl<F: PrimeField> From<u64> for FieldElement<F>
impl<F: PrimeField> From<u64> for FieldElement<F>
Source§fn from(a: u64) -> FieldElement<F>
fn from(a: u64) -> FieldElement<F>
Source§impl<F: PrimeField> From<usize> for FieldElement<F>
impl<F: PrimeField> From<usize> for FieldElement<F>
Source§fn from(a: usize) -> FieldElement<F>
fn from(a: usize) -> FieldElement<F>
Source§impl<F: Hash + PrimeField> Hash for FieldElement<F>
impl<F: Hash + PrimeField> Hash for FieldElement<F>
Source§impl<F: PrimeField> Mul for FieldElement<F>
impl<F: PrimeField> Mul for FieldElement<F>
Source§type Output = FieldElement<F>
type Output = FieldElement<F>
*
operator.Source§impl<F: PrimeField> Neg for FieldElement<F>
impl<F: PrimeField> Neg for FieldElement<F>
Source§impl<F: Ord + PrimeField> Ord for FieldElement<F>
impl<F: Ord + PrimeField> Ord for FieldElement<F>
Source§fn cmp(&self, other: &FieldElement<F>) -> Ordering
fn cmp(&self, other: &FieldElement<F>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<F: PartialEq + PrimeField> PartialEq for FieldElement<F>
impl<F: PartialEq + PrimeField> PartialEq for FieldElement<F>
Source§impl<F: PartialOrd + PrimeField> PartialOrd for FieldElement<F>
impl<F: PartialOrd + PrimeField> PartialOrd for FieldElement<F>
Source§impl<T: PrimeField> Serialize for FieldElement<T>
impl<T: PrimeField> Serialize for FieldElement<T>
Source§impl<F: PrimeField> Sub for FieldElement<F>
impl<F: PrimeField> Sub for FieldElement<F>
Source§type Output = FieldElement<F>
type Output = FieldElement<F>
-
operator.Source§impl<F: PrimeField> SubAssign for FieldElement<F>
impl<F: PrimeField> SubAssign for FieldElement<F>
Source§fn sub_assign(&mut self, rhs: FieldElement<F>)
fn sub_assign(&mut self, rhs: FieldElement<F>)
-=
operation. Read moreimpl<F: Copy + PrimeField> Copy for FieldElement<F>
impl<F: Eq + PrimeField> Eq for FieldElement<F>
impl<F: PrimeField> StructuralPartialEq for FieldElement<F>
Auto Trait Implementations§
impl<F> Freeze for FieldElement<F>where
F: Freeze,
impl<F> RefUnwindSafe for FieldElement<F>where
F: RefUnwindSafe,
impl<F> Send for FieldElement<F>
impl<F> Sync for FieldElement<F>
impl<F> Unpin for FieldElement<F>where
F: Unpin,
impl<F> UnwindSafe for FieldElement<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more