diff --git a/src/air/traces.cairo b/src/air/traces.cairo index 57b8a3789..fcdd5542c 100644 --- a/src/air/traces.cairo +++ b/src/air/traces.cairo @@ -1,5 +1,5 @@ use cairo_verifier::channel::channel::ChannelTrait; -use cairo_verifier::table_commitment::{ +use cairo_verifier::table_commitment::table_commitment::{ TableUnsentCommitment, TableCommitment, TableDecommitment, TableCommitmentWitness, table_commit, table_decommit, }; diff --git a/src/air/traces_config.cairo b/src/air/traces_config.cairo index ea5a0a8b4..fa609a973 100644 --- a/src/air/traces_config.cairo +++ b/src/air/traces_config.cairo @@ -1,5 +1,5 @@ use cairo_verifier::vector_commitment::vector_commitment::VectorCommitmentConfigTrait; -use cairo_verifier::{common::asserts::assert_in_range, table_commitment::TableCommitmentConfig}; +use cairo_verifier::{common::asserts::assert_in_range, table_commitment::table_commitment::TableCommitmentConfig}; const MAX_N_COLUMNS: felt252 = 128; const AIR_LAYOUT_N_ORIGINAL_COLUMNS: felt252 = 12; diff --git a/src/deserialization/fri.cairo b/src/deserialization/fri.cairo index 47e9ad0b5..c019c53bc 100644 --- a/src/deserialization/fri.cairo +++ b/src/deserialization/fri.cairo @@ -1,6 +1,6 @@ use cairo_verifier::{ fri::{fri_config::FriConfig, fri::{FriUnsentCommitment, FriWitness, FriLayerWitness}}, - table_commitment::{TableCommitmentConfig, TableCommitmentWitness, TableUnsentCommitment}, + table_commitment::table_commitment::{TableCommitmentConfig, TableCommitmentWitness, TableUnsentCommitment}, vector_commitment::vector_commitment::{VectorCommitmentConfig, VectorCommitmentWitness}, }; diff --git a/src/deserialization/traces.cairo b/src/deserialization/traces.cairo index 879abb114..a31aff6c7 100644 --- a/src/deserialization/traces.cairo +++ b/src/deserialization/traces.cairo @@ -9,7 +9,7 @@ use cairo_verifier::{ VectorCommitmentWitnessWithSerde } }, - table_commitment::{ + table_commitment::table_commitment::{ TableCommitmentConfig, TableCommitmentWitness, TableDecommitment, TableUnsentCommitment }, }; diff --git a/src/fri/fri.cairo b/src/fri/fri.cairo index 0cabc102f..bb0696978 100644 --- a/src/fri/fri.cairo +++ b/src/fri/fri.cairo @@ -6,7 +6,7 @@ use cairo_verifier::{ fri_layer::{FriLayerQuery, FriLayerComputationParams, compute_next_layer}, fri_last_layer::verify_last_layer, }, - table_commitment::{ + table_commitment::table_commitment::{ TableCommitmentWitness, TableDecommitment, TableCommitment, TableCommitmentConfig, TableUnsentCommitment, table_commit, table_decommit } diff --git a/src/fri/fri_config.cairo b/src/fri/fri_config.cairo index 5ec9146aa..189f3153b 100644 --- a/src/fri/fri_config.cairo +++ b/src/fri/fri_config.cairo @@ -1,6 +1,6 @@ use cairo_verifier::{ common::{asserts::assert_in_range, math::{pow, Felt252PartialOrd}}, - table_commitment::TableCommitmentConfig, + table_commitment::table_commitment::TableCommitmentConfig, vector_commitment::vector_commitment::{VectorCommitmentConfig, VectorCommitmentConfigTrait}, }; diff --git a/src/stark.cairo b/src/stark.cairo index 31766cd94..ba0ee18e2 100644 --- a/src/stark.cairo +++ b/src/stark.cairo @@ -5,7 +5,7 @@ use cairo_verifier::{ }, fri::{fri_config::{FriConfig, FriConfigTrait}, fri::{FriUnsentCommitment, FriWitness}}, domains::StarkDomainsImpl, - table_commitment::{TableCommitmentConfig, TableCommitmentWitness, TableDecommitment}, + table_commitment::table_commitment::{TableCommitmentConfig, TableCommitmentWitness, TableDecommitment}, proof_of_work::{ config::{ProofOfWorkConfig, ProofOfWorkConfigTrait}, proof_of_work::ProofOfWorkUnsentCommitment diff --git a/src/table_commitment.cairo b/src/table_commitment.cairo index 79775baa4..140a6df47 100644 --- a/src/table_commitment.cairo +++ b/src/table_commitment.cairo @@ -1,67 +1,4 @@ -use cairo_verifier::vector_commitment::vector_commitment::{ - VectorCommitmentConfig, VectorCommitment, VectorCommitmentWitness -}; +mod table_commitment; -// Commitment values for a table commitment protocol. Used to generate a commitment by "reading" -// these values from the channel. -#[derive(Drop, Copy)] -struct TableUnsentCommitment { - vector: felt252, -} - -// Commitment for a table (n_rows x n_columns) of field elements in montgomery form. -#[derive(Drop, Copy)] -struct TableCommitment { - config: TableCommitmentConfig, - vector_commitment: VectorCommitment, -} - -#[derive(Drop, Copy)] -struct TableCommitmentConfig { - n_columns: felt252, - vector: VectorCommitmentConfig, -} - -// Responses for queries to the table commitment. -// Each query corresponds to a full row of the table. -#[derive(Drop, Copy)] -struct TableDecommitment { - // n_columns * n_queries values to decommit. - values: Span, -} - -// Witness for a decommitment over queries. -#[derive(Drop, Copy)] -struct TableCommitmentWitness { - vector: VectorCommitmentWitness, -} - -fn table_commit( - unsent_commitment: TableUnsentCommitment, config: TableCommitmentConfig -) -> TableCommitment { - TableCommitment { - config: TableCommitmentConfig { - n_columns: 0, - vector: VectorCommitmentConfig { height: 0, n_verifier_friendly_commitment_layers: 0, } - }, - vector_commitment: VectorCommitment { - config: VectorCommitmentConfig { height: 0, n_verifier_friendly_commitment_layers: 0, }, - commitment_hash: 0 - } - } -} - -// Decommits a TableCommitment at multiple indices. -// rows must be sorted and unique. -// Args: -// commitment - the table commitment. -// n_queries - number of queries to decommit. -// queries - the claimed indices. -// decommitment - the claimed values at those indices. -// witness - the decommitment witness. -fn table_decommit( - commitment: TableCommitment, - queries: Span, - decommitment: TableDecommitment, - witness: TableCommitmentWitness, -) {} +#[cfg(test)] +mod tests; diff --git a/src/table_commitment/table_commitment.cairo b/src/table_commitment/table_commitment.cairo new file mode 100644 index 000000000..823a47501 --- /dev/null +++ b/src/table_commitment/table_commitment.cairo @@ -0,0 +1,68 @@ +use cairo_verifier::vector_commitment::vector_commitment::{ + VectorCommitmentConfig, VectorCommitment, VectorCommitmentWitness +}; + +// Commitment values for a table commitment protocol. Used to generate a commitment by "reading" +// these values from the channel. +#[derive(Drop, Copy)] +struct TableUnsentCommitment { + vector: felt252, +} + +// Commitment for a table (n_rows x n_columns) of field elements in montgomery form. +#[derive(Drop, Copy)] +struct TableCommitment { + config: TableCommitmentConfig, + vector_commitment: VectorCommitment, +} + +#[derive(Drop, Copy)] +struct TableCommitmentConfig { + n_columns: felt252, + vector: VectorCommitmentConfig, +} + +// Responses for queries to the table commitment. +// Each query corresponds to a full row of the table. +#[derive(Drop, Copy)] +struct TableDecommitment { + // n_columns * n_queries values to decommit. + values: Span, +} + +// Witness for a decommitment over queries. +#[derive(Drop, Copy)] +struct TableCommitmentWitness { + vector: VectorCommitmentWitness, +} + +fn table_commit( + unsent_commitment: TableUnsentCommitment, config: TableCommitmentConfig +) -> TableCommitment { + TableCommitment { + config: TableCommitmentConfig { + n_columns: 0, + vector: VectorCommitmentConfig { height: 0, n_verifier_friendly_commitment_layers: 0, } + }, + vector_commitment: VectorCommitment { + config: VectorCommitmentConfig { height: 0, n_verifier_friendly_commitment_layers: 0, }, + commitment_hash: 0 + } + } +} + +// Decommits a TableCommitment at multiple indices. +// rows must be sorted and unique. +// Args: +// commitment - the table commitment. +// n_queries - number of queries to decommit. +// queries - the claimed indices. +// decommitment - the claimed values at those indices. +// witness - the decommitment witness. +fn table_decommit( + commitment: TableCommitment, + queries: Span, + decommitment: TableDecommitment, + witness: TableCommitmentWitness, +) {} + diff --git a/src/table_commitment/tests.cairo b/src/table_commitment/tests.cairo new file mode 100644 index 000000000..954d81e66 --- /dev/null +++ b/src/table_commitment/tests.cairo @@ -0,0 +1 @@ +mod test_table_commitment; diff --git a/src/table_commitment/tests/test_table_commitment.cairo b/src/table_commitment/tests/test_table_commitment.cairo new file mode 100644 index 000000000..e69de29bb