Trait snarkvm_wasm::prelude::GroupGadget [−][src]
pub trait GroupGadget<G, F>: ToBytesGadget<F> + NEqGadget<F> + EqGadget<F> + ToBitsBEGadget<F> + CondSelectGadget<F> + AllocGadget<G, F> + Clone + Debug where
F: Field,
G: Group, { type Value: Debug; type Variable;}Show methods
fn get_value(&self) -> Option<Self::Value>; fn get_variable(&self) -> Self::Variable; fn zero<CS>(cs: CS) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>; fn add<CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>; fn add_constant<CS>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>; fn double_in_place<CS>(&mut self, cs: CS) -> Result<(), SynthesisError>
where
CS: ConstraintSystem<F>; fn negate<CS>(&self, cs: CS) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>; fn cost_of_add() -> usize; fn cost_of_double() -> usize; fn sub<CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>, { ... } fn sub_constant<CS>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>, { ... } fn mul_bits<CS>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>, { ... } fn scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError>
where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>, { ... } fn symmetric_scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError>
where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>, { ... } fn masked_scalar_multiplication<'a, CS, I, B>(
&mut self,
CS,
I,
I
) -> Result<(), SynthesisError>
where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>, { ... } fn three_bit_signed_digit_scalar_multiplication<CS, I, J, K, B>(
CS,
&[B],
K
) -> Result<Self, SynthesisError>
where
B: Borrow<[G]>,
I: Borrow<[Boolean]>,
CS: ConstraintSystem<F>,
J: Iterator<Item = I>,
K: Iterator<Item = J>, { ... } fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError>
where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>, { ... } fn symmetric_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError>
where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>, { ... } fn masked_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I,
mask_bases: &[B],
masks: I
) -> Result<Self, SynthesisError>
where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>, { ... }
Associated Types
Required methods
fn get_variable(&self) -> Self::Variable
fn zero<CS>(cs: CS) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn add<CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn add_constant<CS>(&self, cs: CS, other: &G) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn double_in_place<CS>(&mut self, cs: CS) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>,
fn negate<CS>(&self, cs: CS) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn cost_of_add() -> usize
fn cost_of_double() -> usize
Provided methods
fn sub<CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn sub_constant<CS>(&self, cs: CS, other: &G) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn mul_bits<CS>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
fn mul_bits<CS>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
Inputs must be specified in little-endian form.
If the addition law is incomplete for the identity element,
result
must not be the identity element.
fn scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError> where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>,
fn symmetric_scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError> where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>,
fn masked_scalar_multiplication<'a, CS, I, B>(
&mut self,
CS,
I,
I
) -> Result<(), SynthesisError> where
B: Borrow<Boolean>,
G: 'a,
I: Iterator<Item = (B, &'a G)>,
CS: ConstraintSystem<F>,
fn three_bit_signed_digit_scalar_multiplication<CS, I, J, K, B>(
CS,
&[B],
K
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
I: Borrow<[Boolean]>,
CS: ConstraintSystem<F>,
J: Iterator<Item = I>,
K: Iterator<Item = J>,
fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>,
fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>,
Computes Σⱼ(scalarⱼ * baseⱼ)
for all j,
where scalarⱼ
is a Boolean
representation of the j-th scalar.
fn symmetric_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>,
fn masked_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I,
mask_bases: &[B],
masks: I
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>,
fn masked_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I,
mask_bases: &[B],
masks: I
) -> Result<Self, SynthesisError> where
B: Borrow<[G]>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
CS: ConstraintSystem<F>,
Compute ∏((h_i^{-1} * 1[p_i = 0] + h_i * 1[p_i = 1])^{1 - m_i \xor p_i})((g_i h_i^{-1} * 1[p_i = 0] + g_i^{-1} h_i * 1[p_i = 1])^{m_i \xor p_i}) for all i, m_i being the scalars, p_i being the masks, h_i being the symmetric Pedersen bases and g_i the Pedersen bases.