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

feat: implement decommitment phase of fri verifier #14

Merged
merged 27 commits into from
Sep 30, 2024

Conversation

jaehunkim
Copy link
Contributor

No description provided.

@jaehunkim jaehunkim self-assigned this Sep 7, 2024
@jaehunkim jaehunkim marked this pull request as ready for review September 9, 2024 08:25
@jaehunkim jaehunkim changed the title feat: implement decommitment phase feat: implement decommitment phase of fri verifier Sep 9, 2024
Copy link
Contributor

@rot256 rot256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this code somewhat hard to follow:

There is a lot of functions mutating state on the same large object, lots of values which can be either None/Some which are set/unwrapped inside nested loops, lots of indexing. It's really hard to discern which state is being update by what and which state is relevant to a particular function.

Might even make sense to merge the logic across verify_first_layer(), verify_inner_layers(), verify_last_layer(): currently they are transferring state between these functions via the FriVerifier struct anyway and it does not make sense to invoke one without the other, or even invoke them out-of-order: they are really "one transformation" on the object.

Consider adding some comments to the folding/verifier logic.

It also seems to me that it folds the same layer multiple times.

fri/src/details.rs Show resolved Hide resolved
Comment on lines +37 to +40
let mut cumulative_fri_step = 0;
for i in 0..layer_num {
cumulative_fri_step += params.fri_step_list[i];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let cumulative_fri_step = params.fri_step_list.take(layer_num).sum()

fri/src/details.rs Outdated Show resolved Hide resolved
fri/src/details.rs Show resolved Hide resolved
fri/src/details.rs Show resolved Hide resolved
Comment on lines 184 to 194
if self.query_indices_test.is_some() {
continue;
} else {
assert!(
self.table_verifiers[i]
.verify_decommitment(&mut self.channel, &to_verify)
.unwrap(),
"Layer {} failed decommitment",
i
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really hard for me to follow when something is allowed to be a None/Some in this code.

If you expect things to be Some then consider unwrapping them at the top of the function: so that there is a clear set of preconditions for invoking the function.

Comment on lines 144 to 154
let mut to_verify = if let Some(test_data) = self.to_verify_test.as_ref() {
test_data[i].clone()
} else {
self.table_verifiers[i]
.query(
&mut self.channel,
&layer_data_queries,
&layer_integrity_queries,
)
.unwrap()
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does these two paths correspond to?

query_indices
}

pub fn next_layer_data_and_integrity_queries<F: FftField + PrimeField, E: EvaluationDomain<F>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment explaining what these sets are.

let coset_row = get_table_prover_row(idx >> cumulative_fri_step, layer_fri_step);
for coset_col in 0..(1 << layer_fri_step) {
let query = RowCol::new(coset_row, coset_col);
if !integrity_queries.contains(&query) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can integrity_queries.contains(&query) occur?

}

if self.query_indices_test.is_some() {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "continue" does nothing: there is no logic following the clause.

@jaehunkim jaehunkim changed the base branch from dev-fri-verifier2 to master September 30, 2024 08:36
@jaehunkim jaehunkim merged commit a172365 into master Sep 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants