ark-r1cs-std/crypto-primitives/src/commitment/mod.rs
crypto-primitives/src/commitment/mod.rsRaw
1use rand::Rng;
2use algebra::UniformRand;
3use std::{fmt::Debug, hash::Hash};
4
5use algebra::bytes::ToBytes;
6
7pub mod blake2s;
8pub mod injective_map;
9pub mod pedersen;
10
11#[cfg(feature = "r1cs")]
12pub mod constraints;
13#[cfg(feature = "r1cs")]
14pub use constraints::*;
15
16use crate::Error;
17
18pub trait CommitmentScheme {
19 type Output: ToBytes + Clone + Default + Eq + Hash + Debug;
20 type Parameters: Clone;
21 type Randomness: Clone + ToBytes + Default + Eq + UniformRand + Debug;
22
23 fn setup<R: Rng>(r: &mut R) -> Result<Self::Parameters, Error>;
24
25 fn commit(
26 parameters: &Self::Parameters,
27 input: &[u8],
28 r: &Self::Randomness,
29 ) -> Result<Self::Output, Error>;
30}