-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I tried to calculate Pedersen hash with circom and circomjs, but the results are different.
This is my circuit:
template PedersenHasher() {
signal input source;
signal output hash;
signal output hash2;
component hasher = Pedersen(248);
component sourceBits = Num2Bits(248);
sourceBits.in <== source;
for (var i = 0; i < 248; i++) {
hasher.in[i] <== sourceBits.out[i];
}
hash <== hasher.out[0];
hash2 <== hasher.out[1];
}
component main = PedersenHasher();
And this is my circomjs code:
const pedersen = await buildPedersenHash();
const source = crypto.randomBytes(31);
const pedersenHash = pedersen.hash(source)
const points = pedersen.babyJub.unpackPoint(pedersenHash)
const { proof, publicSignals } = await groth16.fullProve({ source: ethers.BigNumber.from(source).toString() },
"./build/pedersenHasherTest_js/pedersenHasherTest.wasm", "./build/pedersenHasher_0001.zkey")
If am I right publicSignals[0] should be equal to points[0] and publicSignals[1] should be equal to points[1], but the hashes are different.
Am I doing something wrong, or is it a bug in circomjs?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels