gnosis / dex-zksnarks

Code to generate snark proofs for batch auction result validation of the Gnosis d.exchange
46 stars 7 forks source link

Small changes to the way we do unit testing #25

Closed fleupold closed 5 years ago

fleupold commented 5 years ago

A few changes merged into this one small PR (not great, but each one of them would be hard to separate out): 1) We can now print stacktraces when our assert_zero fails. This is helpful to debug, which assertion specifically is failing (e.g. if three hashes are checked, we know immediately which one is wrong). This requires depending on Boost and compiling without optimizations. 2) Remove side-effects of hashfunction implementations in test: Before, calling hashPedersen on the same input twice, would result in different outputs. This is not great for the main snark, since we do multiple pedersenHashes in the same function and want the same data to have the same result. It's still using a dummy iplementation, but at least without sideeffects now. We might later want to implement a proper hash function there. 3) Provide global privateInput: For the hashTransform we just passed 0s as privateInput. In order to write meaningful tests for the main snark we need a way to control our input. I therefore added a global variable that can be assigned from within each test case to provide specific private input. 4) Adding an offset to decomposeBits: This is particularly useful for deserializing balances/prices (#13) , but already for hashPedersen it gets rid of one copy assignment (saving constraints)

fleupold commented 5 years ago

In the cases where we expect an assert to fail, we don't want to print the stack trace. Otherwise our test output would be very verbosely polluted.