Skip to content

Commit

Permalink
Avoid trying to compute pairing of zeros
Browse files Browse the repository at this point in the history
Without this change, an assertion failure happens in libff,
at alt_bn128_pairing.cpp:347

which seems to be very similar to scipr-lab/libsnark#62
  • Loading branch information
pirapira committed May 19, 2017
1 parent e221f3e commit 958a69c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libdevcrypto/LibSnark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ pair<bool, bytes> dev::crypto::alt_bn128_pairing_product(dev::bytesConstRef _in)
if (-libff::alt_bn128_G2::scalar_field::one() * p + p != libff::alt_bn128_G2::zero())
// p is not an element of the group (has wrong order)
return {false, bytes()};
if (p.is_zero())
continue; // the pairing is one
if (decodePointG1(pair).is_zero())
continue; // the pairing is one
x = x * libff::alt_bn128_miller_loop(
libff::alt_bn128_precompute_G1(decodePointG1(pair)),
libff::alt_bn128_precompute_G2(p)
Expand Down

0 comments on commit 958a69c

Please sign in to comment.