private-attribution / ipa

A raw implementation of Interoperable Private Attribution
MIT License
40 stars 23 forks source link

Cleaning up test code #1136

Closed benjaminsavage closed 2 months ago

benjaminsavage commented 2 months ago

I left a few small naming suggestions on #1134. It's easier to just merge that PR and put up a new one with those changes given timezones =).

The tests were also bothering me. I have tried to unify what we are testing with the actual approach we intend to use. Namely:

  1. To use a consistent compression factor for every step, including the final step. Not vary the compression factor for the final recursive step.
  2. For the final proof, to first move element at index 0 to the end of the array, then overwrite index 0 with the mask.

Now that these are unified, we can just test it two ways, manually calling recurse_u_or_v many times, as well as to call recursively_compute_final_check. Now we can just assert these give the same answer.

How did I get the expected numbers? I updated the Google Spreadsheet where I have manually implemented this ZKP protocol: https://docs.google.com/spreadsheets/d/10tCSgiZyQbt4bMB3KqhAUOCfgfO8xIni83J2saipFCg/edit?usp=sharing

I like to see that the numbers match up. It gives me confidence that we did things correctly, since mistakes are likely to be independent in these two wildly different implementations.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 98.38710% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.63%. Comparing base (40bdad2) to head (f30bfe3).

Files Patch % Lines
...rc/protocol/ipa_prf/malicious_security/verifier.rs 98.30% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1136 +/- ## ======================================= Coverage 91.62% 91.63% ======================================= Files 190 190 Lines 27921 27877 -44 ======================================= - Hits 25584 25545 -39 + Misses 2337 2332 -5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.