mirror of
https://github.com/personaelabs/spartan-ecdsa.git
synced 2026-01-10 14:38:04 -05:00
feat: allow specifying using the remote circuit
This commit is contained in:
@@ -90,7 +90,8 @@ export class MembershipProver extends Profiler implements IProver {
|
||||
this.timeEnd("Generate witness");
|
||||
|
||||
this.time("Load circuit");
|
||||
const circuitBin = await loadCircuit(this.circuit);
|
||||
const useRemoteCircuit = typeof window !== "undefined";
|
||||
const circuitBin = await loadCircuit(this.circuit, useRemoteCircuit);
|
||||
this.timeEnd("Load circuit");
|
||||
|
||||
// Get the public input in bytes
|
||||
|
||||
@@ -13,6 +13,7 @@ import { PublicInput, verifyEffEcdsaPubInput } from "../helpers/public_input";
|
||||
*/
|
||||
export class MembershipVerifier extends Profiler implements IVerifier {
|
||||
circuit: string;
|
||||
useRemoteCircuit: boolean;
|
||||
|
||||
constructor(options: VerifyConfig) {
|
||||
super({ enabled: options?.enableProfiler });
|
||||
@@ -30,6 +31,8 @@ export class MembershipVerifier extends Profiler implements IVerifier {
|
||||
}
|
||||
|
||||
this.circuit = options.circuit;
|
||||
this.useRemoteCircuit =
|
||||
options.useRemoteCircuit ?? typeof window !== "undefined";
|
||||
}
|
||||
|
||||
async initWasm() {
|
||||
@@ -41,7 +44,7 @@ export class MembershipVerifier extends Profiler implements IVerifier {
|
||||
publicInputSer: Uint8Array
|
||||
): Promise<boolean> {
|
||||
this.time("Load circuit");
|
||||
const circuitBin = await loadCircuit(this.circuit);
|
||||
const circuitBin = await loadCircuit(this.circuit, this.useRemoteCircuit);
|
||||
this.timeEnd("Load circuit");
|
||||
|
||||
this.time("Verify public input");
|
||||
|
||||
@@ -18,9 +18,8 @@ export const snarkJsWitnessGen = async (input: any, wasmFile: string) => {
|
||||
/**
|
||||
* Load a circuit from a file or URL
|
||||
*/
|
||||
export const loadCircuit = async (pathOrUrl: string): Promise<Uint8Array> => {
|
||||
const isWeb = typeof window !== "undefined";
|
||||
if (isWeb) {
|
||||
export const loadCircuit = async (pathOrUrl: string, useRemoteCircuit: boolean): Promise<Uint8Array> => {
|
||||
if (useRemoteCircuit) {
|
||||
return await fetchCircuit(pathOrUrl);
|
||||
} else {
|
||||
return await readCircuitFromFs(pathOrUrl);
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface ProverConfig {
|
||||
export interface VerifyConfig {
|
||||
circuit: string; // Path to circuit file compiled by Nova-Scotia
|
||||
enableProfiler?: boolean;
|
||||
useRemoteCircuit?: boolean;
|
||||
}
|
||||
|
||||
export interface IProver {
|
||||
|
||||
Reference in New Issue
Block a user