Struct o1_utils::foreign_field::ForeignElement
source · pub struct ForeignElement<F: Field, const B: usize, const N: usize> {
pub limbs: [F; N],
/* private fields */
}
Expand description
Represents a foreign field element Represents a foreign field element
Fields§
§limbs: [F; N]
limbs in little endian order
Implementations§
source§impl<F: Field, const B: usize, const N: usize> ForeignElement<F, B, N>
impl<F: Field, const B: usize, const N: usize> ForeignElement<F, B, N>
sourcepub fn new(limbs: [F; N]) -> Self
pub fn new(limbs: [F; N]) -> Self
Creates a new foreign element from an array containing N limbs
sourcepub fn from_biguint(big: BigUint) -> Self
pub fn from_biguint(big: BigUint) -> Self
Initializes a new foreign element from a big unsigned integer
Panics if the BigUint is too large to fit in the N
limbs
sourcepub fn neg(&self, modulus: &BigUint) -> Self
pub fn neg(&self, modulus: &BigUint) -> Self
Initializes a new foreign element from an absolute BigUint
but the equivalent
foreign element obtained corresponds to the negated input. It first converts the
input big element to a big integer modulo the foreign field modulus, and then
computes the negation of the result.
sourcepub fn from_be(bytes: &[u8]) -> Self
pub fn from_be(bytes: &[u8]) -> Self
Initializes a new foreign element from a set of bytes in big endian
sourcepub fn to_biguint(&self) -> BigUint
pub fn to_biguint(&self) -> BigUint
Obtains the big integer representation of the foreign field element
source§impl<F: PrimeField, const B: usize, const N: usize> ForeignElement<F, B, N>
impl<F: PrimeField, const B: usize, const N: usize> ForeignElement<F, B, N>
sourcepub fn from_field(field: F) -> Self
pub fn from_field(field: F) -> Self
Initializes a new foreign element from an element in the native field
Trait Implementations§
source§impl<F: Clone + Field, const B: usize, const N: usize> Clone for ForeignElement<F, B, N>
impl<F: Clone + Field, const B: usize, const N: usize> Clone for ForeignElement<F, B, N>
source§fn clone(&self) -> ForeignElement<F, B, N>
fn clone(&self) -> ForeignElement<F, B, N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<F: Field, const B: usize, const N: usize> ForeignFieldHelpers<F, B> for ForeignElement<F, B, N>
impl<F: Field, const B: usize, const N: usize> ForeignFieldHelpers<F, B> for ForeignElement<F, B, N>
source§fn two_to_limb() -> F
fn two_to_limb() -> F
source§fn two_to_2limb() -> F
fn two_to_2limb() -> F
source§fn two_to_3limb() -> F
fn two_to_3limb() -> F
source§impl<F: PartialEq + Field, const B: usize, const N: usize> PartialEq<ForeignElement<F, B, N>> for ForeignElement<F, B, N>
impl<F: PartialEq + Field, const B: usize, const N: usize> PartialEq<ForeignElement<F, B, N>> for ForeignElement<F, B, N>
source§fn eq(&self, other: &ForeignElement<F, B, N>) -> bool
fn eq(&self, other: &ForeignElement<F, B, N>) -> bool
self
and other
values to be equal, and is used
by ==
.