Skip to content

Commit

Permalink
Allow barretenberg to use all cores
Browse files Browse the repository at this point in the history
  • Loading branch information
LogvinovLeon committed Jan 24, 2024
1 parent 15341af commit 72ce385
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/noir-ethereum-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { BarretenbergBackend, ProofData, type CompiledCircuit } from '@noir-lang
import { Noir, WitnessMap } from '@noir-lang/noir_js';
import { promises as fs } from 'fs';
import toml from 'toml';
import os from 'os';
import noir_ethereum_history_api from '../../../circuit/target/noir_ethereum_history_api.json';
import { type Oracles, defaultOracles } from './noir/oracles/oracles.js';
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 @@ -21,8 +24,6 @@ export async function recordStorageProof(
oracles: Oracles = defaultOracles,
name: string
): Promise<boolean> {
const backend = new BarretenbergBackend(circuit);
const noir = new Noir(circuit, backend);
const proof = await noir.generateFinalProof(input, oracles);

const proofHex = decodeHexString(proof.proof);
Expand All @@ -36,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 72ce385

Please sign in to comment.