Skip to content

Commit ce98ebc

Browse files
Ensure verifier weights are nonzero (#61)
It's important that verifier weights be nonzero. While this is exceptionally unlikely ever to occur in practice, it's easy and efficient to check. This PR adds a check that all verifier weights are nonzero, and resamples if this isn't the case.
1 parent 12ff2e2 commit ce98ebc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/proof.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,17 @@ impl Proof {
610610
}
611611
}
612612

613-
// Generate weights for this proof's verification equations
614-
let w1 = Scalar::random(&mut transcript_weights_rng);
615-
let w2 = Scalar::random(&mut transcript_weights_rng);
616-
let w3 = Scalar::random(&mut transcript_weights_rng);
617-
let w4 = Scalar::random(&mut transcript_weights_rng);
613+
// Generate nonzero weights for this proof's verification equations
614+
let mut w1 = Scalar::ZERO;
615+
let mut w2 = Scalar::ZERO;
616+
let mut w3 = Scalar::ZERO;
617+
let mut w4 = Scalar::ZERO;
618+
while w1 == Scalar::ZERO || w2 == Scalar::ZERO || w3 == Scalar::ZERO || w4 == Scalar::ZERO {
619+
w1 = Scalar::random(&mut transcript_weights_rng);
620+
w2 = Scalar::random(&mut transcript_weights_rng);
621+
w3 = Scalar::random(&mut transcript_weights_rng);
622+
w4 = Scalar::random(&mut transcript_weights_rng);
623+
}
618624

619625
// Get the challenge for convenience
620626
let xi = xi_powers[1];

0 commit comments

Comments
 (0)