Skip to content

Commit

Permalink
feat: brute force compute_note_hash_and_nullifier selector
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Sep 5, 2023
1 parent c9c5369 commit d391150
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CallContext, CircuitsWasm, FunctionData, TxContext } from '@aztec/circuits.js';
import { computeTxHash } from '@aztec/circuits.js/abis';
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
import { ArrayType, FunctionType, encodeArguments } from '@aztec/foundation/abi';
import { ArrayType, FunctionSelector, FunctionType, encodeArguments } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
Expand Down Expand Up @@ -168,12 +168,23 @@ export class AcirSimulator {
storageSlot: Fr,
notePreimage: Fr[],
) {
let abi: FunctionAbiWithDebugMetadata;
try {
abi = await this.db.getFunctionABI(contractAddress, computeNoteHashAndNullifierSelector);
} catch (e) {
let abi: FunctionAbiWithDebugMetadata | undefined = undefined;

// Brute force
for (let i = 1; i < 5; i++) {
const signature = `compute_note_hash_and_nullifier(Field,Field,Field,[Field;${i}])`;
const selector = FunctionSelector.fromSignature(signature);
try {
abi = await this.db.getFunctionABI(contractAddress, selector);
break;
} catch (e) {
// ignore
}
}

if (abi == undefined) {
throw new Error(
`Mandatory implementation of "${computeNoteHashAndNullifierSignature}" missing in noir contract ${contractAddress.toString()}.`,
`Mandatory implementation of "compute_note_hash_and_nullifier" missing in noir contract ${contractAddress.toString()}.`,
);
}

Expand Down

0 comments on commit d391150

Please sign in to comment.