Struct snarkvm_gadgets::algorithms::crh::pedersen::PedersenCRHGadget
source · [−]pub struct PedersenCRHGadget<G: ProjectiveCurve, F: PrimeField, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> { /* private fields */ }
Trait Implementations
sourceimpl<G: ProjectiveCurve, F: PrimeField, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> AllocGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: ProjectiveCurve, F: PrimeField, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> AllocGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
fn alloc_constant<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>>, CS: ConstraintSystem<F>>(
_cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError>
fn alloc<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>>, CS: ConstraintSystem<F>>(
_cs: CS,
_value_gen: Fn
) -> Result<Self, SynthesisError>
fn alloc_input<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>>, CS: ConstraintSystem<F>>(
_cs: CS,
_value_gen: Fn
) -> Result<Self, SynthesisError>
fn alloc_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
fn alloc_input_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
sourceimpl<F: PrimeField, G: ProjectiveCurve, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> CRHGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<F: PrimeField, G: ProjectiveCurve, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> CRHGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
type OutputGadget = GG
fn check_evaluation_gadget_on_bits<CS: ConstraintSystem<F>>(
&self,
cs: CS,
input: Vec<Boolean>
) -> Result<Self::OutputGadget, SynthesisError>
fn check_evaluation_gadget<CS: ConstraintSystem<F>>(
&self,
cs: CS,
input: Vec<UInt8>
) -> Result<Self::OutputGadget, SynthesisError>
fn check_evaluation_gadget_on_field_elements<CS: ConstraintSystem<F>>(
&self,
cs: CS,
input: Vec<FpGadget<F>>
) -> Result<Self::OutputGadget, SynthesisError>
sourceimpl<G: Clone + ProjectiveCurve, F: Clone + PrimeField, GG: Clone + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Clone for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: Clone + ProjectiveCurve, F: Clone + PrimeField, GG: Clone + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Clone for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
sourcefn clone(&self) -> PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
fn clone(&self) -> PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<G: Debug + ProjectiveCurve, F: Debug + PrimeField, GG: Debug + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Debug for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: Debug + ProjectiveCurve, F: Debug + PrimeField, GG: Debug + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Debug for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
sourceimpl<F: PrimeField, G: ProjectiveCurve, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> MaskedCRHGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<F: PrimeField, G: ProjectiveCurve, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> MaskedCRHGadget<PedersenCRH<G, NUM_WINDOWS, WINDOW_SIZE>, F> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
sourcefn check_evaluation_gadget_masked<CS: ConstraintSystem<F>>(
&self,
cs: CS,
input: Vec<UInt8>,
mask_parameters: &Self::MaskParametersGadget,
mask: Vec<UInt8>
) -> Result<Self::OutputGadget, SynthesisError>
fn check_evaluation_gadget_masked<CS: ConstraintSystem<F>>(
&self,
cs: CS,
input: Vec<UInt8>,
mask_parameters: &Self::MaskParametersGadget,
mask: Vec<UInt8>
) -> Result<Self::OutputGadget, SynthesisError>
Evaluates a masked Pedersen hash on the given input
using the given mask
. The algorithm
is based on the description in https://eprint.iacr.org/2020/190.pdf, which relies on the
homomorphic properties of Pedersen hashes. First, the mask is extended to ensure constant
hardness - for each bit, 0 => 01, 1 => 10. Then, denoting input bits as m_i, mask bits
as p_i and bases as h_i, computes sum of
(g_i * 1[p_i = 0] + g_i^{-1} * 1[p_i = 1])^{m_i \xor p_i} for all i. Finally, the hash of
the mask itself, being sum of h_i^{p_i} for all i, is added to the computed sum. This
algorithm ensures that each bit in the hash is affected by the mask and that the
final hash remains the same as if no mask was used.
type MaskParametersGadget = Self
sourcefn extend_mask<CS: ConstraintSystem<F>>(
_: CS,
mask: &[UInt8]
) -> Result<Vec<UInt8>, SynthesisError>
fn extend_mask<CS: ConstraintSystem<F>>(
_: CS,
mask: &[UInt8]
) -> Result<Vec<UInt8>, SynthesisError>
Extends the mask such that 0 => 01, 1 => 10.
sourceimpl<G: PartialEq + ProjectiveCurve, F: PartialEq + PrimeField, GG: PartialEq + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> PartialEq<PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: PartialEq + ProjectiveCurve, F: PartialEq + PrimeField, GG: PartialEq + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> PartialEq<PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>> for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
sourcefn eq(
&self,
other: &PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
) -> bool
fn eq(
&self,
other: &PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(
&self,
other: &PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
) -> bool
fn ne(
&self,
other: &PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
) -> bool
This method tests for !=
.
impl<G: Eq + ProjectiveCurve, F: Eq + PrimeField, GG: Eq + CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Eq for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: ProjectiveCurve, F: PrimeField, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> StructuralEq for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
impl<G: ProjectiveCurve, F: PrimeField, GG: CurveGadget<G, F>, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> StructuralPartialEq for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE>
Auto Trait Implementations
impl<G, F, GG, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> RefUnwindSafe for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE> where
F: RefUnwindSafe,
G: RefUnwindSafe,
GG: RefUnwindSafe,
impl<G, F, GG, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Send for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE> where
GG: Send,
impl<G, F, GG, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Sync for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE> where
GG: Sync,
impl<G, F, GG, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> Unpin for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE> where
F: Unpin,
G: Unpin,
GG: Unpin,
impl<G, F, GG, const NUM_WINDOWS: usize, const WINDOW_SIZE: usize> UnwindSafe for PedersenCRHGadget<G, F, GG, NUM_WINDOWS, WINDOW_SIZE> where
F: UnwindSafe,
G: UnwindSafe,
GG: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more