Trait snarkvm_wasm::traits::algorithms::MaskedCRHGadget[][src]

pub trait MaskedCRHGadget<H, F>: CRHGadget<H, F> where
    H: CRH,
    F: PrimeField
{ pub fn check_evaluation_gadget_masked<CS>(
        cs: CS,
        parameters: &Self::ParametersGadget,
        input: Vec<UInt8, Global>,
        mask_parameters: &Self::ParametersGadget,
        mask: Vec<UInt8, Global>
    ) -> Result<Self::OutputGadget, SynthesisError>
    where
        CS: ConstraintSystem<F>
; pub fn extend_mask<CS>(
        CS,
        mask: &[UInt8]
    ) -> Result<Vec<UInt8, Global>, SynthesisError>
    where
        CS: ConstraintSystem<F>
, { ... } }

Required methods

pub fn check_evaluation_gadget_masked<CS>(
    cs: CS,
    parameters: &Self::ParametersGadget,
    input: Vec<UInt8, Global>,
    mask_parameters: &Self::ParametersGadget,
    mask: Vec<UInt8, Global>
) -> Result<Self::OutputGadget, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

Loading content...

Provided methods

pub fn extend_mask<CS>(
    CS,
    mask: &[UInt8]
) -> Result<Vec<UInt8, Global>, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

Extends the mask such that 0 => 01, 1 => 10.

Loading content...

Implementors

impl<F, G, GG, S> MaskedCRHGadget<PedersenCRH<G, S>, F> for PedersenCRHGadget<G, F, GG> where
    G: Group,
    S: PedersenSize,
    F: PrimeField,
    GG: GroupGadget<G, F>, 
[src]

pub fn check_evaluation_gadget_masked<CS>(
    cs: CS,
    parameters: &<PedersenCRHGadget<G, F, GG> as CRHGadget<PedersenCRH<G, S>, F>>::ParametersGadget,
    input: Vec<UInt8, Global>,
    mask_parameters: &<PedersenCRHGadget<G, F, GG> as CRHGadget<PedersenCRH<G, S>, F>>::ParametersGadget,
    mask: Vec<UInt8, Global>
) -> Result<<PedersenCRHGadget<G, F, GG> as CRHGadget<PedersenCRH<G, S>, F>>::OutputGadget, SynthesisError> where
    CS: ConstraintSystem<F>, 
[src]

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.

impl<F, G, GG, S> MaskedCRHGadget<PedersenCompressedCRH<G, S>, F> for PedersenCompressedCRHGadget<G, F, GG> where
    G: Group + ProjectiveCurve,
    S: PedersenSize,
    F: PrimeField,
    GG: CompressedGroupGadget<G, F>, 
[src]

Loading content...