Trait Mmcs

Source
pub trait Mmcs<T: Send + Sync + Clone>: Clone {
    type ProverData<M>;
    type Commitment: Clone + Serialize + DeserializeOwned;
    type Proof: Clone + Serialize + DeserializeOwned;
    type Error: Debug;

    // Required methods
    fn commit<M: Matrix<T>>(
        &self,
        inputs: Vec<M>,
    ) -> (Self::Commitment, Self::ProverData<M>);
    fn open_batch<M: Matrix<T>>(
        &self,
        index: usize,
        prover_data: &Self::ProverData<M>,
    ) -> BatchOpening<T, Self>;
    fn get_matrices<'a, M: Matrix<T>>(
        &self,
        prover_data: &'a Self::ProverData<M>,
    ) -> Vec<&'a M>;
    fn verify_batch(
        &self,
        commit: &Self::Commitment,
        dimensions: &[Dimensions],
        index: usize,
        batch_opening: BatchOpeningRef<'_, T, Self>,
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn commit_matrix<M: Matrix<T>>(
        &self,
        input: M,
    ) -> (Self::Commitment, Self::ProverData<M>) { ... }
    fn commit_vec(
        &self,
        input: Vec<T>,
    ) -> (Self::Commitment, Self::ProverData<RowMajorMatrix<T>>)
       where T: Clone + Send + Sync { ... }
    fn get_matrix_heights<M: Matrix<T>>(
        &self,
        prover_data: &Self::ProverData<M>,
    ) -> Vec<usize> { ... }
    fn get_max_height<M: Matrix<T>>(
        &self,
        prover_data: &Self::ProverData<M>,
    ) -> usize { ... }
}
Expand description

A “Mixed Matrix Commitment Scheme” (MMCS) is a generalization of a vector commitment scheme.

It supports committing to matrices and then opening rows. It is also batch-oriented; one can commit to a batch of matrices at once even if their widths and heights differ.

When a particular row index is opened, it is interpreted directly as a row index for matrices with the largest height. For matrices with smaller heights, some bits of the row index are removed (from the least-significant side) to get the effective row index. These semantics are useful in the FRI protocol. See the documentation for open_batch for more details.

Required Associated Types§

Required Methods§

Source

fn commit<M: Matrix<T>>( &self, inputs: Vec<M>, ) -> (Self::Commitment, Self::ProverData<M>)

Commits to a batch of matrices at once and returns both the commitment and associated prover data.

Each matrix in the batch may have different dimensions.

§Parameters
  • inputs: A vector of matrices to commit to.
§Returns

A tuple (commitment, prover_data) where:

  • commitment is a compact representation of all matrix elements and will be sent to the verifier.
  • prover_data is auxiliary data used by the prover open the commitment.
Source

fn open_batch<M: Matrix<T>>( &self, index: usize, prover_data: &Self::ProverData<M>, ) -> BatchOpening<T, Self>

Opens a specific row (identified by index) from each matrix in the batch.

This function is designed to support batch opening semantics where matrices may have different heights. The given index is interpreted relative to the maximum matrix height; smaller matrices apply a bit-shift to extract the corresponding row.

§Parameters
  • index: The global row index (relative to max height).
  • prover_data: Prover data returned from [commit] or related methods.
§Returns

A BatchOpening containing the opened rows and the proof of their correctness.

§Opening Index Semantics

For each matrix M[i], the row index used is:

j = index >> (log2_ceil(max_height) - log2_ceil(M[i].height))
Source

fn get_matrices<'a, M: Matrix<T>>( &self, prover_data: &'a Self::ProverData<M>, ) -> Vec<&'a M>

Returns references to all matrices originally committed to in the batch.

This allows access to the underlying data for inspection or additional logic.

§Parameters
  • prover_data: The prover data returned by [commit].
§Returns

A vector of references to the committed matrices.

Source

fn verify_batch( &self, commit: &Self::Commitment, dimensions: &[Dimensions], index: usize, batch_opening: BatchOpeningRef<'_, T, Self>, ) -> Result<(), Self::Error>

Verifies a batch opening at a specific row index against the original commitment.

This is the verifier-side analogue of [open_batch]. The verifier receives:

  • The original commitment.
  • Dimensions of each matrix being opened (in the same order as originally committed).
  • The global index used for opening (interpreted as in [open_batch]).
  • A BatchOpeningRef containing the claimed opened values and the proof.
§Parameters
  • commit: The original commitment.
  • dimensions: Dimensions of the committed matrices, in order.
  • index: The global row index that was opened.
  • batch_opening: A reference to the values and proof to verify.
§Returns

Ok(()) if the opening is valid; otherwise returns a verification error.

Provided Methods§

Source

fn commit_matrix<M: Matrix<T>>( &self, input: M, ) -> (Self::Commitment, Self::ProverData<M>)

Convenience method to commit to a single matrix.

Internally wraps the matrix in a singleton vector and delegates to [commit].

§Parameters
  • input: The matrix to commit to.
§Returns

A tuple (commitment, prover_data) as in [commit].

Source

fn commit_vec( &self, input: Vec<T>, ) -> (Self::Commitment, Self::ProverData<RowMajorMatrix<T>>)
where T: Clone + Send + Sync,

Convenience method to commit to a single column vector, treated as a column matrix.

Automatically wraps the vector into a column matrix using RowMajorMatrix::new_col.

§Parameters
  • input: A vector of field elements representing a single column.
§Returns

A tuple (commitment, prover_data) for the resulting 1-column matrix.

Source

fn get_matrix_heights<M: Matrix<T>>( &self, prover_data: &Self::ProverData<M>, ) -> Vec<usize>

Returns the height (number of rows) of each matrix in the batch.

This is a utility method derived from [get_matrices].

§Parameters
  • prover_data: The prover data returned by [commit].
§Returns

A vector containing the height of each committed matrix.

Source

fn get_max_height<M: Matrix<T>>( &self, prover_data: &Self::ProverData<M>, ) -> usize

Get the largest height of any committed matrix.

§Panics

This may panic if there are no committed matrices.

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§

Source§

impl<F, EF, InnerMmcs> Mmcs<EF> for ExtensionMmcs<F, EF, InnerMmcs>
where F: Field, EF: ExtensionField<F>, InnerMmcs: Mmcs<F>,

Source§

type ProverData<M> = <InnerMmcs as Mmcs<F>>::ProverData<FlatMatrixView<F, EF, M>>

Source§

type Commitment = <InnerMmcs as Mmcs<F>>::Commitment

Source§

type Proof = <InnerMmcs as Mmcs<F>>::Proof

Source§

type Error = <InnerMmcs as Mmcs<F>>::Error