2 Commits

Author SHA1 Message Date
Daniel Tehrani
63f534a23a v2.3.0 2023-10-05 19:24:51 +09:00
Daniel Tehrani
4d7c3c73df feat: allow specifying using a remote circuit for the prover 2023-10-05 19:13:59 +09:00
3 changed files with 6 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@personaelabs/spartan-ecdsa",
"version": "2.2.0",
"version": "2.3.0",
"main": "./build/lib.js",
"types": "./build/lib.d.ts",
"license": "MIT",

View File

@@ -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 });
@@ -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() {
@@ -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");

View File

@@ -24,6 +24,7 @@ export interface ProverConfig {
witnessGenWasm: string;
circuit: string;
enableProfiler?: boolean;
useRemoteCircuit?: boolean;
}
export interface VerifyConfig {