clearmatics / libff

C++ library for Finite Fields and Elliptic Curves (forked from scipr-lab/libff)

Home Page:https://clearmatics.github.io/libff/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate strange serialization issue with `Fp2`

dtebbs opened this issue · comments

I hit a very strange problem in clearmatics/zeth#67 where some tests related to serialization could fail on some platforms (linux travis build failed, whereas mac ran fine).

After investigating, it turned out that disabling certain calls to operator<<(std::ostream &, const Fp2 &v) allowed the tests to pass. Removing the SEPARATOR serialization fixed all the test errors. I'm unusure exactly what is going on here and even after trying many combinations of things I didn't get a satisfactory reproducible (the best experiment I was able to do was enabling / disabling the use of << when printing out the hex representation of the Fp2 elements. So, given that the separator is defined as the empty string, but my best guess is that this is related to text/binary stream differences across stl implementations.

For now #2 seems to be a valid fix, but this issue is intended as a reminder to go back and investigate the original cause and be sure there is no hidden bug.

Closing this now. It was related to a bug in client code, where libff was configured with one set of parameters, and client code included libff headers with conflicting #defines (two confcliting version of certain functions were generated, and the linker chose which version to be used, so seemingly unrelated changes caused the issue to appear / disappear).