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§
type ProverData<M>
type Commitment: Clone + Serialize + DeserializeOwned
type Proof: Clone + Serialize + DeserializeOwned
type Error: Debug
Required Methods§
Sourcefn commit<M: Matrix<T>>(
&self,
inputs: Vec<M>,
) -> (Self::Commitment, Self::ProverData<M>)
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.
Sourcefn open_batch<M: Matrix<T>>(
&self,
index: usize,
prover_data: &Self::ProverData<M>,
) -> BatchOpening<T, Self>
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))
Sourcefn get_matrices<'a, M: Matrix<T>>(
&self,
prover_data: &'a Self::ProverData<M>,
) -> Vec<&'a M>
fn get_matrices<'a, M: Matrix<T>>( &self, prover_data: &'a Self::ProverData<M>, ) -> Vec<&'a M>
Sourcefn verify_batch(
&self,
commit: &Self::Commitment,
dimensions: &[Dimensions],
index: usize,
batch_opening: BatchOpeningRef<'_, T, Self>,
) -> Result<(), Self::Error>
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§
Sourcefn commit_matrix<M: Matrix<T>>(
&self,
input: M,
) -> (Self::Commitment, Self::ProverData<M>)
fn commit_matrix<M: Matrix<T>>( &self, input: M, ) -> (Self::Commitment, Self::ProverData<M>)
Sourcefn commit_vec(
&self,
input: Vec<T>,
) -> (Self::Commitment, Self::ProverData<RowMajorMatrix<T>>)
fn commit_vec( &self, input: Vec<T>, ) -> (Self::Commitment, Self::ProverData<RowMajorMatrix<T>>)
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.
Sourcefn get_matrix_heights<M: Matrix<T>>(
&self,
prover_data: &Self::ProverData<M>,
) -> Vec<usize>
fn get_matrix_heights<M: Matrix<T>>( &self, prover_data: &Self::ProverData<M>, ) -> Vec<usize>
Sourcefn get_max_height<M: Matrix<T>>(
&self,
prover_data: &Self::ProverData<M>,
) -> usize
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.