From dc710155e90429d74439456fd1b21151559415a4 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Wed, 27 Nov 2024 17:07:24 +0000 Subject: [PATCH] Use more informative assert messages --- src/fri/fri.cairo | 9 +++++---- src/fri/fri_config.cairo | 6 ++++-- src/fri/fri_last_layer.cairo | 2 +- src/oods.cairo | 8 +++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/fri/fri.cairo b/src/fri/fri.cairo index 5aa5f616..e8cea69f 100644 --- a/src/fri/fri.cairo +++ b/src/fri/fri.cairo @@ -114,7 +114,7 @@ fn fri_commit_rounds( fn fri_commit( ref channel: Channel, unsent_commitment: FriUnsentCommitment, config: FriConfig ) -> FriCommitment { - assert((*config.fri_step_sizes.at(0)) == 0, 'Invalid value'); + assert((*config.fri_step_sizes.at(0)) == 0, 'FRI/First step size != 0'); assert( unsent_commitment.inner_layers.len().into() == config.n_layers - 1, 'Invalid inner layer commitments' @@ -133,7 +133,8 @@ fn fri_commit( let coefficients = unsent_commitment.last_layer_coefficients; assert( - pow(2, config.log_last_layer_degree_bound) == coefficients.len().into(), 'Invalid value' + pow(2, config.log_last_layer_degree_bound) == coefficients.len().into(), + 'FRI/wrong last layer coeffs len' ); FriCommitment { @@ -180,7 +181,7 @@ fn fri_verify_layer_step( fn fri_verify_initial( queries: Span, commitment: FriCommitment, decommitment: FriDecommitment, ) -> (FriVerificationStateConstant, FriVerificationStateVariable) { - assert(queries.len() == decommitment.values.len(), 'Invalid value'); + assert(queries.len() == decommitment.values.len(), 'FRI/wrong queries len'); // Compute first FRI layer queries. let fri_queries = gather_first_layer_queries( @@ -193,7 +194,7 @@ fn fri_verify_initial( .last_layer_coefficients .len() .into() == pow(2, commitment.config.log_last_layer_degree_bound), - 'Invlid value' + 'FRI/wrong last layer coeffs len' ); ( diff --git a/src/fri/fri_config.cairo b/src/fri/fri_config.cairo index b6207f9d..2a1deeb1 100644 --- a/src/fri/fri_config.cairo +++ b/src/fri/fri_config.cairo @@ -32,7 +32,7 @@ impl FriConfigImpl of FriConfigTrait { assert( *self.log_last_layer_degree_bound <= MAX_LAST_LAYER_LOG_DEGREE_BOUND, 'Value too big' ); - assert(*self.fri_step_sizes[0] == 0, 'Invalid value'); + assert(*self.fri_step_sizes[0] == 0, 'FRI/First step size != 0'); assert( (*self.inner_layers).len().into() == *self.n_layers - 1, 'Invalid inner layer config' ); @@ -52,7 +52,9 @@ impl FriConfigImpl of FriConfigTrait { sum_of_step_sizes += fri_step; assert_in_range(fri_step, 1, MAX_FRI_STEP + 1); - assert(table_commitment.n_columns == pow(2, fri_step), 'Invalid value'); + assert( + table_commitment.n_columns == pow(2, fri_step), 'FRI/wrong table commitment size' + ); table_commitment.vector.validate(log_input_size, n_verifier_friendly_commitment_layers); i += 1; diff --git a/src/fri/fri_last_layer.cairo b/src/fri/fri_last_layer.cairo index 7e47ed0c..4a602695 100644 --- a/src/fri/fri_last_layer.cairo +++ b/src/fri/fri_last_layer.cairo @@ -9,7 +9,7 @@ fn verify_last_layer(mut queries: Span, coefficients: Span { break; } diff --git a/src/oods.cairo b/src/oods.cairo index 1f1b03ec..336aa621 100644 --- a/src/oods.cairo +++ b/src/oods.cairo @@ -86,14 +86,16 @@ fn eval_oods_boundary_poly_at_points( contract_address: ContractAddress, ) -> Array { assert( - decommitment.original.values.len() == points.len() * n_original_columns, 'Invalid value' + decommitment.original.values.len() == points.len() * n_original_columns, + 'OODS/wrong orig values len' ); assert( decommitment.interaction.values.len() == points.len() * n_interaction_columns, - 'Invalid value' + 'OODS/wrong interact values len' ); assert( - composition_decommitment.values.len() == points.len() * CONSTRAINT_DEGREE, 'Invalid value' + composition_decommitment.values.len() == points.len() * CONSTRAINT_DEGREE, + 'OODS/wrong compos values len' ); let mut evaluations = ArrayTrait::::new();