franklin_crypto::plonk::circuit::goldilocks

Struct GoldilocksField

Source
pub struct GoldilocksField<E: Engine> { /* private fields */ }

Implementations§

Source§

impl<E: Engine> GoldilocksField<E>

Source

pub const ORDER: u64 = 18_446_744_069_414_584_321u64

Source

pub const ORDER_BITS: usize = 64usize

Source

pub const REMAINDER: u64 = 4_294_967_295u64

Source

pub fn zero() -> Self

Source

pub fn one() -> Self

Source

pub fn minus_one() -> Self

Source

pub fn constant_from_field(value: GL) -> Self

Source

pub fn constant(value: u64) -> Self

Source

pub fn into_u64(self) -> Option<u64>

Source

pub fn into_field(self) -> Option<GL>

Source

pub fn is_constant(&self) -> bool

Source

pub fn alloc<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<E::Fr>, ) -> Result<Self, SynthesisError>

Source

pub fn alloc_from_u64<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<u64>, ) -> Result<Self, SynthesisError>

Source

pub fn alloc_from_field<CS: ConstraintSystem<E>>( cs: &mut CS, witness: Option<GL>, ) -> Result<Self, SynthesisError>

Source

pub unsafe fn from_num_unchecked(num: Num<E>) -> Result<Self, SynthesisError>

Source

pub fn from_num<CS: ConstraintSystem<E>>( cs: &mut CS, num: Num<E>, ) -> Result<Self, SynthesisError>

Source

pub fn into_num(&self) -> Num<E>

Source

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.

Source

pub fn negate<CS: ConstraintSystem<E>>( &self, cs: &mut CS, ) -> Result<Self, SynthesisError>

Source

pub fn add<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<Self, SynthesisError>

Source

pub fn inverse<CS: ConstraintSystem<E>>( &self, cs: &mut CS, ) -> Result<Self, SynthesisError>

Source

pub fn mul<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<Self, SynthesisError>

Source

pub fn mul_add<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, third: &Self, ) -> Result<Self, SynthesisError>

self * other + third

Source

pub fn equals<CS: ConstraintSystem<E>>( cs: &mut CS, this: &Self, other: &Self, ) -> Result<Boolean, SynthesisError>

Source

pub fn enforce_equal<CS: ConstraintSystem<E>>( &self, cs: &mut CS, other: &Self, ) -> Result<(), SynthesisError>

Source

pub fn conditionally_select<CS: ConstraintSystem<E>>( cs: &mut CS, bit: Boolean, first: &Self, second: &Self, ) -> Result<Self, SynthesisError>

Source

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>
where E: Clone + Engine,

Source§

fn clone(&self) -> Self

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<E: Engine> Debug for GoldilocksField<E>

Source§

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

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

impl<E> Default for GoldilocksField<E>
where E: Default + Engine,

Source§

fn default() -> Self

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

impl<E: Engine, CS: ConstraintSystem<E>> From<GoldilocksField<E>> for GoldilocksAsFieldWrapper<E, CS>

Source§

fn from(value: GoldilocksField<E>) -> Self

Converts to this type from the input type.
Source§

impl<E: Engine> Hash for GoldilocksField<E>

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<E> Copy for GoldilocksField<E>
where E: Copy + Engine,

Auto Trait Implementations§

§

impl<E> Freeze for GoldilocksField<E>
where <E as ScalarEngine>::Fr: Freeze,

§

impl<E> RefUnwindSafe for GoldilocksField<E>
where <E as ScalarEngine>::Fr: RefUnwindSafe,

§

impl<E> Send for GoldilocksField<E>

§

impl<E> Sync for GoldilocksField<E>

§

impl<E> Unpin for GoldilocksField<E>
where <E as ScalarEngine>::Fr: Unpin,

§

impl<E> UnwindSafe for GoldilocksField<E>
where <E as ScalarEngine>::Fr: 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
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> PipeOp<T> for T

Source§

fn to<F, U>(self, f: F) -> U
where F: FnOnce(T) -> U,

Source§

fn op<F>(self, f: F) -> T
where F: FnOnce(&mut T),

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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, 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.
Source§

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

Source§

fn vzip(self) -> V