How could I successfully construct the correct values of the Merkle root, note hash path, and note commitment that actually works with Merkle-tree-involving stdlib functions and uses in Noir?
1: noir/merkle.nr at 50fcb3cded8cf37403a2dc3839bf99b7df4261b5 · noir-lang/noir · GitHub
2: noir/main.nr at 50fcb3cded8cf37403a2dc3839bf99b7df4261b5 · noir-lang/noir · GitHub
In these tests, merkle roots and relating input values are already written in Prover.toml, but since my goal is to create my own app that involves these values, I’d like to know how to get the correct ones that don’t cause errors with latest nargo versions.
The only thing I found is this repo: simple shield. But those values generated from this repo’s js/ts tests don’t work with the copied circuit codes of the above tests in my nargo environment whose version is 0.6.0. I suppose it’s because that the packages such as @noir-lang/barretenberg are out of date.
Is there any repo that contains working JS/TS or solidity implementation for creating merkle root and producing the input values?
Hello. The JS/TS packages are indeed quite outdated, we’re working on them as we speak so we shouldn’t have to wait much longer.
The simple shield is a good example, but you can find another one in the noir-starter if you check the “ec” branch (not yet merged but it’s a working example).
Just keep in mind that the Pedersen implementation, used in merkle trees, changed between 0.4.1 and 0.5 (ultraplonk). Since the latest JS/TS packages are not up-to-date with ultraplonk, their implementation of Pedersen is still the “old one”. In practice this means you should use 0.4.1 if you’re comparing the merkle trees generated by barretenberg/aztec_backend and those generated/verified by Noir 0.5+.
Again, we’re working on it and soon you’ll be able to create merkle trees in JS/TS using the upcoming new packages, and verify them in-circuit using Noir 0.5+
TL;DR use Noir 0.4.1