Skip to content

Commit

Permalink
Instantiate noir only once
Browse files Browse the repository at this point in the history
  • Loading branch information
LogvinovLeon committed Jan 25, 2024
1 parent 6cf61e5 commit e74df97
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/noir-ethereum-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { decodeHexString, encodeHexString } from './noir/noir_js/encode.js';
import { abiEncode, type InputMap } from '@noir-lang/noirc_abi';

export const circuit = noir_ethereum_history_api as unknown as CompiledCircuit;
const backend = new BarretenbergBackend(circuit, { threads: os.cpus().length });
const noir = new Noir(circuit, backend);

export interface MainInputs extends InputMap {
block_no: number;
Expand All @@ -22,8 +24,6 @@ export async function recordStorageProof(
oracles: Oracles = defaultOracles,
name: string
): Promise<boolean> {
const backend = new BarretenbergBackend(circuit, { threads: os.cpus().length });
const noir = new Noir(circuit, backend);
const proof = await noir.generateFinalProof(input, oracles);

const proofHex = decodeHexString(proof.proof);
Expand All @@ -37,8 +37,6 @@ export async function recordStorageProof(
}

export async function verifyStorageProof(proof: ProofData): Promise<boolean> {
const backend = new BarretenbergBackend(circuit);
const noir = new Noir(circuit, backend);
return await noir.verifyFinalProof(proof);
}

Expand Down

0 comments on commit e74df97

Please sign in to comment.