Skip to main content

CommitmentEngineTrait

Trait CommitmentEngineTrait 

Source
pub trait CommitmentEngineTrait<E: Engine>:
    Clone
    + Send
    + Sync {
    type CommitmentKey: Len + Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>;
    type DerandKey: Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>;
    type Commitment: CommitmentTrait<E>;

Show 13 methods // Required methods fn load_setup( reader: &mut (impl Read + Seek), label: &'static [u8], n: usize, ) -> Result<Self::CommitmentKey, PtauFileError>; fn save_setup( ck: &Self::CommitmentKey, writer: &mut (impl Write + Seek), ) -> Result<(), PtauFileError>; fn setup( label: &'static [u8], n: usize, ) -> Result<Self::CommitmentKey, NovaError>; fn derand_key(ck: &Self::CommitmentKey) -> Self::DerandKey; fn commit( ck: &Self::CommitmentKey, v: &[E::Scalar], r: &E::Scalar, ) -> Self::Commitment; fn commit_sparse_binary( ck: &Self::CommitmentKey, non_zero_indices: &[usize], r: &E::Scalar, ) -> Self::Commitment; fn commit_small<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[T], r: &E::Scalar, ) -> Self::Commitment; fn commit_small_range<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[T], r: &E::Scalar, range: Range<usize>, max_num_bits: usize, ) -> Self::Commitment; fn derandomize( dk: &Self::DerandKey, commit: &Self::Commitment, r: &E::Scalar, ) -> Self::Commitment; fn ck_to_coordinates(ck: &Self::CommitmentKey) -> Vec<(E::Base, E::Base)>; fn ck_to_group_elements(ck: &Self::CommitmentKey) -> Vec<E::GE>; // Provided methods fn batch_commit( ck: &Self::CommitmentKey, v: &[Vec<E::Scalar>], r: &[E::Scalar], ) -> Vec<Self::Commitment> { ... } fn batch_commit_small<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[Vec<T>], r: &[E::Scalar], ) -> Vec<Self::Commitment> { ... }
}
Expand description

A trait that ties different pieces of the commitment generation together

Required Associated Types§

Source

type CommitmentKey: Len + Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>

Holds the type of the commitment key The key should quantify its length in terms of group generators.

Source

type DerandKey: Clone + Debug + Send + Sync + Serialize + for<'de> Deserialize<'de>

Holds the type of the derandomization key

Source

type Commitment: CommitmentTrait<E>

Holds the type of the commitment

Required Methods§

Source

fn load_setup( reader: &mut (impl Read + Seek), label: &'static [u8], n: usize, ) -> Result<Self::CommitmentKey, PtauFileError>

Load keys

Source

fn save_setup( ck: &Self::CommitmentKey, writer: &mut (impl Write + Seek), ) -> Result<(), PtauFileError>

Saves the key to the provided writer.

Source

fn setup( label: &'static [u8], n: usize, ) -> Result<Self::CommitmentKey, NovaError>

Samples a new commitment key of a specified size.

§Errors

Returns an error if the setup cannot be performed (e.g., HyperKZG in production builds without the test-utils feature).

Source

fn derand_key(ck: &Self::CommitmentKey) -> Self::DerandKey

Extracts the blinding generator

Source

fn commit( ck: &Self::CommitmentKey, v: &[E::Scalar], r: &E::Scalar, ) -> Self::Commitment

Commits to the provided vector using the provided generators and random blind

Source

fn commit_sparse_binary( ck: &Self::CommitmentKey, non_zero_indices: &[usize], r: &E::Scalar, ) -> Self::Commitment

Commits to the provided vector of sparse binary scalars using the provided generators and random blind

Source

fn commit_small<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[T], r: &E::Scalar, ) -> Self::Commitment

Commits to the provided vector of “small” scalars (at most 64 bits) using the provided generators and random blind

Source

fn commit_small_range<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[T], r: &E::Scalar, range: Range<usize>, max_num_bits: usize, ) -> Self::Commitment

Commits to the provided vector of “small” scalars (at most 64 bits) using the provided generators and random blind (range)

Source

fn derandomize( dk: &Self::DerandKey, commit: &Self::Commitment, r: &E::Scalar, ) -> Self::Commitment

Remove given blind from commitment

Source

fn ck_to_coordinates(ck: &Self::CommitmentKey) -> Vec<(E::Base, E::Base)>

Returns the coordinates of each generator in the commitment key.

This method extracts the (x, y) coordinates of each generator point in the commitment key. This is useful for operations that need direct access to the underlying elliptic curve points, such as in-circuit verification of polynomial evaluations.

§Panics

Panics if any generator point is the point at infinity.

Source

fn ck_to_group_elements(ck: &Self::CommitmentKey) -> Vec<E::GE>

Returns the generators as projective group elements.

This provides full group-operation access (add, double, scalar mul) on the commitment key generators, useful for precomputing correction points in circuit optimizations.

Provided Methods§

Source

fn batch_commit( ck: &Self::CommitmentKey, v: &[Vec<E::Scalar>], r: &[E::Scalar], ) -> Vec<Self::Commitment>

Batch commits to the provided vectors using the provided generators and random blind

Source

fn batch_commit_small<T: Integer + Into<u64> + Copy + Sync + ToPrimitive>( ck: &Self::CommitmentKey, v: &[Vec<T>], r: &[E::Scalar], ) -> Vec<Self::Commitment>

Batch commits to the provided vectors of “small” scalars (at most 64 bits) using the provided generators and random blind

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§