diff --git a/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts b/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts index 471c0f776bd..c8d4870039c 100644 --- a/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts +++ b/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts @@ -1,5 +1,4 @@ import { pedersenHash } from '@aztec/foundation/crypto'; -import { Fr } from '@aztec/foundation/fields'; import { MerkleTree } from './merkle_tree.js'; @@ -13,7 +12,7 @@ export class MerkleTreeCalculator { constructor( private height: number, zeroLeaf = Buffer.alloc(32), - hasher = (left: Buffer, right: Buffer) => pedersenHash([Fr.fromBuffer(left), Fr.fromBuffer(right)]).toBuffer(), + hasher = (left: Buffer, right: Buffer) => pedersenHash([left, right]).toBuffer(), ) { this.hasher = hasher; this.zeroHashes = Array.from({ length: height }).reduce( diff --git a/yarn-project/circuits.js/src/merkle/sibling_path.ts b/yarn-project/circuits.js/src/merkle/sibling_path.ts index 4a31d3a7a23..52383dae87c 100644 --- a/yarn-project/circuits.js/src/merkle/sibling_path.ts +++ b/yarn-project/circuits.js/src/merkle/sibling_path.ts @@ -1,12 +1,11 @@ import { pedersenHash } from '@aztec/foundation/crypto'; -import { Fr } from '@aztec/foundation/fields'; /** Computes the expected root of a merkle tree given a leaf and its sibling path. */ export function computeRootFromSiblingPath( leaf: Buffer, siblingPath: Buffer[], index: number, - hasher = (left: Buffer, right: Buffer) => pedersenHash([Fr.fromBuffer(left), Fr.fromBuffer(right)]).toBuffer(), + hasher = (left: Buffer, right: Buffer) => pedersenHash([left, right]).toBuffer(), ) { let result = leaf; for (const sibling of siblingPath) { diff --git a/yarn-project/foundation/src/crypto/pedersen/index.test.ts b/yarn-project/foundation/src/crypto/pedersen/index.test.ts index 5b2f1b435a2..0e9e1c1c92a 100644 --- a/yarn-project/foundation/src/crypto/pedersen/index.test.ts +++ b/yarn-project/foundation/src/crypto/pedersen/index.test.ts @@ -27,12 +27,12 @@ describe('pedersen', () => { }); it('pedersen hash', () => { - const r = pedersenHash([1n, 1n]); + const r = pedersenHash([toBufferBE(1n, 32), toBufferBE(1n, 32)]); expect(r.toString()).toEqual('0x07ebfbf4df29888c6cd6dca13d4bb9d1a923013ddbbcbdc3378ab8845463297b'); }); it('pedersen hash with index', () => { - const r = pedersenHash([1n, 1n], 5); + const r = pedersenHash([toBufferBE(1n, 32), toBufferBE(1n, 32)], 5); expect(r.toString()).toEqual('0x1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6'); });