Closed chung080702 closed 1 year ago
The pedersen hash implementation for noir (and bb.js) changed in a recent version. You can see the foundry-voting example was updated here: https://github.com/noir-lang/noir-examples/commit/8472f63ca0f057ebcb60440daf25b22292afb087
@signorecello will update the stealthdrop soon--he's out for a bit. If you'd like to take a shot at updating the example, feel free to open a PR.
@critesjosh The foundary-voting example only has the pedersen hash in noir. I need js library that support the pedersen hash like that. Is there any other hash function in bb.js with the same implementation as in noir?
You can do pedersen hashes with bb.js. You can see how it is done in the tests here.
Call api.pedersenHashInit();
then maybe api.pedersenHashMultiple
I am working on getting the exact function that will do you what you need, but try it out.
hey @chung080702 you should have a correct implementation on the main branch now, thanks for reporting!
Perdersen hash result on the circuit is different from that on the @aztec/bb.js library. I ran your test at stealdrop and got the error that new_root is different from merkle_root. Then I write a simple test to check the perdersen hash of 1 and 2. The result in the circuit is 0x092d73d58bf37ff31acb813bb9b3b8aef71ef86db847bc92e9513bcbd98f7ac7, and the result in the library is 0x1ecc3e451bab2412ce126da45504efbfec396a455045bfec.
Code in circuit:
Code in ts: