diff --git a/yarn-project/accounts/src/defaults/account_entrypoint.ts b/yarn-project/accounts/src/defaults/account_entrypoint.ts index 67b62181dfd..f64db020b70 100644 --- a/yarn-project/accounts/src/defaults/account_entrypoint.ts +++ b/yarn-project/accounts/src/defaults/account_entrypoint.ts @@ -1,6 +1,6 @@ import { AuthWitnessProvider, EntrypointInterface, FeeOptions } from '@aztec/aztec.js/account'; import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; -import { AztecAddress, Fr, FunctionData, GeneratorIndex, TxContext } from '@aztec/circuits.js'; +import { AztecAddress, FunctionData, GeneratorIndex, TxContext } from '@aztec/circuits.js'; import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js'; @@ -25,12 +25,8 @@ export class DefaultAccountEntrypoint implements EntrypointInterface { const abi = this.getEntrypointAbi(); const entrypointPackedArgs = PackedArguments.fromArgs(encodeArguments(abi, [appPayload, feePayload])); - const appAuthWitness = await this.auth.createAuthWitness( - Fr.fromBuffer(hashPayload(appPayload, GeneratorIndex.SIGNATURE_PAYLOAD)), - ); - const feeAuthWitness = await this.auth.createAuthWitness( - Fr.fromBuffer(hashPayload(feePayload, GeneratorIndex.FEE_PAYLOAD)), - ); + const appAuthWitness = await this.auth.createAuthWitness(hashPayload(appPayload, GeneratorIndex.SIGNATURE_PAYLOAD)); + const feeAuthWitness = await this.auth.createAuthWitness(hashPayload(feePayload, GeneratorIndex.FEE_PAYLOAD)); const txRequest = TxExecutionRequest.from({ argsHash: entrypointPackedArgs.hash, diff --git a/yarn-project/aztec.js/src/utils/cheat_codes.ts b/yarn-project/aztec.js/src/utils/cheat_codes.ts index 02ce3e56549..b22aa828bee 100644 --- a/yarn-project/aztec.js/src/utils/cheat_codes.ts +++ b/yarn-project/aztec.js/src/utils/cheat_codes.ts @@ -246,7 +246,7 @@ export class AztecCheatCodes { public computeSlotInMap(baseSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Fr { // Based on `at` function in // aztec3-packages/aztec-nr/aztec/src/state_vars/map.nr - return Fr.fromBuffer(pedersenHash([new Fr(baseSlot), new Fr(key)].map(f => f.toBuffer()))); + return pedersenHash([new Fr(baseSlot), new Fr(key)].map(f => f.toBuffer())); } /** diff --git a/yarn-project/circuits.js/src/contract/contract_address.ts b/yarn-project/circuits.js/src/contract/contract_address.ts index e9636e6de39..933cbe6207d 100644 --- a/yarn-project/circuits.js/src/contract/contract_address.ts +++ b/yarn-project/circuits.js/src/contract/contract_address.ts @@ -43,11 +43,9 @@ export function computePartialAddress( ? instance.saltedInitializationHash : computeSaltedInitializationHash(instance); - return Fr.fromBuffer( - pedersenHash( - [instance.contractClassId, saltedInitializationHash].map(x => x.toBuffer()), - GeneratorIndex.PARTIAL_ADDRESS, - ), + return pedersenHash( + [instance.contractClassId, saltedInitializationHash].map(x => x.toBuffer()), + GeneratorIndex.PARTIAL_ADDRESS, ); } @@ -58,11 +56,9 @@ export function computePartialAddress( export function computeSaltedInitializationHash( instance: Pick, ): Fr { - return Fr.fromBuffer( - pedersenHash( - [instance.salt, instance.initializationHash, instance.portalContractAddress].map(x => x.toBuffer()), - GeneratorIndex.PARTIAL_ADDRESS, - ), + return pedersenHash( + [instance.salt, instance.initializationHash, instance.portalContractAddress].map(x => x.toBuffer()), + GeneratorIndex.PARTIAL_ADDRESS, ); } @@ -79,7 +75,7 @@ export function computeContractAddressFromPartial( [publicKeyHash.toBuffer(), args.partialAddress.toBuffer()], GeneratorIndex.CONTRACT_ADDRESS, ); - return new AztecAddress(result); + return AztecAddress.fromField(result); } /** @@ -91,7 +87,7 @@ export function computePublicKeysHash(publicKey: PublicKey | undefined): Fr { if (!publicKey) { return Fr.ZERO; } - return Fr.fromBuffer(pedersenHash([publicKey.x.toBuffer(), publicKey.y.toBuffer()], GeneratorIndex.PARTIAL_ADDRESS)); + return pedersenHash([publicKey.x.toBuffer(), publicKey.y.toBuffer()], GeneratorIndex.PARTIAL_ADDRESS); } /** @@ -114,5 +110,5 @@ export function computeInitializationHash(initFn: FunctionAbi, args: any[]): Fr */ export function computeInitializationHashFromEncodedArgs(initFn: FunctionSelector, encodedArgs: Fr[]): Fr { const argsHash = computeVarArgsHash(encodedArgs); - return Fr.fromBuffer(pedersenHash([initFn.toBuffer(), argsHash.toBuffer()], GeneratorIndex.CONSTRUCTOR)); + return pedersenHash([initFn.toBuffer(), argsHash.toBuffer()], GeneratorIndex.CONSTRUCTOR); } diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.ts b/yarn-project/circuits.js/src/contract/contract_class_id.ts index 2165225a37c..d2e218f3fe8 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.ts @@ -35,11 +35,9 @@ export function computeContractClassIdWithPreimage( 'publicBytecodeCommitment' in contractClass ? contractClass.publicBytecodeCommitment : computePublicBytecodeCommitment(contractClass.packedBytecode); - const id = Fr.fromBuffer( - pedersenHash( - [artifactHash.toBuffer(), privateFunctionsRoot.toBuffer(), publicBytecodeCommitment.toBuffer()], - GeneratorIndex.CONTRACT_LEAF, // TODO(@spalladino): Review all generator indices in this file - ), + const id = pedersenHash( + [artifactHash.toBuffer(), privateFunctionsRoot.toBuffer(), publicBytecodeCommitment.toBuffer()], + GeneratorIndex.CONTRACT_LEAF, // TODO(@spalladino): Review all generator indices in this file ); return { id, artifactHash, privateFunctionsRoot, publicBytecodeCommitment }; } diff --git a/yarn-project/circuits.js/src/contract/private_function.ts b/yarn-project/circuits.js/src/contract/private_function.ts index a1abcf166ee..0e7bde1cdc9 100644 --- a/yarn-project/circuits.js/src/contract/private_function.ts +++ b/yarn-project/circuits.js/src/contract/private_function.ts @@ -31,12 +31,12 @@ export function computePrivateFunctionLeaf(fn: PrivateFunction): Buffer { return pedersenHash( [fn.selector, fn.vkHash].map(x => x.toBuffer()), GeneratorIndex.FUNCTION_LEAF, - ); + ).toBuffer(); } function getPrivateFunctionTreeCalculator(): MerkleTreeCalculator { if (!privateFunctionTreeCalculator) { - const functionTreeZeroLeaf = pedersenHash(new Array(PRIVATE_FUNCTION_SIZE).fill(Buffer.alloc(32))); + const functionTreeZeroLeaf = pedersenHash(new Array(PRIVATE_FUNCTION_SIZE).fill(Buffer.alloc(32))).toBuffer(); privateFunctionTreeCalculator = new MerkleTreeCalculator(FUNCTION_TREE_HEIGHT, functionTreeZeroLeaf); } return privateFunctionTreeCalculator; diff --git a/yarn-project/circuits.js/src/hash/hash.test.ts b/yarn-project/circuits.js/src/hash/hash.test.ts index fd85f263473..1839ba3e475 100644 --- a/yarn-project/circuits.js/src/hash/hash.test.ts +++ b/yarn-project/circuits.js/src/hash/hash.test.ts @@ -105,13 +105,13 @@ describe('hash', () => { it('Computes an empty nullifier hash ', () => { const emptyNull = SideEffectLinkedToNoteHash.empty(); - const emptyHash = Fr.fromBuffer(computeNullifierHash(emptyNull)).toString(); + const emptyHash = computeNullifierHash(emptyNull).toString(); expect(emptyHash).toMatchSnapshot(); }); it('Computes an empty sideeffect hash ', () => { const emptySideEffect = SideEffect.empty(); - const emptyHash = Fr.fromBuffer(computeCommitmentsHash(emptySideEffect)).toString(); + const emptyHash = computeCommitmentsHash(emptySideEffect).toString(); expect(emptyHash).toMatchSnapshot(); }); diff --git a/yarn-project/circuits.js/src/hash/hash.ts b/yarn-project/circuits.js/src/hash/hash.ts index f3f8964c3c8..c9407b2b1e9 100644 --- a/yarn-project/circuits.js/src/hash/hash.ts +++ b/yarn-project/circuits.js/src/hash/hash.ts @@ -66,7 +66,7 @@ let functionTreeRootCalculator: MerkleTreeCalculator | undefined; */ function getFunctionTreeRootCalculator() { if (!functionTreeRootCalculator) { - const functionTreeZeroLeaf = pedersenHash(new Array(5).fill(Buffer.alloc(32))); + const functionTreeZeroLeaf = pedersenHash(new Array(5).fill(Buffer.alloc(32))).toBuffer(); functionTreeRootCalculator = new MerkleTreeCalculator(FUNCTION_TREE_HEIGHT, functionTreeZeroLeaf); } return functionTreeRootCalculator; @@ -102,8 +102,9 @@ export function computeFunctionTreeRoot(fnLeaves: Fr[]) { * @returns The constructor hash. */ export function hashConstructor(functionData: FunctionData, argsHash: Fr, constructorVKHash: Buffer): Fr { - return Fr.fromBuffer( - pedersenHash([functionData.hash().toBuffer(), argsHash.toBuffer(), constructorVKHash], GeneratorIndex.CONSTRUCTOR), + return pedersenHash( + [functionData.hash().toBuffer(), argsHash.toBuffer(), constructorVKHash], + GeneratorIndex.CONSTRUCTOR, ); } @@ -114,9 +115,7 @@ export function hashConstructor(functionData: FunctionData, argsHash: Fr, constr * @returns A commitment nonce. */ export function computeCommitmentNonce(nullifierZero: Fr, commitmentIndex: number): Fr { - return Fr.fromBuffer( - pedersenHash([nullifierZero.toBuffer(), numToUInt32BE(commitmentIndex, 32)], GeneratorIndex.COMMITMENT_NONCE), - ); + return pedersenHash([nullifierZero.toBuffer(), numToUInt32BE(commitmentIndex, 32)], GeneratorIndex.COMMITMENT_NONCE); } /** @@ -127,9 +126,7 @@ export function computeCommitmentNonce(nullifierZero: Fr, commitmentIndex: numbe * @returns A siloed commitment. */ export function siloCommitment(contract: AztecAddress, innerCommitment: Fr): Fr { - return Fr.fromBuffer( - pedersenHash([contract.toBuffer(), innerCommitment.toBuffer()], GeneratorIndex.SILOED_COMMITMENT), - ); + return pedersenHash([contract.toBuffer(), innerCommitment.toBuffer()], GeneratorIndex.SILOED_COMMITMENT); } /** @@ -139,7 +136,7 @@ export function siloCommitment(contract: AztecAddress, innerCommitment: Fr): Fr * @returns A unique commitment. */ export function computeUniqueCommitment(nonce: Fr, siloedCommitment: Fr): Fr { - return Fr.fromBuffer(pedersenHash([nonce.toBuffer(), siloedCommitment.toBuffer()], GeneratorIndex.UNIQUE_COMMITMENT)); + return pedersenHash([nonce.toBuffer(), siloedCommitment.toBuffer()], GeneratorIndex.UNIQUE_COMMITMENT); } /** @@ -150,7 +147,7 @@ export function computeUniqueCommitment(nonce: Fr, siloedCommitment: Fr): Fr { * @returns A siloed nullifier. */ export function siloNullifier(contract: AztecAddress, innerNullifier: Fr): Fr { - return Fr.fromBuffer(pedersenHash([contract.toBuffer(), innerNullifier.toBuffer()], GeneratorIndex.OUTER_NULLIFIER)); + return pedersenHash([contract.toBuffer(), innerNullifier.toBuffer()], GeneratorIndex.OUTER_NULLIFIER); } /** @@ -171,9 +168,7 @@ export function computePublicDataTreeValue(value: Fr): Fr { */ export function computePublicDataTreeLeafSlot(contractAddress: AztecAddress, storageSlot: Fr): Fr { - return Fr.fromBuffer( - pedersenHash([contractAddress.toBuffer(), storageSlot.toBuffer()], GeneratorIndex.PUBLIC_LEAF_INDEX), - ); + return pedersenHash([contractAddress.toBuffer(), storageSlot.toBuffer()], GeneratorIndex.PUBLIC_LEAF_INDEX); } /** @@ -193,11 +188,9 @@ export function computeVarArgsHash(args: Fr[]) { if (c.length < ARGS_HASH_CHUNK_LENGTH) { c = padArrayEnd(c, Fr.ZERO, ARGS_HASH_CHUNK_LENGTH); } - return Fr.fromBuffer( - pedersenHash( - c.map(a => a.toBuffer()), - GeneratorIndex.FUNCTION_ARGS, - ), + return pedersenHash( + c.map(a => a.toBuffer()), + GeneratorIndex.FUNCTION_ARGS, ); }); @@ -205,11 +198,9 @@ export function computeVarArgsHash(args: Fr[]) { chunksHashes = padArrayEnd(chunksHashes, Fr.ZERO, ARGS_HASH_CHUNK_COUNT); } - return Fr.fromBuffer( - pedersenHash( - chunksHashes.map(a => a.toBuffer()), - GeneratorIndex.FUNCTION_ARGS, - ), + return pedersenHash( + chunksHashes.map(a => a.toBuffer()), + GeneratorIndex.FUNCTION_ARGS, ); } @@ -230,5 +221,5 @@ export function computeNullifierHash(input: SideEffectLinkedToNoteHash) { * @returns the hash */ export function computeMessageSecretHash(secretMessage: Fr) { - return Fr.fromBuffer(pedersenHash([secretMessage.toBuffer()], GeneratorIndex.L1_TO_L2_MESSAGE_SECRET)); + return pedersenHash([secretMessage.toBuffer()], GeneratorIndex.L1_TO_L2_MESSAGE_SECRET); } diff --git a/yarn-project/circuits.js/src/keys/index.ts b/yarn-project/circuits.js/src/keys/index.ts index 07e8b0b2a65..dee7623db74 100644 --- a/yarn-project/circuits.js/src/keys/index.ts +++ b/yarn-project/circuits.js/src/keys/index.ts @@ -20,7 +20,7 @@ function deriveSecretKey(secretKey: GrumpkinPrivateKey, index: Fr): GrumpkinPriv // TODO: Temporary hack. Should replace it with a secure way to derive the secret key. // Match the way keys are derived in noir-protocol-circuits/src/crates/private_kernel_lib/src/common.nr const hash = pedersenHash([secretKey.high, secretKey.low, index].map(v => v.toBuffer())); - return new GrumpkinScalar(hash); + return new GrumpkinScalar(hash.toBuffer()); } /** 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 388d08a5f2d..c8d4870039c 100644 --- a/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts +++ b/yarn-project/circuits.js/src/merkle/merkle_tree_calculator.ts @@ -12,7 +12,7 @@ export class MerkleTreeCalculator { constructor( private height: number, zeroLeaf = Buffer.alloc(32), - hasher = (left: Buffer, right: Buffer) => pedersenHash([left, right]), + 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/structs/contract_deployment_data.ts b/yarn-project/circuits.js/src/structs/contract_deployment_data.ts index 55f13f19ecd..e7fdb5d7e71 100644 --- a/yarn-project/circuits.js/src/structs/contract_deployment_data.ts +++ b/yarn-project/circuits.js/src/structs/contract_deployment_data.ts @@ -89,11 +89,9 @@ export class ContractDeploymentData { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(f => f.toBuffer()), - GeneratorIndex.CONTRACT_DEPLOYMENT_DATA, - ), + return pedersenHash( + this.toFields().map(f => f.toBuffer()), + GeneratorIndex.CONTRACT_DEPLOYMENT_DATA, ); } } diff --git a/yarn-project/circuits.js/src/structs/function_data.ts b/yarn-project/circuits.js/src/structs/function_data.ts index 3cf82fc5784..310d03507aa 100644 --- a/yarn-project/circuits.js/src/structs/function_data.ts +++ b/yarn-project/circuits.js/src/structs/function_data.ts @@ -123,11 +123,9 @@ export class FunctionData { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.FUNCTION_DATA, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.FUNCTION_DATA, ); } } diff --git a/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts b/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts index 53f2b1e71ca..6a5b0f22cc8 100644 --- a/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts +++ b/yarn-project/circuits.js/src/structs/function_leaf_preimage.ts @@ -72,11 +72,9 @@ export class FunctionLeafPreimage { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.FUNCTION_LEAF, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.FUNCTION_LEAF, ); } } diff --git a/yarn-project/circuits.js/src/structs/header.ts b/yarn-project/circuits.js/src/structs/header.ts index 1e28525a99a..0194ec5f97e 100644 --- a/yarn-project/circuits.js/src/structs/header.ts +++ b/yarn-project/circuits.js/src/structs/header.ts @@ -94,11 +94,9 @@ export class Header { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(f => f.toBuffer()), - GeneratorIndex.BLOCK_HASH, - ), + return pedersenHash( + this.toFields().map(f => f.toBuffer()), + GeneratorIndex.BLOCK_HASH, ); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/new_contract_data.ts b/yarn-project/circuits.js/src/structs/kernel/new_contract_data.ts index 94203ddfad2..82921fc545f 100644 --- a/yarn-project/circuits.js/src/structs/kernel/new_contract_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/new_contract_data.ts @@ -55,11 +55,9 @@ export class NewContractData { if (this.isEmpty()) { return new Fr(0); } - return Fr.fromBuffer( - pedersenHash( - NewContractData.getFields(this).map(f => f.toBuffer()), - GeneratorIndex.CONTRACT_LEAF, - ), + return pedersenHash( + NewContractData.getFields(this).map(f => f.toBuffer()), + GeneratorIndex.CONTRACT_LEAF, ); } diff --git a/yarn-project/circuits.js/src/structs/private_call_stack_item.ts b/yarn-project/circuits.js/src/structs/private_call_stack_item.ts index ec56ca3bc97..5da5b020841 100644 --- a/yarn-project/circuits.js/src/structs/private_call_stack_item.ts +++ b/yarn-project/circuits.js/src/structs/private_call_stack_item.ts @@ -91,11 +91,9 @@ export class PrivateCallStackItem { * @returns Hash. */ public hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.CALL_STACK_ITEM, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.CALL_STACK_ITEM, ); } diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 99b263181d7..cdf55d91df2 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -299,11 +299,9 @@ export class PrivateCircuitPublicInputs { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.PRIVATE_CIRCUIT_PUBLIC_INPUTS, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.PRIVATE_CIRCUIT_PUBLIC_INPUTS, ); } } diff --git a/yarn-project/circuits.js/src/structs/public_call_stack_item.ts b/yarn-project/circuits.js/src/structs/public_call_stack_item.ts index 0f1e43b7db3..5f9f98d2cae 100644 --- a/yarn-project/circuits.js/src/structs/public_call_stack_item.ts +++ b/yarn-project/circuits.js/src/structs/public_call_stack_item.ts @@ -96,11 +96,9 @@ export class PublicCallStackItem { this.publicInputs.argsHash = argsHash; } - return Fr.fromBuffer( - pedersenHash( - [this.contractAddress, this.functionData.hash(), this.publicInputs.hash()].map(f => f.toBuffer()), - GeneratorIndex.CALL_STACK_ITEM, - ), + return pedersenHash( + [this.contractAddress, this.functionData.hash(), this.publicInputs.hash()].map(f => f.toBuffer()), + GeneratorIndex.CALL_STACK_ITEM, ); } diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 2b0e111f9df..4bf4d0140f6 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -228,11 +228,9 @@ export class PublicCircuitPublicInputs { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.PUBLIC_CIRCUIT_PUBLIC_INPUTS, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.PUBLIC_CIRCUIT_PUBLIC_INPUTS, ); } } diff --git a/yarn-project/circuits.js/src/structs/tx_context.ts b/yarn-project/circuits.js/src/structs/tx_context.ts index dd5107105b4..e66e0596ed8 100644 --- a/yarn-project/circuits.js/src/structs/tx_context.ts +++ b/yarn-project/circuits.js/src/structs/tx_context.ts @@ -120,11 +120,9 @@ export class TxContext { } hash(): Fr { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(f => f.toBuffer()), - GeneratorIndex.TX_CONTEXT, - ), + return pedersenHash( + this.toFields().map(f => f.toBuffer()), + GeneratorIndex.TX_CONTEXT, ); } } diff --git a/yarn-project/circuits.js/src/structs/tx_request.ts b/yarn-project/circuits.js/src/structs/tx_request.ts index 855da757002..f2d169fc827 100644 --- a/yarn-project/circuits.js/src/structs/tx_request.ts +++ b/yarn-project/circuits.js/src/structs/tx_request.ts @@ -71,11 +71,9 @@ export class TxRequest { } hash() { - return Fr.fromBuffer( - pedersenHash( - this.toFields().map(field => field.toBuffer()), - GeneratorIndex.TX_REQUEST, - ), + return pedersenHash( + this.toFields().map(field => field.toBuffer()), + GeneratorIndex.TX_REQUEST, ); } diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts index db68e95f98d..4825c04e63a 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts @@ -813,7 +813,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${messageHash.toString('hex')}`, + `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -840,7 +840,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); }); @@ -1147,7 +1147,7 @@ describe('e2e_blacklist_token_contract', () => { ); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); @@ -1386,7 +1386,7 @@ describe('e2e_blacklist_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${messageHash.toString('hex')}`, + `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -1408,7 +1408,7 @@ describe('e2e_blacklist_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 9e5932e00d4..4f70efdc5fe 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -203,7 +203,7 @@ describe('e2e_cross_chain_messaging', () => { .withWallet(user1Wallet) .methods.exit_to_l1_private(l2Token.address, ethAccount, withdrawAmount, EthAddress.ZERO, nonce) .simulate(), - ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedBurnMessageHash.toString('hex')}`); + ).rejects.toThrowError(`Unknown auth witness for message hash ${expectedBurnMessageHash.toString()}`); }, 120_000); it("Can't claim funds publicly if they were deposited privately", async () => { diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index a33526523ed..10c6cbae525 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -172,7 +172,7 @@ describe('e2e_lending_contract', () => { .request(), ); - await wallet.createAuthWitness(Fr.fromBuffer(messageHash)); + await wallet.createAuthWitness(messageHash); await lendingSim.progressTime(TIME_JUMP); lendingSim.depositPrivate(lendingAccount.address, lendingAccount.key(), depositAmount); @@ -205,7 +205,7 @@ describe('e2e_lending_contract', () => { .unshield(lendingAccount.address, lendingContract.address, depositAmount, nonce) .request(), ); - await wallet.createAuthWitness(Fr.fromBuffer(messageHash)); + await wallet.createAuthWitness(messageHash); await lendingSim.progressTime(TIME_JUMP); lendingSim.depositPrivate(lendingAccount.address, lendingAccount.address.toField(), depositAmount); @@ -303,7 +303,7 @@ describe('e2e_lending_contract', () => { lendingContract.address, stableCoin.methods.burn(lendingAccount.address, repayAmount, nonce).request(), ); - await wallet.createAuthWitness(Fr.fromBuffer(messageHash)); + await wallet.createAuthWitness(messageHash); await lendingSim.progressTime(TIME_JUMP); lendingSim.repayPrivate(lendingAccount.address, lendingAccount.key(), repayAmount); @@ -329,7 +329,7 @@ describe('e2e_lending_contract', () => { lendingContract.address, stableCoin.methods.burn(lendingAccount.address, repayAmount, nonce).request(), ); - await wallet.createAuthWitness(Fr.fromBuffer(messageHash)); + await wallet.createAuthWitness(messageHash); await lendingSim.progressTime(TIME_JUMP); lendingSim.repayPrivate(lendingAccount.address, lendingAccount.address.toField(), repayAmount); diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index 42792edbe75..bb667a39179 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -614,7 +614,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${messageHash.toString('hex')}`, + `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -635,7 +635,7 @@ describe('e2e_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); }); @@ -874,7 +874,7 @@ describe('e2e_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); }); @@ -1062,7 +1062,7 @@ describe('e2e_token_contract', () => { const messageHash = computeAuthWitMessageHash(accounts[1].address, action.request()); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${messageHash.toString('hex')}`, + `Unknown auth witness for message hash ${messageHash.toString()}`, ); }); @@ -1081,7 +1081,7 @@ describe('e2e_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect(action.simulate()).rejects.toThrowError( - `Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`, + `Unknown auth witness for message hash ${expectedMessageHash.toString()}`, ); }); }); diff --git a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts index cbf7df99002..9a5669165d4 100644 --- a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts +++ b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts @@ -206,7 +206,7 @@ export const uniswapL1L2TestSuite = ( .unshield(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHUnshieldApproval) .request(), ); - await ownerWallet.createAuthWitness(Fr.fromBuffer(unshieldToUniswapMessageHash)); + await ownerWallet.createAuthWitness(unshieldToUniswapMessageHash); // 4. Swap on L1 - sends L2 to L1 message to withdraw WETH to L1 and another message to swap assets. logger('Withdrawing weth to L1 and sending message to swap to dai'); @@ -475,7 +475,7 @@ export const uniswapL1L2TestSuite = ( ownerEthAddress, ) .simulate(), - ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`); + ).rejects.toThrowError(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`); }); it("can't swap if user passes a token different to what the bridge tracks", async () => { @@ -494,7 +494,7 @@ export const uniswapL1L2TestSuite = ( .unshield(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHUnshieldApproval) .request(), ); - await ownerWallet.createAuthWitness(Fr.fromBuffer(unshieldToUniswapMessageHash)); + await ownerWallet.createAuthWitness(unshieldToUniswapMessageHash); // 3. Swap but send the wrong token address logger('Swap but send the wrong token address'); @@ -644,7 +644,7 @@ export const uniswapL1L2TestSuite = ( .unshield(ownerAddress, uniswapL2Contract.address, wethAmountToBridge, nonceForWETHUnshieldApproval) .request(), ); - await ownerWallet.createAuthWitness(Fr.fromBuffer(unshieldToUniswapMessageHash)); + await ownerWallet.createAuthWitness(unshieldToUniswapMessageHash); const wethL2BalanceBeforeSwap = await wethCrossChainHarness.getL2PrivateBalanceOf(ownerAddress); // Swap diff --git a/yarn-project/end-to-end/src/simulators/lending_simulator.ts b/yarn-project/end-to-end/src/simulators/lending_simulator.ts index dcc91fa28a1..2a0da49ed1d 100644 --- a/yarn-project/end-to-end/src/simulators/lending_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/lending_simulator.ts @@ -24,7 +24,7 @@ export class LendingAccount { * @returns Key in public space */ public key() { - return Fr.fromBuffer(pedersenHash([this.address, this.secret].map(f => f.toBuffer()))); + return pedersenHash([this.address, this.secret].map(f => f.toBuffer())); } } diff --git a/yarn-project/foundation/src/abi/__snapshots__/function_selector.test.ts.snap b/yarn-project/foundation/src/abi/__snapshots__/function_selector.test.ts.snap new file mode 100644 index 00000000000..b80d8292ad3 --- /dev/null +++ b/yarn-project/foundation/src/abi/__snapshots__/function_selector.test.ts.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FunctionSelector computes a function selector from signature 1`] = ` +FunctionSelector { + "value": 2835717307, +} +`; diff --git a/yarn-project/foundation/src/crypto/pedersen/index.test.ts b/yarn-project/foundation/src/crypto/pedersen/index.test.ts index 412b07ec962..298c81d1859 100644 --- a/yarn-project/foundation/src/crypto/pedersen/index.test.ts +++ b/yarn-project/foundation/src/crypto/pedersen/index.test.ts @@ -26,12 +26,12 @@ describe('pedersen', () => { it('pedersen hash', () => { const r = pedersenHash([toBufferBE(1n, 32), toBufferBE(1n, 32)]); - expect(r).toEqual(Buffer.from('07ebfbf4df29888c6cd6dca13d4bb9d1a923013ddbbcbdc3378ab8845463297b', 'hex')); + expect(r.toString()).toEqual('0x07ebfbf4df29888c6cd6dca13d4bb9d1a923013ddbbcbdc3378ab8845463297b'); }); it('pedersen hash with index', () => { const r = pedersenHash([toBufferBE(1n, 32), toBufferBE(1n, 32)], 5); - expect(r).toEqual(Buffer.from('1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6', 'hex')); + expect(r.toString()).toEqual('0x1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6'); }); it('pedersen hash buffer', () => { diff --git a/yarn-project/foundation/src/crypto/pedersen/pedersen.wasm.ts b/yarn-project/foundation/src/crypto/pedersen/pedersen.wasm.ts index 6d38d88a110..dbe457a2971 100644 --- a/yarn-project/foundation/src/crypto/pedersen/pedersen.wasm.ts +++ b/yarn-project/foundation/src/crypto/pedersen/pedersen.wasm.ts @@ -1,4 +1,6 @@ -import { BarretenbergSync, Fr } from '@aztec/bb.js'; +import { BarretenbergSync, Fr as FrBarretenberg } from '@aztec/bb.js'; + +import { Fr } from '../../fields/fields.js'; /** * Create a pedersen commitment (point) from an array of input fields. @@ -9,7 +11,7 @@ export function pedersenCommit(input: Buffer[]) { throw new Error('All Pedersen Commit input buffers must be <= 32 bytes.'); } input = input.map(i => (i.length < 32 ? Buffer.concat([Buffer.alloc(32 - i.length, 0), i]) : i)); - const point = BarretenbergSync.getSingleton().pedersenCommit(input.map(i => new Fr(i))); + const point = BarretenbergSync.getSingleton().pedersenCommit(input.map(i => new FrBarretenberg(i))); // toBuffer returns Uint8Arrays (browser/worker-boundary friendly). // TODO: rename toTypedArray()? return [Buffer.from(point.x.toBuffer()), Buffer.from(point.y.toBuffer())]; @@ -19,18 +21,20 @@ export function pedersenCommit(input: Buffer[]) { * Create a pedersen hash (field) from an array of input fields. * Left pads any inputs less than 32 bytes. */ -export function pedersenHash(input: Buffer[], index = 0): Buffer { +export function pedersenHash(input: Buffer[], index = 0): Fr { if (!input.every(i => i.length <= 32)) { throw new Error('All Pedersen Hash input buffers must be <= 32 bytes.'); } input = input.map(i => (i.length < 32 ? Buffer.concat([Buffer.alloc(32 - i.length, 0), i]) : i)); - return Buffer.from( - BarretenbergSync.getSingleton() - .pedersenHash( - input.map(i => new Fr(i)), - index, - ) - .toBuffer(), + return Fr.fromBuffer( + Buffer.from( + BarretenbergSync.getSingleton() + .pedersenHash( + input.map(i => new FrBarretenberg(i)), + index, + ) + .toBuffer(), + ), ); } diff --git a/yarn-project/foundation/src/crypto/poseidon/index.ts b/yarn-project/foundation/src/crypto/poseidon/index.ts index 7cc44a95b5e..8f77b580211 100644 --- a/yarn-project/foundation/src/crypto/poseidon/index.ts +++ b/yarn-project/foundation/src/crypto/poseidon/index.ts @@ -1,13 +1,17 @@ -import { BarretenbergSync, Fr } from '@aztec/bb.js'; +import { BarretenbergSync, Fr as FrBarretenberg } from '@aztec/bb.js'; + +import { Fr } from '../../fields/fields.js'; /** * Create a poseidon hash (field) from an array of input fields. * Left pads any inputs less than 32 bytes. */ -export function poseidonHash(input: Buffer[]): Buffer { - return Buffer.from( - BarretenbergSync.getSingleton() - .poseidonHash(input.map(i => new Fr(i))) - .toBuffer(), +export function poseidonHash(input: Buffer[]): Fr { + return Fr.fromBuffer( + Buffer.from( + BarretenbergSync.getSingleton() + .poseidonHash(input.map(i => new FrBarretenberg(i))) + .toBuffer(), + ), ); } diff --git a/yarn-project/merkle-tree/src/pedersen.ts b/yarn-project/merkle-tree/src/pedersen.ts index 2cc99004970..b4a749e5a8a 100644 --- a/yarn-project/merkle-tree/src/pedersen.ts +++ b/yarn-project/merkle-tree/src/pedersen.ts @@ -12,7 +12,7 @@ export class Pedersen implements Hasher { * purposes. */ public hash(lhs: Uint8Array, rhs: Uint8Array): Buffer { - return pedersenHash([Buffer.from(lhs), Buffer.from(rhs)]); + return pedersenHash([Buffer.from(lhs), Buffer.from(rhs)]).toBuffer(); } /* @@ -20,6 +20,6 @@ export class Pedersen implements Hasher { * purposes. */ public hashInputs(inputs: Buffer[]): Buffer { - return pedersenHash(inputs); + return pedersenHash(inputs).toBuffer(); } } diff --git a/yarn-project/pxe/src/note_processor/note_processor.test.ts b/yarn-project/pxe/src/note_processor/note_processor.test.ts index 3770584959c..6c66111c2b0 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.test.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.test.ts @@ -43,7 +43,7 @@ describe('Note Processor', () => { const firstBlockDataStartIndex = (firstBlockNum - 1) * numCommitmentsPerBlock; const firstBlockDataEndIndex = firstBlockNum * numCommitmentsPerBlock; - const computeMockNoteHash = (note: Note) => Fr.fromBuffer(pedersenHash(note.items.map(i => i.toBuffer()))); + const computeMockNoteHash = (note: Note) => pedersenHash(note.items.map(i => i.toBuffer())); // ownedData: [tx1, tx2, ...], the numbers in each tx represents the indices of the note hashes the account owns. const createEncryptedLogsAndOwnedL1NotePayloads = (ownedData: number[][], ownedNotes: L1NotePayload[]) => { diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index 8a56550155a..bfe7b98f704 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -118,7 +118,7 @@ describe('AVM simulator', () => { describe.each([ ['avm_poseidon_hash', poseidonHash], ['avm_pedersen_hash', pedersenHash], - ])('Hashes with field returned in noir contracts', (name: string, hashFunction: (data: Buffer[]) => Buffer) => { + ])('Hashes with field returned in noir contracts', (name: string, hashFunction: (data: Buffer[]) => Fr) => { it(`Should execute contract function that performs ${name} hash`, async () => { const calldata = [new Fr(1), new Fr(2), new Fr(3)]; const hash = hashFunction(calldata.map(f => f.toBuffer())); diff --git a/yarn-project/simulator/src/avm/opcodes/hashing.test.ts b/yarn-project/simulator/src/avm/opcodes/hashing.test.ts index 0c7b363df04..452b997a62f 100644 --- a/yarn-project/simulator/src/avm/opcodes/hashing.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/hashing.test.ts @@ -1,4 +1,3 @@ -import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { keccak, pedersenHash, poseidonHash, sha256 } from '@aztec/foundation/crypto'; import { AvmContext } from '../avm_context.js'; @@ -45,7 +44,7 @@ describe('Hashing Opcodes', () => { await new Poseidon2(indirect, dstOffset, hashOffset, args.length).execute(context); const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(toBigIntBE(expectedHash))); + expect(result).toEqual(new Field(expectedHash)); }); it('Should hash correctly - indirect', async () => { @@ -63,7 +62,7 @@ describe('Hashing Opcodes', () => { await new Poseidon2(indirect, dstOffset, hashOffset, args.length).execute(context); const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(toBigIntBE(expectedHash))); + expect(result).toEqual(new Field(expectedHash)); }); }); @@ -225,7 +224,7 @@ describe('Hashing Opcodes', () => { await new Pedersen(indirect, dstOffset, hashOffset, args.length).execute(context); const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(toBigIntBE(expectedHash))); + expect(result).toEqual(new Field(expectedHash)); }); it('Should hash correctly - indirect', async () => { @@ -244,7 +243,7 @@ describe('Hashing Opcodes', () => { await new Pedersen(indirect, dstOffset, hashOffset, args.length).execute(context); const result = context.machineState.memory.get(dstOffset); - expect(result).toEqual(new Field(toBigIntBE(expectedHash))); + expect(result).toEqual(new Field(expectedHash)); }); }); }); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 501c5b908a4..a8e03dcdfc5 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -178,7 +178,7 @@ describe('Private Execution test suite', () => { return trees[name]; }; - const hashFields = (data: Fr[]) => Fr.fromBuffer(pedersenHash(data.map(f => f.toBuffer()))); + const hashFields = (data: Fr[]) => pedersenHash(data.map(f => f.toBuffer())); beforeAll(() => { logger = createDebugLogger('aztec:test:private_execution'); diff --git a/yarn-project/simulator/src/client/simulator.test.ts b/yarn-project/simulator/src/client/simulator.test.ts index 4eec4b5a3d1..b8192633373 100644 --- a/yarn-project/simulator/src/client/simulator.test.ts +++ b/yarn-project/simulator/src/client/simulator.test.ts @@ -23,7 +23,7 @@ describe('Simulator', () => { const ownerNullifierSecretKey = GrumpkinScalar.random(); const ownerNullifierPublicKey = Point.random(); - const hashFields = (data: Fr[]) => Fr.fromBuffer(pedersenHash(data.map(f => f.toBuffer()))); + const hashFields = (data: Fr[]) => pedersenHash(data.map(f => f.toBuffer())); beforeEach(() => { oracle = mock(); diff --git a/yarn-project/simulator/src/public/index.test.ts b/yarn-project/simulator/src/public/index.test.ts index 4a528e1f187..7171d3656de 100644 --- a/yarn-project/simulator/src/public/index.test.ts +++ b/yarn-project/simulator/src/public/index.test.ts @@ -332,8 +332,8 @@ describe('ACIR public execution simulator', () => { const expectedNoteHash = pedersenHash([amount.toBuffer(), secretHash.toBuffer()]); const storageSlot = new Fr(5); // for pending_shields - const expectedInnerNoteHash = pedersenHash([storageSlot.toBuffer(), expectedNoteHash]); - expect(result.newCommitments[0].value.toBuffer()).toEqual(expectedInnerNoteHash); + const expectedInnerNoteHash = pedersenHash([storageSlot, expectedNoteHash].map(f => f.toBuffer())); + expect(result.newCommitments[0].value).toEqual(expectedInnerNoteHash); }); it('Should be able to create a L2 to L1 message from the public context', async () => { @@ -363,10 +363,7 @@ describe('ACIR public execution simulator', () => { // Assert the l2 to l1 message was created expect(result.newL2ToL1Messages.length).toEqual(1); - const expectedNewMessage = new L2ToL1Message( - portalContractAddress, - Fr.fromBuffer(pedersenHash(params.map(a => a.toBuffer()))), - ); + const expectedNewMessage = new L2ToL1Message(portalContractAddress, pedersenHash(params.map(a => a.toBuffer()))); expect(result.newL2ToL1Messages[0]).toEqual(expectedNewMessage); }); @@ -398,7 +395,7 @@ describe('ACIR public execution simulator', () => { expect(result.newNullifiers.length).toEqual(1); const expectedNewMessageValue = pedersenHash(params.map(a => a.toBuffer())); - expect(result.newNullifiers[0].value.toBuffer()).toEqual(expectedNewMessageValue); + expect(result.newNullifiers[0].value).toEqual(expectedNewMessageValue); }); describe('L1 to L2 messages', () => { @@ -478,7 +475,7 @@ describe('ACIR public execution simulator', () => { let root = messageKey ?? preimage.hash(); for (const sibling of siblingPathBuffers) { - root = Fr.fromBuffer(pedersenHash([root.toBuffer(), sibling])); + root = pedersenHash([root.toBuffer(), sibling]); } commitmentsDb.getL1ToL2Message.mockImplementation(() => { return Promise.resolve(new MessageLoadOracleInputs(preimage, 0n, siblingPath)); diff --git a/yarn-project/simulator/src/utils.ts b/yarn-project/simulator/src/utils.ts index a47e4e390ba..ad65917f013 100644 --- a/yarn-project/simulator/src/utils.ts +++ b/yarn-project/simulator/src/utils.ts @@ -14,5 +14,5 @@ export function computeSlotForMapping( toField: () => Fr; }, ) { - return Fr.fromBuffer(pedersenHash([mappingSlot, key.toField()].map(field => field.toBuffer()))); + return pedersenHash([mappingSlot, key.toField()].map(field => field.toBuffer())); }