scipr-lab / libsnark

C++ library for zkSNARKs
Other
1.81k stars 579 forks source link

negating without checking if zero #60

Open ebfull opened 7 years ago

ebfull commented 7 years ago

For example:

alt_bn128_G1 alt_bn128_G1::operator-() const
{
    return alt_bn128_G1(this->X, -(this->Y), this->Z);
}

-G1::zero() thus has an invalid jacobian representation. I doubt any code outside of this will be reading Y without running to_affine_coordinates first (which overwrites the invalid Y coordinate) so this probably won't manifest as a bug elsewhere.