ark-r1cs-std/crypto-primitives/src/commitment/constraints.rs
crypto-primitives/src/commitment/constraints.rsRaw
1use crate::CommitmentScheme;
2use algebra::Field;
3use r1cs_core::{ConstraintSystem, SynthesisError};
4use r1cs_std::prelude::*;
5use std::fmt::Debug;
6
7pub trait CommitmentGadget<C: CommitmentScheme, ConstraintF: Field> {
8 type OutputGadget: EqGadget<ConstraintF>
9 + ToBytesGadget<ConstraintF>
10 + AllocGadget<C::Output, ConstraintF>
11 + Clone
12 + Sized
13 + Debug;
14 type ParametersGadget: AllocGadget<C::Parameters, ConstraintF> + Clone;
15 type RandomnessGadget: AllocGadget<C::Randomness, ConstraintF> + Clone;
16
17 fn check_commitment_gadget<CS: ConstraintSystem<ConstraintF>>(
18 cs: CS,
19 parameters: &Self::ParametersGadget,
20 input: &[UInt8],
21 r: &Self::RandomnessGadget,
22 ) -> Result<Self::OutputGadget, SynthesisError>;
23}