Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrezhniev committed Sep 10, 2024
1 parent a4bef47 commit 7b2f839
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 57 deletions.
33 changes: 18 additions & 15 deletions build/browser.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3394,11 +3394,13 @@ async function builder(code, options) {
// If we can't look up the patch version, assume the lowest
let patchVersion = 0;

let codeIsWebAssemblyInstance = false;

// If code is already prepared WebAssembly.Instance, we use it directly
if (code instanceof WebAssembly.Instance) {
instance = code;
codeIsWebAssemblyInstance = true;
} else {

let memorySize = 32767;

if (options.memorySize) {
Expand Down Expand Up @@ -3558,9 +3560,13 @@ async function builder(code, options) {
// We explicitly check for major version 2 in case there's a circom v3 in the future
if (majorVersion === 2) {
wc = new WitnessCalculatorCircom2(instance, sanityCheck);
} else {
// TODO: Maybe we want to check for the explicit version 1 before choosing this?
} else if (majorVersion === 1) {
if (codeIsWebAssemblyInstance) {
throw new Error('Loading code from WebAssembly instance is not supported for circom version 1');
}
wc = new WitnessCalculatorCircom1(memory, instance, sanityCheck);
} else {
throw new Error(`Unsupported circom version: ${majorVersion}`);
}
return wc;

Expand Down Expand Up @@ -3938,7 +3944,7 @@ async function wtnsCalculate(_input, wasmFileName, wtnsFileName, options) {
await fdWasm.close();

const wc = await builder(wasm, options);
if (wc.circom_version() == 1) {
if (wc.circom_version() === 1) {
const w = await wc.calculateBinWitness(input);

const fdWtns = await createBinFile(wtnsFileName, "wtns", 2, 2);
Expand Down Expand Up @@ -3975,13 +3981,13 @@ async function wtnsCalculate(_input, wasmFileName, wtnsFileName, options) {
*/
const {unstringifyBigInts: unstringifyBigInts$a} = utils;

async function groth16FullProve(_input, wasmFile, zkeyFileName, logger) {
async function groth16FullProve(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$a(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate(input, wasmFile, wtns);
await wtnsCalculate(input, wasmFile, wtns, wtnsCalcOptions);
return await groth16Prove(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -7043,10 +7049,7 @@ async function wtnsDebug(_input, wasmFileName, wtnsFileName, symName, options, l
const wasm = await fdWasm.read(fdWasm.totalSize);
await fdWasm.close();


let wcOps = {
sanityCheck: true
};
const wcOps = {...options, sanityCheck: true};
let sym = await loadSymbols(symName);
if (options.set) {
if (!sym) sym = await loadSymbols(symName);
Expand Down Expand Up @@ -7074,7 +7077,7 @@ async function wtnsDebug(_input, wasmFileName, wtnsFileName, symName, options, l
wcOps.sym = sym;

const wc = await builder(wasm, wcOps);
const w = await wc.calculateWitness(input);
const w = await wc.calculateWitness(input, true);

const fdWtns = await createBinFile(wtnsFileName, "wtns", 2, 2);

Expand Down Expand Up @@ -12801,13 +12804,13 @@ async function plonk16Prove(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$5} = utils;

async function plonkFullProve(_input, wasmFile, zkeyFileName, logger) {
async function plonkFullProve(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$5(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate(input, wasmFile, wtns);
await wtnsCalculate(input, wasmFile, wtns, wtnsCalcOptions);
return await plonk16Prove(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -15392,13 +15395,13 @@ async function fflonkProve(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$2} = utils;

async function fflonkFullProve(_input, wasmFilename, zkeyFilename, logger) {
async function fflonkFullProve(_input, wasmFilename, zkeyFilename, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$2(_input);

const wtns= {type: "mem"};

// Compute the witness
await wtnsCalculate(input, wasmFilename, wtns);
await wtnsCalculate(input, wasmFilename, wtns, wtnsCalcOptions);

// Compute the proof
return await fflonkProve(zkeyFilename, wtns, logger);
Expand Down
21 changes: 9 additions & 12 deletions build/cli.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6072,7 +6072,7 @@ async function wtnsCalculate$1(_input, wasmFileName, wtnsFileName, options) {
await fdWasm.close();

const wc = await circom_runtime.WitnessCalculatorBuilder(wasm, options);
if (wc.circom_version() == 1) {
if (wc.circom_version() === 1) {
const w = await wc.calculateBinWitness(input);

const fdWtns = await binFileUtils__namespace.createBinFile(wtnsFileName, "wtns", 2, 2);
Expand Down Expand Up @@ -6109,13 +6109,13 @@ async function wtnsCalculate$1(_input, wasmFileName, wtnsFileName, options) {
*/
const {unstringifyBigInts: unstringifyBigInts$9} = ffjavascript.utils;

async function groth16FullProve$1(_input, wasmFile, zkeyFileName, logger) {
async function groth16FullProve$1(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$9(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate$1(input, wasmFile, wtns);
await wtnsCalculate$1(input, wasmFile, wtns, wtnsCalcOptions);
return await groth16Prove$1(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -9004,13 +9004,13 @@ async function plonk16Prove(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$6} = ffjavascript.utils;

async function plonkFullProve$1(_input, wasmFile, zkeyFileName, logger) {
async function plonkFullProve$1(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$6(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate$1(input, wasmFile, wtns);
await wtnsCalculate$1(input, wasmFile, wtns, wtnsCalcOptions);
return await plonk16Prove(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -11569,13 +11569,13 @@ async function fflonkProve$1(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$3} = ffjavascript.utils;

async function fflonkFullProve$1(_input, wasmFilename, zkeyFilename, logger) {
async function fflonkFullProve$1(_input, wasmFilename, zkeyFilename, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$3(_input);

const wtns= {type: "mem"};

// Compute the witness
await wtnsCalculate$1(input, wasmFilename, wtns);
await wtnsCalculate$1(input, wasmFilename, wtns, wtnsCalcOptions);

// Compute the proof
return await fflonkProve$1(zkeyFilename, wtns, logger);
Expand Down Expand Up @@ -12257,10 +12257,7 @@ async function wtnsDebug$1(_input, wasmFileName, wtnsFileName, symName, options,
const wasm = await fdWasm.read(fdWasm.totalSize);
await fdWasm.close();


let wcOps = {
sanityCheck: true
};
const wcOps = {...options, sanityCheck: true};
let sym = await loadSymbols(symName);
if (options.set) {
if (!sym) sym = await loadSymbols(symName);
Expand Down Expand Up @@ -12288,7 +12285,7 @@ async function wtnsDebug$1(_input, wasmFileName, wtnsFileName, symName, options,
wcOps.sym = sym;

const wc = await circom_runtime.WitnessCalculatorBuilder(wasm, wcOps);
const w = await wc.calculateWitness(input);
const w = await wc.calculateWitness(input, true);

const fdWtns = await binFileUtils__namespace.createBinFile(wtnsFileName, "wtns", 2, 2);

Expand Down
21 changes: 9 additions & 12 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ async function wtnsCalculate(_input, wasmFileName, wtnsFileName, options) {
await fdWasm.close();

const wc = await circom_runtime.WitnessCalculatorBuilder(wasm, options);
if (wc.circom_version() == 1) {
if (wc.circom_version() === 1) {
const w = await wc.calculateBinWitness(input);

const fdWtns = await binFileUtils__namespace.createBinFile(wtnsFileName, "wtns", 2, 2);
Expand Down Expand Up @@ -1299,13 +1299,13 @@ async function wtnsCalculate(_input, wasmFileName, wtnsFileName, options) {
*/
const {unstringifyBigInts: unstringifyBigInts$a} = ffjavascript.utils;

async function groth16FullProve(_input, wasmFile, zkeyFileName, logger) {
async function groth16FullProve(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$a(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate(input, wasmFile, wtns);
await wtnsCalculate(input, wasmFile, wtns, wtnsCalcOptions);
return await groth16Prove(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -4017,10 +4017,7 @@ async function wtnsDebug(_input, wasmFileName, wtnsFileName, symName, options, l
const wasm = await fdWasm.read(fdWasm.totalSize);
await fdWasm.close();


let wcOps = {
sanityCheck: true
};
const wcOps = {...options, sanityCheck: true};
let sym = await loadSymbols(symName);
if (options.set) {
if (!sym) sym = await loadSymbols(symName);
Expand Down Expand Up @@ -4048,7 +4045,7 @@ async function wtnsDebug(_input, wasmFileName, wtnsFileName, symName, options, l
wcOps.sym = sym;

const wc = await circom_runtime.WitnessCalculatorBuilder(wasm, wcOps);
const w = await wc.calculateWitness(input);
const w = await wc.calculateWitness(input, true);

const fdWtns = await binFileUtils__namespace.createBinFile(wtnsFileName, "wtns", 2, 2);

Expand Down Expand Up @@ -9114,13 +9111,13 @@ async function plonk16Prove(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$5} = ffjavascript.utils;

async function plonkFullProve(_input, wasmFile, zkeyFileName, logger) {
async function plonkFullProve(_input, wasmFile, zkeyFileName, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$5(_input);

const wtns= {
type: "mem"
};
await wtnsCalculate(input, wasmFile, wtns);
await wtnsCalculate(input, wasmFile, wtns, wtnsCalcOptions);
return await plonk16Prove(zkeyFileName, wtns, logger);
}

Expand Down Expand Up @@ -11707,13 +11704,13 @@ async function fflonkProve(zkeyFileName, witnessFileName, logger) {
*/
const {unstringifyBigInts: unstringifyBigInts$2} = ffjavascript.utils;

async function fflonkFullProve(_input, wasmFilename, zkeyFilename, logger) {
async function fflonkFullProve(_input, wasmFilename, zkeyFilename, logger, wtnsCalcOptions) {
const input = unstringifyBigInts$2(_input);

const wtns= {type: "mem"};

// Compute the witness
await wtnsCalculate(input, wasmFilename, wtns);
await wtnsCalculate(input, wasmFilename, wtns, wtnsCalcOptions);

// Compute the proof
return await fflonkProve(zkeyFilename, wtns, logger);
Expand Down
35 changes: 19 additions & 16 deletions build/snarkjs.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/snarkjs.min.js

Large diffs are not rendered by default.

0 comments on commit 7b2f839

Please sign in to comment.