ZoKrates
ZoKrates copied to clipboard
Compiler crashes if arguments are too large
Description
The compiler crashes during witness computation if (at least) one of the arguments presented is too large.
Environment
- Compiler version: branch
develop
(commitb18ea015
) - Operating system: Manjaro
Steps to Reproduce
def main(u64 x):
return
$ zz compile -i bug.zok
Compiling bug.zok
Compiled code written to 'out'
Number of constraints: 65
$ zz compute-witness -a 340282366920938463426481119284349108225
Computing witness...
Execution failed: Sum check failed
The default ZoKrates interpreter should not yield this error. Please open an issue: expected 18446744073709551615 to equal 340282366920938463426481119284349108225
Hi @m1cm1c, it is expected for this to fail, but the last message should not be displayed like that. We'll have a look into it, thanks!
@dark64 Yes, it makes sense for compilation to fail. However, in my recent call with @Schaeff, he said that you guys are trying to get rid of compiler crashes and want to replace them with user error messages. That's why today I decided to file lots of bug reports about the compiler crashing.
We should have a separate sum check error that we use for arguments and which is not marked malicious.
A similar bug appears in zokrates-js. I run following code in npm RunKit:
var zokratesJs = require("zokrates-js/node")
var zok = await zokratesJs.initialize()
var code = zok.compile(`def main(private u64 original_val) -> u64:
return original_val
`)
var {output} = zok.computeWitness(code, ['50000000000'])
var out = JSON.parse(output)
And, the result given is ["0x00000000a43b7400"]
, which in decimal is 2755359744, and it's not equal to 50000000000, which is less than 2**64. So I belive it's a bug
A similar bug appears in zokrates-js. I run following code in npm RunKit:
var zokratesJs = require("zokrates-js/node") var zok = await zokratesJs.initialize() var code = zok.compile(`def main(private u64 original_val) -> u64: return original_val `) var {output} = zok.computeWitness(code, ['50000000000']) var out = JSON.parse(output)
And, the result given is
["0x00000000a43b7400"]
, which in decimal is 2755359744, and it's not equal to 50000000000, which is less than 2**64. So I belive it's a bug
Ah yes, we are aware of this, the issue is explained here https://github.com/Zokrates/ZoKrates/issues/1096
If it is correct ,I will Iove it from now on