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

Factored per-query verification core algorithm #14

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Al-Kindi-0
Copy link
Owner

No description provided.

@Al-Kindi-0 Al-Kindi-0 requested a review from bobbinth August 22, 2022 16:22
Copy link
Collaborator

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good! I left a few comments inline.

I also wonder if we should try to create much more specialized version(s) of this function. When we move it to Miden assembly, to make it as efficient as possible, it would probably make sense to use very concrete parameters and have several versions of the function. For example, there could be the following versions:

  1. Folding factor 2, extension degree 2
  2. Folding factor 2, extension degree 3
  3. Folding factor 4, extension degree 2
  4. etc.

We could start with one of these right now, and then generalize.

Comment on lines 501 to 515
fn iterate_through_query<B, E, H, const N: usize>(
layer_commitments: &Vec<H::Digest>,
folding_roots: &Vec<B>,
layer_alphas: &Vec<E>,
query: &Vec<(Vec<<H>::Digest>, [E; N])>,
position: usize,
num_partitions: usize,
folding_factor: usize,
number_of_layers: usize,
domain_size: usize,
evaluation: &E,
domain_generator: B,
max_degree_plus_1: usize,
domain_offset: B,
) -> Result<(usize, E, usize, usize), VerifierError>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks great! A few comments:

  1. Let's get rid of num_partitions - we can assume that it is always the same (1, I believe).
  2. Instead of passing query as is now, we should pass AdviseProvider struct we've discussed in other places. This struct should provide the following functionality:
    a. get_node function as discussed before.
    b. unhash_node function which given a node value (Digest) returns a set of values which this digest represents (we can probably chat about this).
  3. Do we need to pass max_degree_plus_1 into this function? It seems like it is not relevant to each query - i.e., we could do the check for max_degree_puls_1 in a different function just once, rather than for each query.
  4. Let's assume that domain_offset is hard-coded. So, we can create a constant for it rather than pass it as a parameter.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thank you Bobbin!
I think I have wrapped my mind on what we are trying to achieve.
Now for the implementation, should the AdviceProvider be generic over Digest? I think this is the most straightforward way as the AdviceProvider would need to be constructed inside the unbatch method of VerifierChannel.

Copy link
Owner Author

Choose a reason for hiding this comment

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

  1. Do we need to pass max_degree_plus_1 into this function? It seems like it is not relevant to each query - i.e., we could do the check for max_degree_puls_1 in a different function just once, rather than for each query.

We don't need it if we remove the max_degree_plus_1 % N != 0 test.

Comment on lines 537 to 541
MerkleTree::<H>::verify(layer_commitments[depth], position_index, &query_proof)
.map_err(|_| VerifierError::LayerCommitmentMismatch)?;
num_hash += query_proof.len() - 1;

let query_value = query_values[cur_pos / target_domain_size];
Copy link
Collaborator

@bobbinth bobbinth Aug 22, 2022

Choose a reason for hiding this comment

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

I think this is the part where we'd need to use the AdviceProvider to read the query value from it.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I have now implemented a draft of the ideas we discussed. Let me know what you think.
I have merged the unhashing of the values to a node into the get_node method. I can extracted into a separate method once we agree on the design.
Next step is to implement concrete versions of the verification methods for different folding factors and field extension degrees. I propose that we start with the one we discussed, namely N == 2 & d == 2 .

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.

2 participants