arnaucube
arnaucube/ark-r1cs-stdPublic Self-hosted repository
ark-r1cs-std/crypto-primitives/src/commitment/constraints.rs
crypto-primitives/src/commitment/constraints.rsRaw
 1use crate::commitment::CommitmentScheme;
 2use algebra_core::Field;
 3use core::fmt::Debug;
 4use r1cs_core::SynthesisError;
 5use r1cs_std::prelude::*;
 6
 7pub trait CommitmentGadget<C: CommitmentScheme, ConstraintF: Field> {
 8    type OutputVar: EqGadget<ConstraintF>
 9        + ToBytesGadget<ConstraintF>
10        + AllocVar<C::Output, ConstraintF>
11        + R1CSVar<ConstraintF>
12        + Clone
13        + Sized
14        + Debug;
15    type ParametersVar: AllocVar<C::Parameters, ConstraintF> + Clone;
16    type RandomnessVar: AllocVar<C::Randomness, ConstraintF> + Clone;
17
18    fn commit(
19        parameters: &Self::ParametersVar,
20        input: &[UInt8<ConstraintF>],
21        r: &Self::RandomnessVar,
22    ) -> Result<Self::OutputVar, SynthesisError>;
23}