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

pub trait MaskedCRHGadget<H, F>: CRHGadget<H, F> where
    H: CRH,
    F: PrimeField
{ 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>
; fn extend_mask<CS>(
        CS,
        mask: &[UInt8]
    ) -> Result<Vec<UInt8, Global>, SynthesisError>
    where
        CS: ConstraintSystem<F>
, { ... } }

Required methods

Provided methods

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

Implementors

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.