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::SynthesisError;
 6
 7use r1cs_std::prelude::*;
 8
 9pub trait FixedLengthCRHGadget<H: FixedLengthCRH, ConstraintF: Field>: Sized {
10    type OutputVar: EqGadget<ConstraintF>
11        + ToBytesGadget<ConstraintF>
12        + CondSelectGadget<ConstraintF>
13        + AllocVar<H::Output, ConstraintF>
14        + R1CSVar<ConstraintF>
15        + Debug
16        + Clone
17        + Sized;
18
19    type ParametersVar: AllocVar<H::Parameters, ConstraintF> + Clone;
20
21    fn evaluate(
22        parameters: &Self::ParametersVar,
23        input: &[UInt8<ConstraintF>],
24    ) -> Result<Self::OutputVar, SynthesisError>;
25}