Skip to content

Commit

Permalink
Make extra sure final byte of s and r is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mstraka100 committed Oct 4, 2024
1 parent 9dfd680 commit 634d7fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/groth16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,15 @@ Prover<Engine>::prove(typename Engine::FrElement* wtns)
E.fr.copy(r, E.fr.zero());
E.fr.copy(s, E.fr.zero());

// FIlling in the last byte here with a non-zero value causes a small amount of proofs to fail,
// Filling in the last byte here with a non-zero value causes a small amount of proofs to fail,
// possibly due to overflowing the field modulus
randombytes_buf((void*)&(r.v[0]), sizeof(r) - 1);
randombytes_buf((void*)&(s.v[0]), sizeof(s) - 1);

// Make extra sure the final byte is 0
reinterpret_cast<char*>(&r)[sizeof(r) - 1] = 0;
reinterpret_cast<char*>(&s)[sizeof(s) - 1] = 0;

# ifndef DONT_USE_FUTURES
pA_future.get();
pB1_future.get();
Expand Down

0 comments on commit 634d7fa

Please sign in to comment.