gnosis / dex-zksnarks

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

hash_transform snark with int128 #4

Closed josojo closed 5 years ago

josojo commented 5 years ago

Finally, it works.

Thanks again for your help.

josojo commented 5 years ago

I needed to move the struct Private variable into the dex_common, otherwise I would get this error during the e2e test:

BUILD SUCCESSFUL Total time: 0 seconds make[2]: Leaving directory `/home/docker/pequin/compiler/frontend' WARNING: --cstdarithtruncate is disabled, so type errors will warn and arithmetic is not ANSI C compliant Compiling hash_transform.c Expanding circuit to file hash_transform.c.ZAATAR.circuit Exception in thread "main" java.lang.RuntimeException: No function definition for readPrivateInput at ccomp.parser_hw.CCompiler.genericFunctionCall(CCompiler.java:1012) at ccomp.parser_hw.CCompiler.getExpr(CCompiler.java:953) at ccomp.parser_hw.CCompiler.addInitializerStatement(CCompiler.java:351) at ccomp.parser_hw.CCompiler.expandStatement(CCompiler.java:619) at ccomp.parser_hw.CCompiler.access$1100(CCompiler.java:109) at ccomp.parser_hw.CCompiler$CMainStatement.toAssignmentStatements(CCompiler.java:486) at SFE.Compiler.BlockStatement.toAssignmentStatements(BlockStatement.java:111) at SFE.Compiler.FunctionBody.toAssignmentStatements(FunctionBody.java:31) at zcc.ZCC.compile(ZCC.java:260) at zcc.ZCC.main(ZCC.java:127)

I don't understand this Do you have any clue why? @fleupold

fleupold commented 5 years ago

It's because the method readPrivateInput uses the Private struct, and if dex-common.h is included before Private is defined it cannot find the type. However, we cannot define Private in dex-common.h, because it won't be common for all circuits. The main verification circuit will have a different private input struct than the hash transformation circuit.

Can you try forward declaring the struct in dex-common.h like here: https://stackoverflow.com/questions/9999512/forward-declaration-of-a-struct-in-c?