arnaucube
arnaucube/ark-r1cs-stdPublic Self-hosted repository
ark-r1cs-std/crypto-primitives/src/crh/constraints.rs
crypto-primitives/src/crh/constraints.rsRaw
 1use algebra_core::Field;
 2use core::fmt::Debug;
 3
 4use crate::crh::FixedLengthCRH;
 5use r1cs_core::{ConstraintSystem, SynthesisError};
 6
 7use r1cs_std::prelude::*;
 8
 9pub trait FixedLengthCRHGadget<H: FixedLengthCRH, ConstraintF: Field>: Sized {
10    type OutputGadget: ConditionalEqGadget<ConstraintF>
11        + EqGadget<ConstraintF>
12        + ToBytesGadget<ConstraintF>
13        + CondSelectGadget<ConstraintF>
14        + AllocGadget<H::Output, ConstraintF>
15        + Debug
16        + Clone
17        + Sized;
18    type ParametersGadget: AllocGadget<H::Parameters, ConstraintF> + Clone;
19
20    fn check_evaluation_gadget<CS: ConstraintSystem<ConstraintF>>(
21        cs: CS,
22        parameters: &Self::ParametersGadget,
23        input: &[UInt8],
24    ) -> Result<Self::OutputGadget, SynthesisError>;
25}