use anyhow::Result; use crate::byte_data::Params; pub trait DataMatrix{ type Params; fn new_random(params: Self::Params) -> Self; fn get(&self, r: usize, c: usize) -> Result; fn get_row(&self, r: usize) -> Result>; fn get_col(&self, c: usize) -> Result>; fn set(&mut self, r: usize, c: usize, elem: T) -> Result<()>; fn update_col(&mut self, c: usize, new_col: &[T]) -> Result<()>; fn pretty_print(&self); } /// Encoder trait pub trait Encoder{ type Params; /// data matrix type to encode type DataMatrix; /// encode in place the input data matrix fn encode(data: &mut Self::DataMatrix) -> Result<()>; /// encode a single column in place fn encode_col(data: &mut Self::DataMatrix, c: usize) -> Result<()>; /// reconstruct in place fn reconstruct(params: Params, matrix_opts: &mut Vec>>) -> Result<()>; } /// Polynomial Commitment scheme (e.g. KZG) trait pub trait PolynomialCommitmentScheme{ type Params; type Field; type FieldMatrix; type SRS; type Commitment; type Proof; fn new(_params: Self::Params) -> Self; fn setup(&self) -> Result; fn commit(&self, _srs: &Self::SRS, _matrix:&Self::FieldMatrix) -> Result; fn update_commitments( srs: &Self::SRS, comm: &mut Self::Commitment, row_idx: usize, old_row: &[Self::Field], new_row: &[Self::Field], ) -> Result<()>; fn open( _: &Self::Commitment, _: &Self::SRS, _row: usize, _col: usize, ) -> Result; fn batch_open( _: &Self::Commitment, _: &Self::SRS, _rows: Vec, _cols: Vec, ) -> Result>; fn verify( comms: &Self::Commitment, srs: &Self::SRS, row: usize, col: usize, value: Self::Field, proof: &Self::Proof, ) -> Result; fn batch_verify( comms: &Self::Commitment, srs: &Self::SRS, rows: Vec, cols: Vec, values: Vec, proof: &Vec, ) -> Result; }