pub struct GoldilocksField<E: Engine> { /* private fields */ }
Implementations§
Source§impl<E: Engine> GoldilocksField<E>
impl<E: Engine> GoldilocksField<E>
pub const ORDER: u64 = 18_446_744_069_414_584_321u64
pub const ORDER_BITS: usize = 64usize
pub const REMAINDER: u64 = 4_294_967_295u64
pub fn zero() -> Self
pub fn one() -> Self
pub fn minus_one() -> Self
pub fn constant_from_field(value: GL) -> Self
pub fn constant(value: u64) -> Self
pub fn into_u64(self) -> Option<u64>
pub fn into_field(self) -> Option<GL>
pub fn is_constant(&self) -> bool
pub fn alloc<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<E::Fr>, ) -> Result<Self, SynthesisError>
pub fn alloc_from_u64<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<u64>, ) -> Result<Self, SynthesisError>
pub fn alloc_from_field<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<GL>, ) -> Result<Self, SynthesisError>
pub unsafe fn from_num_unchecked(num: Num<E>) -> Result<Self, SynthesisError>
pub fn from_num<CS: ConstraintSystem<E>>( cs: &mut CS, num: Num<E>, ) -> Result<Self, SynthesisError>
pub fn into_num(&self) -> Num<E>
Sourcepub fn from_num_to_multiple_with_reduction<CS: ConstraintSystem<E>, const N: usize>(
cs: &mut CS,
num: Num<E>,
) -> Result<[Self; N], SynthesisError>
pub fn from_num_to_multiple_with_reduction<CS: ConstraintSystem<E>, const N: usize>( cs: &mut CS, num: Num<E>, ) -> Result<[Self; N], SynthesisError>
This function is used in SNARK-wrapper to get Goldilocks challenges from random Bn256 scalar field element. Usually, we use N = 3. Note: we lose some information during this conversion, but it’s OK. We only care about good output distribution.
pub fn negate<CS: ConstraintSystem<E>>( &self, cs: &mut CS, ) -> Result<Self, SynthesisError>
pub fn add<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<Self, SynthesisError>
pub fn inverse<CS: ConstraintSystem<E>>( &self, cs: &mut CS, ) -> Result<Self, SynthesisError>
pub fn mul<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<Self, SynthesisError>
Sourcepub fn mul_add<CS: ConstraintSystem<E>>(
&self,
cs: &mut CS,
other: &Self,
third: &Self,
) -> Result<Self, SynthesisError>
pub fn mul_add<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, third: &Self, ) -> Result<Self, SynthesisError>
self * other + third
pub fn equals<CS: ConstraintSystem<E>>( cs: &mut CS, this: &Self, other: &Self, ) -> Result<Boolean, SynthesisError>
pub fn enforce_equal<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<(), SynthesisError>
pub fn conditionally_select<CS: ConstraintSystem<E>>( cs: &mut CS, bit: Boolean, first: &Self, second: &Self, ) -> Result<Self, SynthesisError>
pub fn spread_into_bits<CS: ConstraintSystem<E>, const LIMIT: usize>( &self, cs: &mut CS, ) -> Result<[Boolean; LIMIT], SynthesisError>
Trait Implementations§
Source§impl<E> Clone for GoldilocksField<E>
impl<E> Clone for GoldilocksField<E>
Source§impl<E: Engine> Debug for GoldilocksField<E>
impl<E: Engine> Debug for GoldilocksField<E>
Source§impl<E> Default for GoldilocksField<E>
impl<E> Default for GoldilocksField<E>
Source§impl<E: Engine, CS: ConstraintSystem<E>> From<GoldilocksField<E>> for GoldilocksAsFieldWrapper<E, CS>
impl<E: Engine, CS: ConstraintSystem<E>> From<GoldilocksField<E>> for GoldilocksAsFieldWrapper<E, CS>
Source§fn from(value: GoldilocksField<E>) -> Self
fn from(value: GoldilocksField<E>) -> Self
Converts to this type from the input type.
Source§impl<E: Engine> Hash for GoldilocksField<E>
impl<E: Engine> Hash for GoldilocksField<E>
impl<E> Copy for GoldilocksField<E>
Auto Trait Implementations§
impl<E> Freeze for GoldilocksField<E>
impl<E> RefUnwindSafe for GoldilocksField<E>
impl<E> Send for GoldilocksField<E>
impl<E> Sync for GoldilocksField<E>
impl<E> Unpin for GoldilocksField<E>
impl<E> UnwindSafe for GoldilocksField<E>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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