mirror of
https://github.com/arnaucube/Nova.git
synced 2026-01-12 00:51:28 +01:00
simplify commitmentengine (#149)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user