72 lines
2.0 KiB
Rust
Raw Normal View History

2025-06-24 14:32:49 +02:00
use anyhow::Result;
2025-06-26 12:27:44 +02:00
use crate::byte_data::Params;
2025-06-24 14:32:49 +02:00
pub trait DataMatrix<T>{
type Params;
2025-06-26 12:27:44 +02:00
fn new_random(params: Self::Params) -> Self;
2025-06-24 14:32:49 +02:00
fn update_col(&mut self, c: usize, new_col: &[T]);
fn pretty_print(&self);
}
/// Encoder trait
pub trait Encoder<T>{
2025-06-26 12:27:44 +02:00
type Params;
/// data matrix type to encode
type DataMatrix<U>;
2025-06-24 14:32:49 +02:00
/// encode in place the input data matrix
2025-06-26 12:27:44 +02:00
fn encode(data: &mut Self::DataMatrix<T>) -> Result<()>;
2025-06-24 14:32:49 +02:00
/// encode a single column in place
2025-06-26 12:27:44 +02:00
fn encode_col(data: &mut Self::DataMatrix<T>, c: usize) -> Result<Vec<T>>;
2025-06-24 14:32:49 +02:00
/// reconstruct in place
2025-06-26 12:27:44 +02:00
fn reconstruct(params: Params, matrix_opts: &mut Vec<Option<Vec<T>>>) -> Result<()>;
2025-06-24 14:32:49 +02:00
}
/// Polynomial Commitment scheme (e.g. KZG) trait
pub trait PolynomialCommitmentScheme{
type Params;
type Field;
type FieldMatrix<F>;
type SRS;
type Commitment;
type Proof;
fn new(_params: Self::Params) -> Self;
fn setup(&self) -> Result<Self::SRS>;
fn commit(&self, _srs: &Self::SRS, _matrix:&Self::FieldMatrix<Self::Field>) -> Result<Self::Commitment>;
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<Self::Proof>;
fn batch_open(
_: &Self::Commitment,
_: &Self::SRS,
_rows: Vec<usize>,
_cols: Vec<usize>,
) -> Result<Vec<Self::Proof>>;
fn verify(
comms: &Self::Commitment,
srs: &Self::SRS,
row: usize,
col: usize,
value: Self::Field,
proof: &Self::Proof,
) -> Result<bool>;
fn batch_verify(
comms: &Self::Commitment,
srs: &Self::SRS,
rows: Vec<usize>,
cols: Vec<usize>,
values: Vec<Self::Field>,
proof: &Vec<Self::Proof>,
) -> Result<bool>;
}