Skip to content

Commit

Permalink
feat: allow specifying using a remote circuit for the prover
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTehrani committed Oct 5, 2023
1 parent baedc72 commit 4d7c3c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/lib/src/core/membership_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
export class MembershipProver extends Profiler implements IProver {
circuit: string;
witnessGenWasm: string;
useRemoteCircuit: boolean;

constructor(options: ProverConfig) {
super({ enabled: options?.enableProfiler });
Expand All @@ -37,21 +38,9 @@ export class MembershipProver extends Profiler implements IProver {
`);
}

const isNode = typeof window === "undefined";
if (isNode) {
if (
options.circuit.includes("http") ||
options.witnessGenWasm.includes("http")
) {
throw new Error(
`An URL was given for circuit/witnessGenWasm in Node.js environment. Please specify a local path.
`
);
}
}

this.circuit = options.circuit;
this.witnessGenWasm = options.witnessGenWasm;
this.useRemoteCircuit = options.useRemoteCircuit ?? false;
}

async initWasm() {
Expand Down Expand Up @@ -90,7 +79,8 @@ export class MembershipProver extends Profiler implements IProver {
this.timeEnd("Generate witness");

this.time("Load circuit");
const useRemoteCircuit = typeof window !== "undefined";
const useRemoteCircuit =
this.useRemoteCircuit ?? typeof window !== "undefined";
const circuitBin = await loadCircuit(this.circuit, useRemoteCircuit);
this.timeEnd("Load circuit");

Expand Down
1 change: 1 addition & 0 deletions packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ProverConfig {
witnessGenWasm: string;
circuit: string;
enableProfiler?: boolean;
useRemoteCircuit?: boolean;
}

export interface VerifyConfig {
Expand Down

0 comments on commit 4d7c3c7

Please sign in to comment.