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

Eliminate compute_final_proof #1094

Merged

Conversation

benjaminsavage
Copy link
Collaborator

@danielmasny has pointed out that there is a lot of duplication of logic between compute_proof and compute_final_proof. We could potentially just use one. The caller just needs to be careful to "mask" the "u/v" vectors with randomly distributed points at index 0. By eliminating this method, we do not have any compile time guarantees that it will be used correctly (i.e. the inputs will be masked) but we can follow up with a solution for this later.

Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.99%. Comparing base (8c48156) to head (ab50440).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1094   +/-   ##
=======================================
  Coverage   90.99%   90.99%           
=======================================
  Files         183      183           
  Lines       26028    25973   -55     
=======================================
- Hits        23683    23633   -50     
+ Misses       2345     2340    -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

(
*GenericArray::<Fp31, U4>::from_slice(&vec_u_2[4 * i..4 * i + 4]),
*GenericArray::<Fp31, U4>::from_slice(&vec_v_2[4 * i..4 * i + 4]),
GenericArray::generate(|i| Fp31::try_from(u_chunk[i]).unwrap()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am generally against code repetitions even in tests - it is often useful to read them to understand the API. Perhaps a helper function like this can help

       fn zip_chunks<F: PrimeField, U: ArrayLength>(a: &[u128], b: &[u128]) -> Vec<(GenericArray<F, U>, GenericArray<F, U>)> {
        zip(a.chunks(U::USIZE), b.chunks(U::USIZE))
            .map(|(u_chunk, v_chunk)| {
                (
                    GenericArray::generate(|i| F::try_from(u_chunk[i]).unwrap()),
                    GenericArray::generate(|i| F::try_from(v_chunk[i]).unwrap()),
                )
            })
            .collect::<Vec<_>>()
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great suggestion @akoshelev - this really makes it cleaner and easier to read!

@benjaminsavage benjaminsavage merged commit d9823f8 into private-attribution:main May 25, 2024
11 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.

None yet

2 participants