bb.js-created proof fails when checking via the UltraVerifier contract, when circuits has mixed input types, uint and Filed arguments.
Closed this issue · 2 comments
Aim
It took me a while, but I was able to find the most concise examples for this bug. I am using nargo 0.10.3
and @aztec/bb.js: "0.3.6",
and
@noir-lang/acvm_js: "git+https://git@github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42"
Here is a special repo I made to reproduce quickly this exact minimal example : bbjs-bug-minimal-example
It happens when there is at least two inputs with different types, for example : one Field
argument and one u8
argument.
In my repo I use for main.nr
:
use dep::std;
fn main(value: pub u40, C1: pub Field) {
assert(C1 == value as Field);
}
#[test]
fn test_main() {
let C1 : Field = 40;
let value: u40 = 40;
You can check with nargo test
(or via nargo prove && nargo verify
) that the test passes, as expected.
However, if I try to verify, with the contract verifier, the proof generated in my hardhat test via acirCreateProof
I get a proof failure. You can test this with : npx hardhat test
.
This is annoying because we would like to generate proofs in the browser with bb.js
for circuits with a mix of uint
and Field
inputs. I do not know if there is a workaround for this as of now.
Note : I am sure the issue is within bb.js
here, not in the verifier contract, as I checked that the proof generated via nargo prove
was successfully verified by the contract.
Expected Behavior
The hardhat test (i.e verification of the bb.js
proof) should pass.
Bug
When mixing uint with Field types in public inputs of a circuit, the on-chain verification fails, despite nargo prove && nargo verify
passing, as well as the acirVerifyProof
function returning true
.
To Reproduce
Go check the Readme in the repo.
i.e :
Steps to reproduce bug :
-
Have nargo 10.3 installed and clone this repo.
-
Check that offchain verification works :
nargo prove && nargo verify
- Then check that verification of the proof generated via
bb.js
(viaacir.createProof
function) leads to a failed proof when checked with the contract verifier:
npx hardhat test
Environment
nargo 0.10.3 (git version hash: 2db759f43971c57e2f1f8284c82943e31a555d0c, is dirty: false)
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
** Important ** : this test actually passes when producing the verifier contract via Nargo 10.5 instead of 10.3. Very surprising, I thought at first that the problem came from bb.js
but I am not sure anymore.
Thanks @jat9292 for the help and the debugging. Will close this since the problem seems to be resolved