1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::errors::CommitmentError;
use snarkvm_utilities::{
bytes::{FromBytes, ToBytes},
rand::UniformRand,
};
use rand::Rng;
use std::{fmt::Debug, hash::Hash};
pub trait CommitmentScheme: Sized + Clone + From<<Self as CommitmentScheme>::Parameters> {
type Output: Clone + Debug + Default + Eq + Hash + ToBytes + FromBytes + Sync + Send;
type Parameters: Clone + Debug + Eq + ToBytes + FromBytes;
type Randomness: Clone + Debug + Default + Eq + UniformRand + ToBytes + FromBytes;
fn setup<R: Rng>(r: &mut R) -> Self;
fn commit(&self, input: &[u8], randomness: &Self::Randomness) -> Result<Self::Output, CommitmentError>;
fn parameters(&self) -> &Self::Parameters;
}