-
Notifications
You must be signed in to change notification settings - Fork 23
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
Eliminate compute_final_proof #1094
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
( | ||
*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()), |
There was a problem hiding this comment.
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<_>>()
}
There was a problem hiding this comment.
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!
@danielmasny has pointed out that there is a lot of duplication of logic between
compute_proof
andcompute_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.