simplify commitmentengine (#149)

This commit is contained in:
Srinath Setty
2023-03-09 14:33:33 -08:00
committed by GitHub
parent 6ba204401f
commit 0e86f9acc3
4 changed files with 24 additions and 52 deletions

View File

@@ -10,24 +10,6 @@ use core::{
};
use serde::{Deserialize, Serialize};
/// This trait defines the behavior of commitment key
#[allow(clippy::len_without_is_empty)]
pub trait CommitmentKeyTrait<G: Group>:
Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>
{
/// Holds the type of the commitment that can be produced
type Commitment;
/// Samples a new commitment key of a specified size
fn new(label: &'static [u8], n: usize) -> Self;
/// Returns the vector length that can be committed
fn len(&self) -> usize;
/// Commits to a vector using the commitment key
fn commit(&self, v: &[G::Scalar]) -> Self::Commitment;
}
/// Defines basic operations on commitments
pub trait CommitmentOps<Rhs = Self, Output = Self>:
Add<Rhs, Output = Output> + AddAssign<Rhs>
@@ -99,11 +81,14 @@ pub trait CommitmentEngineTrait<G: Group>:
Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>
{
/// Holds the type of the commitment key
type CommitmentKey: CommitmentKeyTrait<G, Commitment = Self::Commitment>;
type CommitmentKey: Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>;
/// Holds the type of the commitment
type Commitment: CommitmentTrait<G>;
/// Samples a new commitment key of a specified size
fn setup(label: &'static [u8], n: usize) -> Self::CommitmentKey;
/// Commits to the provided vector using the provided generators
fn commit(ck: &Self::CommitmentKey, v: &[G::Scalar]) -> Self::Commitment;
}