acir_field

Struct GenericFieldElement

Source
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>

Source

pub fn from_repr(field: F) -> Self

Source

pub fn into_repr(self) -> F

Source

fn fits_in_u128(&self) -> bool

Source

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>

Source§

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

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

This is the number of bits required to represent this specific field element

Source§

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>

Converts the field element to a vector of bytes in little-endian order

Source§

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>

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>

Returns the closest number of bytes to the bits specified This method truncates

Source§

fn one() -> FieldElement<F>

Source§

fn zero() -> FieldElement<F>

Source§

fn is_zero(&self) -> bool

Source§

fn is_one(&self) -> bool

Source§

fn pow(&self, exponent: &Self) -> Self

Source§

fn modulus() -> BigUint

Source§

fn to_u128(self) -> u128

Source§

fn try_into_u128(self) -> Option<u128>

Source§

fn to_i128(self) -> i128

Source§

fn try_into_i128(self) -> Option<i128>

Source§

fn try_to_u64(&self) -> Option<u64>

Source§

fn try_to_u32(&self) -> Option<u32>

Source§

fn to_hex(self) -> String

Source§

fn from_hex(hex_str: &str) -> Option<FieldElement<F>>

Source§

fn to_be_bytes(self) -> Vec<u8>

Source§

impl<F: PrimeField> Add for FieldElement<F>

Source§

type Output = FieldElement<F>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: FieldElement<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<F: PrimeField> AddAssign for FieldElement<F>

Source§

fn add_assign(&mut self, rhs: FieldElement<F>)

Performs the += operation. Read more
Source§

impl<F: Clone + PrimeField> Clone for FieldElement<F>

Source§

fn clone(&self) -> FieldElement<F>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: PrimeField> Debug for FieldElement<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: Default + PrimeField> Default for FieldElement<F>

Source§

fn default() -> FieldElement<F>

Returns the “default value” for a type. Read more
Source§

impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<F: PrimeField> Display for FieldElement<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: PrimeField> Div for FieldElement<F>

Source§

type Output = FieldElement<F>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FieldElement<F>) -> Self::Output

Performs the / operation. Read more
Source§

impl<F: PrimeField> From<bool> for FieldElement<F>

Source§

fn from(boolean: bool) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<i128> for FieldElement<F>

Source§

fn from(a: i128) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<u128> for FieldElement<F>

Source§

fn from(a: u128) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<u32> for FieldElement<F>

Source§

fn from(a: u32) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<u64> for FieldElement<F>

Source§

fn from(a: u64) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<usize> for FieldElement<F>

Source§

fn from(a: usize) -> FieldElement<F>

Converts to this type from the input type.
Source§

impl<F: Hash + PrimeField> Hash for FieldElement<F>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<F: PrimeField> Mul for FieldElement<F>

Source§

type Output = FieldElement<F>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FieldElement<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<F: PrimeField> Neg for FieldElement<F>

Source§

type Output = FieldElement<F>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<F: Ord + PrimeField> Ord for FieldElement<F>

Source§

fn cmp(&self, other: &FieldElement<F>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<F: PartialEq + PrimeField> PartialEq for FieldElement<F>

Source§

fn eq(&self, other: &FieldElement<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: PartialOrd + PrimeField> PartialOrd for FieldElement<F>

Source§

fn partial_cmp(&self, other: &FieldElement<F>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PrimeField> Serialize for FieldElement<T>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<F: PrimeField> Sub for FieldElement<F>

Source§

type Output = FieldElement<F>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: FieldElement<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<F: PrimeField> SubAssign for FieldElement<F>

Source§

fn sub_assign(&mut self, rhs: FieldElement<F>)

Performs the -= operation. Read more
Source§

impl<F: Copy + PrimeField> Copy for FieldElement<F>

Source§

impl<F: Eq + PrimeField> Eq for FieldElement<F>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,