HarryR / ethsnarks

A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
GNU Lesser General Public License v3.0
240 stars 57 forks source link

Ethsnarks for Windows, and AppVeyor continuous integration #28

Open HarryR opened 6 years ago

HarryR commented 6 years ago

I have setup Windows builds using Appveyor, see: https://ci.appveyor.com/project/harryr/ethsnarks however I don't have a Windows computer (or VM) yet that I can use to test the builds and debug problems with the build system.

CMake supports MSYS, Cygwin and MSVC. Ideally we need to build the following files so they can be used by Windows programs:

It would also be good to verify that the unit tests work on Windows without problems, and possibly the Truffle and Python integration tests too.

Dependencies:

I have started with a skeleton appveyor.yml but AppVeyor can't find the GMP library (CMake, Boost and OpenSSL are being detected without problems).

HarryR commented 6 years ago

Building with msys/mingw might be easier:

However, need to install the GMP and OpenSSL components via msys, or alternatively just build them separately and then link against them statically.

Come to think about it - is it better to do static builds of OpenSSL and GMP?

A very limited subset of OpenSSL / libcrypto functionality is used, and for libmiximus.(dll|dylib|so) no OpenSSL functionality is used at all - only GMP (see nm -D libmiximus.so)

Paths for Appveyor: https://www.appveyor.com/docs/build-environment/

But.. it would be nice to have a single file for build_on_windows.bat or build_on_windows.ps

HarryR commented 5 years ago

I've got it almost building on appveyor using MSYS, but it runs into an error:

[ 22%] Built target ethsnarks_gadgets
src/CMakeFiles/hashpreimage.dir/build.make:86: *** target pattern contains no '%'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:1086: src/CMakeFiles/hashpreimage.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

See: https://ci.appveyor.com/project/harryr/ethsnarks/builds/21534551 for full log

It won't build with MSVC because there's no GMP library, but mingw/msys have one.

Most C++ tests are run via cmake now, and the appveyor.yml file should run the tests after a successful build.

HarryR commented 5 years ago

The previous build error has been fixed, this was due to GMP::gmp-NOTFOUND being used as a target name in a Makefile (even though it's found on OSX and Linux, so have directly referenced the ${GMP_LIBRARY} variable instead of the meta-library).

The project now builds successfully on Windows, see: https://ci.appveyor.com/project/harryr/ethsnarks

However... most if not all of the tests fail for mysterious reasons, and one hangs indefinitely. I think this is related to libff and some mysterious weirdness, e.g.:

Program: C:\projects\ethsnarks\build\src\test\test_subadd.exe File: C:/projects/ethsnarks/depends/libsnark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc, Line 50 Expression: this->pb.lc_val(packed).as_bigint().num_bits() <= bits.size()

Additionally all zkSNARK proofs fail to verify.

It seems something to do with the finite field library using the wrong field prime.

For now, the tests have been disabled. But a full log of the failing tests is available at: https://ci.appveyor.com/project/harryr/ethsnarks/builds/21950411