Trait snarkvm_gadgets::traits::curves::group::GroupGadget
source · [−]pub trait GroupGadget<G: Group, F: Field>: Sized + ToBytesGadget<F> + NEqGadget<F> + EqGadget<F> + ToBitsBEGadget<F> + CondSelectGadget<F> + AllocGadget<G, F> + Clone + Debug {
type Value: Debug;
type Variable;
Show 19 methods
fn get_value(&self) -> Option<Self::Value>;
fn get_variable(&self) -> Self::Variable;
fn zero<CS: ConstraintSystem<F>>(cs: CS) -> Result<Self, SynthesisError>;
fn add<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>;
fn add_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError>;
fn double_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS
) -> Result<(), SynthesisError>;
fn negate<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>;
fn cost_of_add() -> usize;
fn cost_of_double() -> usize;
fn sub<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError> { ... }
fn sub_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError> { ... }
fn mul_bits<CS: ConstraintSystem<F>>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError> { ... }
fn scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError>
where
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
{ ... }
fn symmetric_scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError>
where
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
{ ... }
fn masked_scalar_multiplication<'a, CS, I, B>(
&mut self,
_: CS,
_: I,
_: I
) -> Result<(), SynthesisError>
where
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
{ ... }
fn three_bit_signed_digit_scalar_multiplication<CS, I, J, K, B>(
_: CS,
_: &[B],
_: K
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>,
I: Borrow<[Boolean]>,
J: Iterator<Item = I>,
K: Iterator<Item = J>,
B: Borrow<[G]>,
{ ... }
fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
{ ... }
fn symmetric_multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError>
where
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
{ ... }
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
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
{ ... }
}
Associated Types
Required methods
fn get_variable(&self) -> Self::Variable
fn zero<CS: ConstraintSystem<F>>(cs: CS) -> Result<Self, SynthesisError>
fn add<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn add_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError>
fn double_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS
) -> Result<(), SynthesisError>
fn negate<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>
fn cost_of_add() -> usize
fn cost_of_double() -> usize
Provided methods
fn sub<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn sub_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &G
) -> Result<Self, SynthesisError>
fn mul_bits<CS: ConstraintSystem<F>>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError>
fn mul_bits<CS: ConstraintSystem<F>>(
&self,
cs: CS,
result: &Self,
bits: impl Iterator<Item = Boolean>
) -> Result<Self, SynthesisError>
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
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
fn symmetric_scalar_multiplication<'a, CS, I, B>(
&mut self,
cs: CS,
scalar_bits_with_base_powers: I
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
fn masked_scalar_multiplication<'a, CS, I, B>(
&mut self,
_: CS,
_: I,
_: I
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>,
I: Iterator<Item = (B, &'a G)>,
B: Borrow<Boolean>,
G: 'a,
fn three_bit_signed_digit_scalar_multiplication<CS, I, J, K, B>(
_: CS,
_: &[B],
_: K
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
I: Borrow<[Boolean]>,
J: Iterator<Item = I>,
K: Iterator<Item = J>,
B: Borrow<[G]>,
fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
fn multi_scalar_multiplication<'a, CS, T, I, B>(
cs: CS,
bases: &[B],
scalars: I
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
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
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
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
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
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
CS: ConstraintSystem<F>,
T: 'a + ToBitsBEGadget<F> + ?Sized,
I: Iterator<Item = &'a T>,
B: Borrow<[G]>,
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.