barustenberg icon indicating copy to clipboard operation
barustenberg copied to clipboard

close #79

Open bmzig opened this issue 1 year ago • 5 comments

Description

All major changes were done in src/plonk/proof_system/commitment_scheme.rs.

  • Implement the tests outlined in #79, namely test_kate_open and kate_batch_open.
  • Fix the locks on line 370

No more progress can be made until transcripts are implemented.

Link to issue

#79

Type of change

  • [x] Bug fix (non-breaking change that fixes an issue)

Test plan (required)

Tests implemented:

  • [ ] test_kate_open
  • [ ] kate_batch_open

The latter of the two tests covers the change in batch_open pertaining to the locks.

Miscellaneous

Per the suggestion, the write locks in batch_open were bypassed by arcs and unsafe code. Arc cloning is cheap and enables concurrent writes to consecutive memory addresses:

(0..input_key.small_domain.size)
    .into_par_iter()
    .for_each(|i| unsafe {
        let mut opening_poly = (opening_poly.clone().coefficients.as_ptr() as *mut Fr).offset(i as isize);
        let mut shifted_opening_poly = (shifted_opening_poly.clone().coefficients.as_ptr() as *mut Fr).offset(i as isize);
        *opening_poly = input_key.quotient_polynomial_parts[0].read().unwrap()[i];
        for &(ref poly, challenge) in &opened_polynomials_at_zeta {
            *opening_poly += (*poly).read().unwrap()[i] * challenge;
        }
        *shifted_opening_poly = Fr::zero();
        for &(ref poly, challenge) in &opened_polynomials_at_zeta_omega {
            *shifted_opening_poly += (*poly).read().unwrap()[i] * challenge;
        }
    });

bmzig avatar Oct 11 '23 01:10 bmzig