From 20a720d777b1a3c465f52d0112c02ddc5e6086d8 Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Dec 2023 12:33:33 +0100 Subject: [PATCH] refactor --- src/fri/fri_config.cairo | 10 ++-------- src/structs.cairo | 2 -- src/structs/stark_config.cairo | 2 +- src/structs/table_commitment_config.cairo | 7 ------- src/structs/traces_config.cairo | 2 +- src/structs/vector_commitment_config.cairo | 5 ----- src/table_commitment.cairo | 7 ++++--- src/vector_commitment.cairo | 17 +++++++++++------ 8 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 src/structs/table_commitment_config.cairo delete mode 100644 src/structs/vector_commitment_config.cairo diff --git a/src/fri/fri_config.cairo b/src/fri/fri_config.cairo index a6e942811..4f4fb4e60 100644 --- a/src/fri/fri_config.cairo +++ b/src/fri/fri_config.cairo @@ -2,8 +2,8 @@ use core::array::ArrayTrait; use core::option::OptionTrait; use core::array::SpanTrait; use core::traits::Into; -use cairo_verifier::structs::table_commitment_config::TableCommitmentConfig; -use cairo_verifier::structs::vector_commitment_config::VectorCommitmentConfig; +use cairo_verifier::table_commitment::TableCommitmentConfig; +use cairo_verifier::vector_commitment::{validate_vector_commitment, VectorCommitmentConfig}; const MAX_LAST_LAYER_LOG_DEGREE_BOUND: u32 = 15; const MAX_FRI_LAYERS: u32 = 15; @@ -69,9 +69,3 @@ fn fri_config_validate( log_expected_input_degree } -// ghost functions -fn validate_vector_commitment( - config: VectorCommitmentConfig, - expected_height: felt252, - n_verifier_friendly_commitment_layers: felt252, -) {} diff --git a/src/structs.cairo b/src/structs.cairo index 000d62f6e..b421df63d 100644 --- a/src/structs.cairo +++ b/src/structs.cairo @@ -1,8 +1,6 @@ mod proof_of_work_config; mod stark_config; mod stark_proof; -mod table_commitment_config; mod traces_config; mod unsent_commitment; -mod vector_commitment_config; mod witness; diff --git a/src/structs/stark_config.cairo b/src/structs/stark_config.cairo index 9e960da6b..68cae99dd 100644 --- a/src/structs/stark_config.cairo +++ b/src/structs/stark_config.cairo @@ -1,5 +1,5 @@ use cairo_verifier::structs::traces_config::TracesConfig; -use cairo_verifier::structs::table_commitment_config::TableCommitmentConfig; +use cairo_verifier::table_commitment::TableCommitmentConfig; use cairo_verifier::fri::fri_config::FriConfig; use cairo_verifier::structs::proof_of_work_config::ProofOfWorkConfig; diff --git a/src/structs/table_commitment_config.cairo b/src/structs/table_commitment_config.cairo deleted file mode 100644 index 30238bfed..000000000 --- a/src/structs/table_commitment_config.cairo +++ /dev/null @@ -1,7 +0,0 @@ -use cairo_verifier::structs::vector_commitment_config::VectorCommitmentConfig; - -#[derive(Drop, Copy)] -struct TableCommitmentConfig { - columns: felt252, - vector: VectorCommitmentConfig -} diff --git a/src/structs/traces_config.cairo b/src/structs/traces_config.cairo index f3c741fed..7cbf55fe7 100644 --- a/src/structs/traces_config.cairo +++ b/src/structs/traces_config.cairo @@ -1,4 +1,4 @@ -use cairo_verifier::structs::table_commitment_config::TableCommitmentConfig; +use cairo_verifier::table_commitment::TableCommitmentConfig; struct TracesConfig { original: TableCommitmentConfig, diff --git a/src/structs/vector_commitment_config.cairo b/src/structs/vector_commitment_config.cairo deleted file mode 100644 index b7079ed6a..000000000 --- a/src/structs/vector_commitment_config.cairo +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Drop, Copy)] -struct VectorCommitmentConfig { - height: felt252, - verifier_friendly_commitment_layers: felt252, -} diff --git a/src/table_commitment.cairo b/src/table_commitment.cairo index 58703ed65..2fb6b4a06 100644 --- a/src/table_commitment.cairo +++ b/src/table_commitment.cairo @@ -1,3 +1,5 @@ +use cairo_verifier::vector_commitment::VectorCommitmentConfig; + // Commitment values for a table commitment protocol. Used to generate a commitment by "reading" // these values from the channel. #[derive(Drop, Copy)] @@ -16,9 +18,8 @@ struct TableCommitment { #[derive(Drop, Copy)] struct TableCommitmentConfig { - a: felt252, // dummy -// n_columns: felt, -// vector: VectorCommitmentConfig*, + columns: felt252, + vector: VectorCommitmentConfig } fn table_commit( diff --git a/src/vector_commitment.cairo b/src/vector_commitment.cairo index e4f29a321..485207203 100644 --- a/src/vector_commitment.cairo +++ b/src/vector_commitment.cairo @@ -1,22 +1,27 @@ // Commitment values for a vector commitment. Used to generate a commitment by "reading" these // values from the channel. -#[derive(Drop)] +#[derive(Drop, Copy)] struct VectorUnsentCommitment { a: felt252, // dummy // commitment_hash: ChannelUnsentFelt, } // Commitment for a vector of field elements. -#[derive(Drop)] +#[derive(Drop, Copy)] struct VectorCommitment { a: felt252, // dummy // config: VectorCommitmentConfig*, // commitment_hash: ChannelSentFelt, } -#[derive(Drop)] +#[derive(Drop, Copy)] struct VectorCommitmentConfig { - a: felt252, // dummy -// height: felt, -// n_verifier_friendly_commitment_layers: felt, + height: felt252, + verifier_friendly_commitment_layers: felt252, } + +fn validate_vector_commitment( + config: VectorCommitmentConfig, + expected_height: felt252, + n_verifier_friendly_commitment_layers: felt252, +) {}