scipr-lab / libsnark

C++ library for zkSNARKs
Other
1.83k stars 585 forks source link

Document and assert() dependencies on CPU word size #17

Open madars opened 9 years ago

madars commented 9 years ago

libsnark makes implicit assertions about the machine word size. For example, TinyRAM with word size W requires 2W-bit native arithmetic and thus test_ram_ppzksnark fails on 32-bit machines. We should document this and have appropriate assertions in place.

tromer commented 9 years ago

Further details for reproducibility and for the benefit of people googling the error message:

src/zk_proof_systems/ppzksnark/ram_ppzksnark/tests/test_ram_ppzksnark fails at runtime on 32-bit machines, both i686 and ARMv7.

The error is:

test_ram_ppzksnark: src/reductions/r1cs_to_qap/r1cs_to_qap.tcc:216: libsnark::qap_witness<FieldT> libsnark::r1cs_to_qap_witness_map(const libsnark::r1cs_constraint_system<FieldT>&, libsnark::r1cs_primary_input<FieldT>&, libsnark::r1cs_auxiliary_input<FieldT>&, const FieldT&, const FieldT&, const FieldT&) [with FieldT = libsnark::Fp_model<10l, ((const libsnark::bigint<10l>&)(& libsnark::mnt46_modulus_A))>; libsnark::r1cs_primary_input<FieldT> = std::vector<libsnark::Fp_model<10l, ((const libsnark::bigint<10l>&)(& libsnark::mnt46_modulus_A))>, std::allocator<libsnark::Fp_model<10l, ((const libsnark::bigint<10l>&)(& libsnark::mnt46_modulus_A))> > >; libsnark::r1cs_auxiliary_input<FieldT> = std::vector<libsnark::Fp_model<10l, ((const libsnark::bigint<10l>&)(& libsnark::mnt46_modulus_A))>, std::allocator<libsnark::Fp_model<10l, ((const libsnark::bigint<10l>&)(& libsnark::mnt46_modulus_A))> > >]: Assertion `cs.is_satisfied(primary_input, auxiliary_input)' failed.

This is with 32-bit x86 built on as follows, on a 64-bit Fedora 21:

CXXFLAGS='-m32' make STATIC=1 CURVE=MNT4 NO_PROCPS=1 NO_SUPERCOP=1 NO_GTEST=1 src/zk_proof_systems/ppzksnark/ram_ppzksnark/tests/test_ram_ppzksnark

(To run it you need static libraries for everything; the requisite Fedora pacakges are in the README.)

Omitting the '-m32' generates an 64-bit executable that passes verification.