Skip to content

Update dependencies to use tornado-snarkjs #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 143 additions & 59 deletions build/websnark.js

Large diffs are not rendered by default.

202 changes: 143 additions & 59 deletions example/websnark.js

Large diffs are not rendered by default.

6,039 changes: 5,229 additions & 810 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"eslint-plugin-webassembly": "^1.8.4",
"mocha": "^6.1.4",
"package": "^1.0.1",
"snarkjs": "git+https://github.com/peppersec/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5",
"tornado-snarkjs": "git+https://github.com/peppersec/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5",
"wasmbuilder": "0.0.3"
},
"dependencies": {
Expand Down
7 changes: 5 additions & 2 deletions src/groth16.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ const bigInt = require("big-integer");
const groth16_wasm = require("../build/groth16_wasm.js");
const assert = require("assert");

const inBrowser = (typeof window !== "undefined");
const inBrowser = (typeof window !== "undefined") || process && process.env && process.env.FOR_BROWSER === "true";


let NodeWorker;
let NodeCrypto;

if (!inBrowser) {
NodeWorker = require("worker_threads").Worker;
NodeCrypto = require("crypto");
Expand Down Expand Up @@ -170,7 +173,7 @@ function thread(self) {
}

// We use the Object.assign approach for the backwards compatibility
// @params Number wasmInitialMemory
// @params Number wasmInitialMemory
async function build(params) {
const defaultParams = { wasmInitialMemory: 5000 };
Object.assign(defaultParams, params);
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/

const bigInt = require("big-integer");
const Circuit = require("snarkjs/src/circuit");
const bigInt2 = require("snarkjs/src/bigint");
const Circuit = require("tornado-snarkjs/src/circuit");
const bigInt2 = require("tornado-snarkjs/src/bigint");
const hexifyBigInts = require("../tools/stringifybigint").hexifyBigInts;
const unhexifyBigInts = require("../tools/stringifybigint").unhexifyBigInts;
const stringifyBigInts = require("../tools/stringifybigint").stringifyBigInts;
const unstringifyBigInts = require("../tools/stringifybigint").unstringifyBigInts;
const stringifyBigInts2 = require("snarkjs/src/stringifybigint").stringifyBigInts;
const unstringifyBigInts2 = require("snarkjs/src/stringifybigint").unstringifyBigInts;
const stringifyBigInts2 = require("tornado-snarkjs/src/stringifybigint").stringifyBigInts;
const unstringifyBigInts2 = require("tornado-snarkjs/src/stringifybigint").unstringifyBigInts;

function bigInt2BytesLE(_a, len) {
const b = Array(len);
Expand Down
4 changes: 2 additions & 2 deletions test/bn128.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require("assert");
const refBn128 = require("snarkjs").bn128;
const refBigInt = require("snarkjs").bigInt;
const refBn128 = require("tornado-snarkjs").bn128;
const refBigInt = require("tornado-snarkjs").bigInt;

const buildBn128 = require("../index.js").buildBn128;

Expand Down
4 changes: 2 additions & 2 deletions test/fft.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require("assert");
const refBn128 = require("snarkjs").bn128;
const refBigInt = require("snarkjs").bigInt;
const refBn128 = require("tornado-snarkjs").bn128;
const refBigInt = require("tornado-snarkjs").bigInt;

const buildBn128 = require("../index.js").buildBn128;

Expand Down
2 changes: 1 addition & 1 deletion test/groth16.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const assert = require("assert");
const fs = require("fs");
const path = require("path");
const snarkjs = require("snarkjs");
const snarkjs = require("tornado-snarkjs");

const buildGroth16 = require("../index.js").buildGroth16;

Expand Down