Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more informative assert messages #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/fri/fri.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down Expand Up @@ -180,7 +181,7 @@ fn fri_verify_layer_step(
fn fri_verify_initial(
queries: Span<felt252>, 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(
Expand All @@ -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'
);

(
Expand Down
6 changes: 4 additions & 2 deletions src/fri/fri_config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/fri/fri_last_layer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn verify_last_layer(mut queries: Span<FriLayerQuery>, coefficients: Span<felt25
assert(
horner_eval::horner_eval(coefficients, 1 / *query.x_inv_value) == *query
.y_value,
'Invalid value'
'FRI/last layer query invalid'
);
},
Option::None => { break; }
Expand Down
8 changes: 5 additions & 3 deletions src/oods.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ fn eval_oods_boundary_poly_at_points(
contract_address: ContractAddress,
) -> Array<felt252> {
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::<felt252>::new();
Expand Down
Loading