mirror of
https://github.com/tornadocash/websnark.git
synced 2025-02-17 07:26:19 +01:00
renamed from websnark to wasmsnark
This commit is contained in:
parent
59d8dad1fc
commit
7810d87114
@ -1,8 +1,4 @@
|
||||
module.exports = {
|
||||
"plugins": [
|
||||
"mocha",
|
||||
"webassembly"
|
||||
],
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true,
|
||||
@ -31,7 +27,6 @@ module.exports = {
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"mocha/no-exclusive-tests": "error"
|
||||
]
|
||||
}
|
||||
};
|
||||
|
14
README.md
14
README.md
@ -1,8 +1,8 @@
|
||||
# websnark
|
||||
# wasmsnark
|
||||
|
||||
A fast zkSnark proof and verifier and proof generator written in native Web Assembly.
|
||||
|
||||
websnark is used to generate zkSnark Proofs and verify the from the browser.
|
||||
wasmsnark is used to generate zkSnark Proofs and verify the from the browser.
|
||||
|
||||
This module generates highly optimized Web Assembly modules for the low level
|
||||
cryptographic primitives.
|
||||
@ -17,10 +17,10 @@ browsers.
|
||||
|
||||
|
||||
### BN128
|
||||
You just need to import the websnark_bn128.js found in the build directory.
|
||||
You just need to import the wasmsnark_bn128.js found in the build directory.
|
||||
|
||||
```html
|
||||
<script src="websnark_bn128.js" />
|
||||
<script src="wasmsnark_bn128.js" />
|
||||
```
|
||||
|
||||
This library has a single javascript function:
|
||||
@ -33,7 +33,7 @@ witness is a binary buffer with all the signals in binnary format. The buffer i
|
||||
|
||||
You can use the tool to build the binary file from the witness.json file generated by [snarkjs](https://github.com/iden3/snarkjs).
|
||||
|
||||
### IMPORTANT: Please be sure you run your setup with `--protocol groth` websnark only generates groth16 proofs!
|
||||
### IMPORTANT: Please be sure you run your setup with `--protocol groth` wasmsnark only generates groth16 proofs!
|
||||
|
||||
```
|
||||
node ../tools/buildwitness.js -i witness.json -o witness.bin
|
||||
@ -60,7 +60,7 @@ Here is a simple example of a web page that loads a key and a witness and genera
|
||||
<html>
|
||||
<header>
|
||||
</header>
|
||||
<script src="websnark_bn128.js"></script>
|
||||
<script src="wasmsnark_bn128.js"></script>
|
||||
<script>
|
||||
|
||||
var witness;
|
||||
@ -140,4 +140,4 @@ npm test
|
||||
|
||||
## License
|
||||
|
||||
websnark is part of the iden3 project copyright 2019 0KIMS association and published with GPL-3 license. Please check the COPYING file for more details.
|
||||
wasmsnark is part of the iden3 project copyright 2019 0KIMS association and published with GPL-3 license. Please check the COPYING file for more details.
|
||||
|
File diff suppressed because one or more lines are too long
@ -17,20 +17,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
@ -1272,7 +1272,8 @@ function toByteArray (b64) {
|
||||
? validLen - 4
|
||||
: validLen
|
||||
|
||||
for (var i = 0; i < len; i += 4) {
|
||||
var i
|
||||
for (i = 0; i < len; i += 4) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||||
@ -2043,6 +2044,10 @@ var bigInt = (function (undefined) {
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
if (exp.isNegative()) {
|
||||
exp = exp.multiply(Integer[-1]);
|
||||
base = base.modInv(mod);
|
||||
}
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
@ -2286,13 +2291,13 @@ var bigInt = (function (undefined) {
|
||||
};
|
||||
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
||||
|
||||
BigInteger.prototype.isProbablePrime = function (iterations) {
|
||||
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var t = iterations === undefined ? 5 : iterations;
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt.randBetween(2, n.minus(2)));
|
||||
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
@ -2524,17 +2529,18 @@ var bigInt = (function (undefined) {
|
||||
b = parseValue(b).abs();
|
||||
return a.divide(gcd(a, b)).multiply(b);
|
||||
}
|
||||
function randBetween(a, b) {
|
||||
function randBetween(a, b, rng) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
var usedRNG = rng || Math.random;
|
||||
var low = min(a, b), high = max(a, b);
|
||||
var range = high.subtract(low).add(1);
|
||||
if (range.isSmall) return low.add(Math.floor(Math.random() * range));
|
||||
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
||||
var digits = toBase(range, BASE).value;
|
||||
var result = [], restricted = true;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
var top = restricted ? digits[i] : BASE;
|
||||
var digit = truncate(Math.random() * top);
|
||||
var digit = truncate(usedRNG() * top);
|
||||
result.push(digit);
|
||||
if (digit < top) restricted = false;
|
||||
}
|
||||
@ -2802,7 +2808,7 @@ if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||
|
||||
//amd check
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("big-integer", [], function () {
|
||||
define( function () {
|
||||
return bigInt;
|
||||
});
|
||||
}
|
||||
@ -2821,6 +2827,10 @@ if (typeof define === "function" && define.amd) {
|
||||
|
||||
var base64 = require('base64-js')
|
||||
var ieee754 = require('ieee754')
|
||||
var customInspectSymbol =
|
||||
(typeof Symbol === 'function' && typeof Symbol.for === 'function')
|
||||
? Symbol.for('nodejs.util.inspect.custom')
|
||||
: null
|
||||
|
||||
exports.Buffer = Buffer
|
||||
exports.SlowBuffer = SlowBuffer
|
||||
@ -2857,7 +2867,9 @@ function typedArraySupport () {
|
||||
// Can typed array instances can be augmented?
|
||||
try {
|
||||
var arr = new Uint8Array(1)
|
||||
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
||||
var proto = { foo: function () { return 42 } }
|
||||
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(arr, proto)
|
||||
return arr.foo() === 42
|
||||
} catch (e) {
|
||||
return false
|
||||
@ -2886,7 +2898,7 @@ function createBuffer (length) {
|
||||
}
|
||||
// Return an augmented `Uint8Array` instance
|
||||
var buf = new Uint8Array(length)
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -2936,7 +2948,7 @@ function from (value, encodingOrOffset, length) {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw TypeError(
|
||||
throw new TypeError(
|
||||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||||
'or Array-like Object. Received type ' + (typeof value)
|
||||
)
|
||||
@ -2947,6 +2959,12 @@ function from (value, encodingOrOffset, length) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof SharedArrayBuffer !== 'undefined' &&
|
||||
(isInstance(value, SharedArrayBuffer) ||
|
||||
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
throw new TypeError(
|
||||
'The "value" argument must not be of type number. Received type number'
|
||||
@ -2988,8 +3006,8 @@ Buffer.from = function (value, encodingOrOffset, length) {
|
||||
|
||||
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
||||
// https://github.com/feross/buffer/pull/148
|
||||
Buffer.prototype.__proto__ = Uint8Array.prototype
|
||||
Buffer.__proto__ = Uint8Array
|
||||
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(Buffer, Uint8Array)
|
||||
|
||||
function assertSize (size) {
|
||||
if (typeof size !== 'number') {
|
||||
@ -3093,7 +3111,8 @@ function fromArrayBuffer (array, byteOffset, length) {
|
||||
}
|
||||
|
||||
// Return an augmented `Uint8Array` instance
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3415,6 +3434,9 @@ Buffer.prototype.inspect = function inspect () {
|
||||
if (this.length > max) str += ' ... '
|
||||
return '<Buffer ' + str + '>'
|
||||
}
|
||||
if (customInspectSymbol) {
|
||||
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
||||
}
|
||||
|
||||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||||
if (isInstance(target, Uint8Array)) {
|
||||
@ -3540,7 +3562,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||||
}
|
||||
}
|
||||
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
||||
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
||||
}
|
||||
|
||||
throw new TypeError('val must be string, number or Buffer')
|
||||
@ -3869,7 +3891,7 @@ function hexSlice (buf, start, end) {
|
||||
|
||||
var out = ''
|
||||
for (var i = start; i < end; ++i) {
|
||||
out += toHex(buf[i])
|
||||
out += hexSliceLookupTable[buf[i]]
|
||||
}
|
||||
return out
|
||||
}
|
||||
@ -3906,7 +3928,8 @@ Buffer.prototype.slice = function slice (start, end) {
|
||||
|
||||
var newBuf = this.subarray(start, end)
|
||||
// Return an augmented `Uint8Array` instance
|
||||
newBuf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
||||
|
||||
return newBuf
|
||||
}
|
||||
|
||||
@ -4395,6 +4418,8 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||||
}
|
||||
} else if (typeof val === 'number') {
|
||||
val = val & 255
|
||||
} else if (typeof val === 'boolean') {
|
||||
val = Number(val)
|
||||
}
|
||||
|
||||
// Invalid ranges are not set to a default, so can range check early.
|
||||
@ -4452,11 +4477,6 @@ function base64clean (str) {
|
||||
return str
|
||||
}
|
||||
|
||||
function toHex (n) {
|
||||
if (n < 16) return '0' + n.toString(16)
|
||||
return n.toString(16)
|
||||
}
|
||||
|
||||
function utf8ToBytes (string, units) {
|
||||
units = units || Infinity
|
||||
var codePoint
|
||||
@ -4587,6 +4607,20 @@ function numberIsNaN (obj) {
|
||||
return obj !== obj // eslint-disable-line no-self-compare
|
||||
}
|
||||
|
||||
// Create lookup table for `toString('hex')`
|
||||
// See: https://github.com/feross/buffer/issues/219
|
||||
var hexSliceLookupTable = (function () {
|
||||
var alphabet = '0123456789abcdef'
|
||||
var table = new Array(256)
|
||||
for (var i = 0; i < 16; ++i) {
|
||||
var i16 = i * 16
|
||||
for (var j = 0; j < 16; ++j) {
|
||||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||||
}
|
||||
}
|
||||
return table
|
||||
})()
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"base64-js":7,"buffer":9,"ieee754":10}],10:[function(require,module,exports){
|
||||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||||
@ -4957,20 +4991,20 @@ process.umask = function() { return 0; };
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
@ -5754,20 +5788,20 @@ module.exports = build;
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
@ -17,20 +17,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
@ -1277,7 +1277,8 @@ function toByteArray (b64) {
|
||||
? validLen - 4
|
||||
: validLen
|
||||
|
||||
for (var i = 0; i < len; i += 4) {
|
||||
var i
|
||||
for (i = 0; i < len; i += 4) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||||
@ -2048,6 +2049,10 @@ var bigInt = (function (undefined) {
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
if (exp.isNegative()) {
|
||||
exp = exp.multiply(Integer[-1]);
|
||||
base = base.modInv(mod);
|
||||
}
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
@ -2291,13 +2296,13 @@ var bigInt = (function (undefined) {
|
||||
};
|
||||
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
||||
|
||||
BigInteger.prototype.isProbablePrime = function (iterations) {
|
||||
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var t = iterations === undefined ? 5 : iterations;
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt.randBetween(2, n.minus(2)));
|
||||
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
@ -2529,17 +2534,18 @@ var bigInt = (function (undefined) {
|
||||
b = parseValue(b).abs();
|
||||
return a.divide(gcd(a, b)).multiply(b);
|
||||
}
|
||||
function randBetween(a, b) {
|
||||
function randBetween(a, b, rng) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
var usedRNG = rng || Math.random;
|
||||
var low = min(a, b), high = max(a, b);
|
||||
var range = high.subtract(low).add(1);
|
||||
if (range.isSmall) return low.add(Math.floor(Math.random() * range));
|
||||
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
||||
var digits = toBase(range, BASE).value;
|
||||
var result = [], restricted = true;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
var top = restricted ? digits[i] : BASE;
|
||||
var digit = truncate(Math.random() * top);
|
||||
var digit = truncate(usedRNG() * top);
|
||||
result.push(digit);
|
||||
if (digit < top) restricted = false;
|
||||
}
|
||||
@ -2807,7 +2813,7 @@ if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||
|
||||
//amd check
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("big-integer", [], function () {
|
||||
define( function () {
|
||||
return bigInt;
|
||||
});
|
||||
}
|
||||
@ -3395,6 +3401,10 @@ module.exports = {
|
||||
|
||||
var base64 = require('base64-js')
|
||||
var ieee754 = require('ieee754')
|
||||
var customInspectSymbol =
|
||||
(typeof Symbol === 'function' && typeof Symbol.for === 'function')
|
||||
? Symbol.for('nodejs.util.inspect.custom')
|
||||
: null
|
||||
|
||||
exports.Buffer = Buffer
|
||||
exports.SlowBuffer = SlowBuffer
|
||||
@ -3431,7 +3441,9 @@ function typedArraySupport () {
|
||||
// Can typed array instances can be augmented?
|
||||
try {
|
||||
var arr = new Uint8Array(1)
|
||||
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
||||
var proto = { foo: function () { return 42 } }
|
||||
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(arr, proto)
|
||||
return arr.foo() === 42
|
||||
} catch (e) {
|
||||
return false
|
||||
@ -3460,7 +3472,7 @@ function createBuffer (length) {
|
||||
}
|
||||
// Return an augmented `Uint8Array` instance
|
||||
var buf = new Uint8Array(length)
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3510,7 +3522,7 @@ function from (value, encodingOrOffset, length) {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw TypeError(
|
||||
throw new TypeError(
|
||||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||||
'or Array-like Object. Received type ' + (typeof value)
|
||||
)
|
||||
@ -3521,6 +3533,12 @@ function from (value, encodingOrOffset, length) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof SharedArrayBuffer !== 'undefined' &&
|
||||
(isInstance(value, SharedArrayBuffer) ||
|
||||
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
throw new TypeError(
|
||||
'The "value" argument must not be of type number. Received type number'
|
||||
@ -3562,8 +3580,8 @@ Buffer.from = function (value, encodingOrOffset, length) {
|
||||
|
||||
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
||||
// https://github.com/feross/buffer/pull/148
|
||||
Buffer.prototype.__proto__ = Uint8Array.prototype
|
||||
Buffer.__proto__ = Uint8Array
|
||||
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(Buffer, Uint8Array)
|
||||
|
||||
function assertSize (size) {
|
||||
if (typeof size !== 'number') {
|
||||
@ -3667,7 +3685,8 @@ function fromArrayBuffer (array, byteOffset, length) {
|
||||
}
|
||||
|
||||
// Return an augmented `Uint8Array` instance
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3989,6 +4008,9 @@ Buffer.prototype.inspect = function inspect () {
|
||||
if (this.length > max) str += ' ... '
|
||||
return '<Buffer ' + str + '>'
|
||||
}
|
||||
if (customInspectSymbol) {
|
||||
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
||||
}
|
||||
|
||||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||||
if (isInstance(target, Uint8Array)) {
|
||||
@ -4114,7 +4136,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||||
}
|
||||
}
|
||||
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
||||
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
||||
}
|
||||
|
||||
throw new TypeError('val must be string, number or Buffer')
|
||||
@ -4443,7 +4465,7 @@ function hexSlice (buf, start, end) {
|
||||
|
||||
var out = ''
|
||||
for (var i = start; i < end; ++i) {
|
||||
out += toHex(buf[i])
|
||||
out += hexSliceLookupTable[buf[i]]
|
||||
}
|
||||
return out
|
||||
}
|
||||
@ -4480,7 +4502,8 @@ Buffer.prototype.slice = function slice (start, end) {
|
||||
|
||||
var newBuf = this.subarray(start, end)
|
||||
// Return an augmented `Uint8Array` instance
|
||||
newBuf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
||||
|
||||
return newBuf
|
||||
}
|
||||
|
||||
@ -4969,6 +4992,8 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||||
}
|
||||
} else if (typeof val === 'number') {
|
||||
val = val & 255
|
||||
} else if (typeof val === 'boolean') {
|
||||
val = Number(val)
|
||||
}
|
||||
|
||||
// Invalid ranges are not set to a default, so can range check early.
|
||||
@ -5026,11 +5051,6 @@ function base64clean (str) {
|
||||
return str
|
||||
}
|
||||
|
||||
function toHex (n) {
|
||||
if (n < 16) return '0' + n.toString(16)
|
||||
return n.toString(16)
|
||||
}
|
||||
|
||||
function utf8ToBytes (string, units) {
|
||||
units = units || Infinity
|
||||
var codePoint
|
||||
@ -5161,6 +5181,20 @@ function numberIsNaN (obj) {
|
||||
return obj !== obj // eslint-disable-line no-self-compare
|
||||
}
|
||||
|
||||
// Create lookup table for `toString('hex')`
|
||||
// See: https://github.com/feross/buffer/issues/219
|
||||
var hexSliceLookupTable = (function () {
|
||||
var alphabet = '0123456789abcdef'
|
||||
var table = new Array(256)
|
||||
for (var i = 0; i < 16; ++i) {
|
||||
var i16 = i * 16
|
||||
for (var j = 0; j < 16; ++j) {
|
||||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||||
}
|
||||
}
|
||||
return table
|
||||
})()
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"base64-js":7,"buffer":13,"ieee754":14}],14:[function(require,module,exports){
|
||||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||||
@ -5531,20 +5565,20 @@ process.umask = function() { return 0; };
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
@ -6625,20 +6659,20 @@ module.exports = build;
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
5545
build/websnark.js
5545
build/websnark.js
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="websnark_bn128.js"></script>
|
||||
<script src="wasmsnark_bn128.js"></script>
|
||||
<script>
|
||||
|
||||
var witness;
|
||||
|
@ -17,20 +17,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
@ -1272,7 +1272,8 @@ function toByteArray (b64) {
|
||||
? validLen - 4
|
||||
: validLen
|
||||
|
||||
for (var i = 0; i < len; i += 4) {
|
||||
var i
|
||||
for (i = 0; i < len; i += 4) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||||
@ -2043,6 +2044,10 @@ var bigInt = (function (undefined) {
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
if (exp.isNegative()) {
|
||||
exp = exp.multiply(Integer[-1]);
|
||||
base = base.modInv(mod);
|
||||
}
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
@ -2286,13 +2291,13 @@ var bigInt = (function (undefined) {
|
||||
};
|
||||
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
||||
|
||||
BigInteger.prototype.isProbablePrime = function (iterations) {
|
||||
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var t = iterations === undefined ? 5 : iterations;
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt.randBetween(2, n.minus(2)));
|
||||
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
@ -2524,17 +2529,18 @@ var bigInt = (function (undefined) {
|
||||
b = parseValue(b).abs();
|
||||
return a.divide(gcd(a, b)).multiply(b);
|
||||
}
|
||||
function randBetween(a, b) {
|
||||
function randBetween(a, b, rng) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
var usedRNG = rng || Math.random;
|
||||
var low = min(a, b), high = max(a, b);
|
||||
var range = high.subtract(low).add(1);
|
||||
if (range.isSmall) return low.add(Math.floor(Math.random() * range));
|
||||
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
||||
var digits = toBase(range, BASE).value;
|
||||
var result = [], restricted = true;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
var top = restricted ? digits[i] : BASE;
|
||||
var digit = truncate(Math.random() * top);
|
||||
var digit = truncate(usedRNG() * top);
|
||||
result.push(digit);
|
||||
if (digit < top) restricted = false;
|
||||
}
|
||||
@ -2802,7 +2808,7 @@ if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||
|
||||
//amd check
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("big-integer", [], function () {
|
||||
define( function () {
|
||||
return bigInt;
|
||||
});
|
||||
}
|
||||
@ -2821,6 +2827,10 @@ if (typeof define === "function" && define.amd) {
|
||||
|
||||
var base64 = require('base64-js')
|
||||
var ieee754 = require('ieee754')
|
||||
var customInspectSymbol =
|
||||
(typeof Symbol === 'function' && typeof Symbol.for === 'function')
|
||||
? Symbol.for('nodejs.util.inspect.custom')
|
||||
: null
|
||||
|
||||
exports.Buffer = Buffer
|
||||
exports.SlowBuffer = SlowBuffer
|
||||
@ -2857,7 +2867,9 @@ function typedArraySupport () {
|
||||
// Can typed array instances can be augmented?
|
||||
try {
|
||||
var arr = new Uint8Array(1)
|
||||
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
||||
var proto = { foo: function () { return 42 } }
|
||||
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(arr, proto)
|
||||
return arr.foo() === 42
|
||||
} catch (e) {
|
||||
return false
|
||||
@ -2886,7 +2898,7 @@ function createBuffer (length) {
|
||||
}
|
||||
// Return an augmented `Uint8Array` instance
|
||||
var buf = new Uint8Array(length)
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -2936,7 +2948,7 @@ function from (value, encodingOrOffset, length) {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw TypeError(
|
||||
throw new TypeError(
|
||||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||||
'or Array-like Object. Received type ' + (typeof value)
|
||||
)
|
||||
@ -2947,6 +2959,12 @@ function from (value, encodingOrOffset, length) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof SharedArrayBuffer !== 'undefined' &&
|
||||
(isInstance(value, SharedArrayBuffer) ||
|
||||
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
throw new TypeError(
|
||||
'The "value" argument must not be of type number. Received type number'
|
||||
@ -2988,8 +3006,8 @@ Buffer.from = function (value, encodingOrOffset, length) {
|
||||
|
||||
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
||||
// https://github.com/feross/buffer/pull/148
|
||||
Buffer.prototype.__proto__ = Uint8Array.prototype
|
||||
Buffer.__proto__ = Uint8Array
|
||||
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(Buffer, Uint8Array)
|
||||
|
||||
function assertSize (size) {
|
||||
if (typeof size !== 'number') {
|
||||
@ -3093,7 +3111,8 @@ function fromArrayBuffer (array, byteOffset, length) {
|
||||
}
|
||||
|
||||
// Return an augmented `Uint8Array` instance
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3415,6 +3434,9 @@ Buffer.prototype.inspect = function inspect () {
|
||||
if (this.length > max) str += ' ... '
|
||||
return '<Buffer ' + str + '>'
|
||||
}
|
||||
if (customInspectSymbol) {
|
||||
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
||||
}
|
||||
|
||||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||||
if (isInstance(target, Uint8Array)) {
|
||||
@ -3540,7 +3562,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||||
}
|
||||
}
|
||||
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
||||
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
||||
}
|
||||
|
||||
throw new TypeError('val must be string, number or Buffer')
|
||||
@ -3869,7 +3891,7 @@ function hexSlice (buf, start, end) {
|
||||
|
||||
var out = ''
|
||||
for (var i = start; i < end; ++i) {
|
||||
out += toHex(buf[i])
|
||||
out += hexSliceLookupTable[buf[i]]
|
||||
}
|
||||
return out
|
||||
}
|
||||
@ -3906,7 +3928,8 @@ Buffer.prototype.slice = function slice (start, end) {
|
||||
|
||||
var newBuf = this.subarray(start, end)
|
||||
// Return an augmented `Uint8Array` instance
|
||||
newBuf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
||||
|
||||
return newBuf
|
||||
}
|
||||
|
||||
@ -4395,6 +4418,8 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||||
}
|
||||
} else if (typeof val === 'number') {
|
||||
val = val & 255
|
||||
} else if (typeof val === 'boolean') {
|
||||
val = Number(val)
|
||||
}
|
||||
|
||||
// Invalid ranges are not set to a default, so can range check early.
|
||||
@ -4452,11 +4477,6 @@ function base64clean (str) {
|
||||
return str
|
||||
}
|
||||
|
||||
function toHex (n) {
|
||||
if (n < 16) return '0' + n.toString(16)
|
||||
return n.toString(16)
|
||||
}
|
||||
|
||||
function utf8ToBytes (string, units) {
|
||||
units = units || Infinity
|
||||
var codePoint
|
||||
@ -4587,6 +4607,20 @@ function numberIsNaN (obj) {
|
||||
return obj !== obj // eslint-disable-line no-self-compare
|
||||
}
|
||||
|
||||
// Create lookup table for `toString('hex')`
|
||||
// See: https://github.com/feross/buffer/issues/219
|
||||
var hexSliceLookupTable = (function () {
|
||||
var alphabet = '0123456789abcdef'
|
||||
var table = new Array(256)
|
||||
for (var i = 0; i < 16; ++i) {
|
||||
var i16 = i * 16
|
||||
for (var j = 0; j < 16; ++j) {
|
||||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||||
}
|
||||
}
|
||||
return table
|
||||
})()
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"base64-js":7,"buffer":9,"ieee754":10}],10:[function(require,module,exports){
|
||||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||||
@ -4957,20 +4991,20 @@ process.umask = function() { return 0; };
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
@ -5754,20 +5788,20 @@ module.exports = build;
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
@ -2,7 +2,7 @@
|
||||
<head>
|
||||
<script src='crypto_lib.js'></script>
|
||||
<script src='verifier.js'></script>
|
||||
<script src='websnark_mnt6753.js'></script>
|
||||
<script src='wasmsnark_mnt6753.js'></script>
|
||||
<script type="text/javascript">
|
||||
/* globals window, document */
|
||||
|
||||
|
@ -17,20 +17,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
@ -1277,7 +1277,8 @@ function toByteArray (b64) {
|
||||
? validLen - 4
|
||||
: validLen
|
||||
|
||||
for (var i = 0; i < len; i += 4) {
|
||||
var i
|
||||
for (i = 0; i < len; i += 4) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||||
@ -2048,6 +2049,10 @@ var bigInt = (function (undefined) {
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
if (exp.isNegative()) {
|
||||
exp = exp.multiply(Integer[-1]);
|
||||
base = base.modInv(mod);
|
||||
}
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
@ -2291,13 +2296,13 @@ var bigInt = (function (undefined) {
|
||||
};
|
||||
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
||||
|
||||
BigInteger.prototype.isProbablePrime = function (iterations) {
|
||||
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var t = iterations === undefined ? 5 : iterations;
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt.randBetween(2, n.minus(2)));
|
||||
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
@ -2529,17 +2534,18 @@ var bigInt = (function (undefined) {
|
||||
b = parseValue(b).abs();
|
||||
return a.divide(gcd(a, b)).multiply(b);
|
||||
}
|
||||
function randBetween(a, b) {
|
||||
function randBetween(a, b, rng) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
var usedRNG = rng || Math.random;
|
||||
var low = min(a, b), high = max(a, b);
|
||||
var range = high.subtract(low).add(1);
|
||||
if (range.isSmall) return low.add(Math.floor(Math.random() * range));
|
||||
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
||||
var digits = toBase(range, BASE).value;
|
||||
var result = [], restricted = true;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
var top = restricted ? digits[i] : BASE;
|
||||
var digit = truncate(Math.random() * top);
|
||||
var digit = truncate(usedRNG() * top);
|
||||
result.push(digit);
|
||||
if (digit < top) restricted = false;
|
||||
}
|
||||
@ -2807,7 +2813,7 @@ if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||
|
||||
//amd check
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("big-integer", [], function () {
|
||||
define( function () {
|
||||
return bigInt;
|
||||
});
|
||||
}
|
||||
@ -3395,6 +3401,10 @@ module.exports = {
|
||||
|
||||
var base64 = require('base64-js')
|
||||
var ieee754 = require('ieee754')
|
||||
var customInspectSymbol =
|
||||
(typeof Symbol === 'function' && typeof Symbol.for === 'function')
|
||||
? Symbol.for('nodejs.util.inspect.custom')
|
||||
: null
|
||||
|
||||
exports.Buffer = Buffer
|
||||
exports.SlowBuffer = SlowBuffer
|
||||
@ -3431,7 +3441,9 @@ function typedArraySupport () {
|
||||
// Can typed array instances can be augmented?
|
||||
try {
|
||||
var arr = new Uint8Array(1)
|
||||
arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
|
||||
var proto = { foo: function () { return 42 } }
|
||||
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(arr, proto)
|
||||
return arr.foo() === 42
|
||||
} catch (e) {
|
||||
return false
|
||||
@ -3460,7 +3472,7 @@ function createBuffer (length) {
|
||||
}
|
||||
// Return an augmented `Uint8Array` instance
|
||||
var buf = new Uint8Array(length)
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3510,7 +3522,7 @@ function from (value, encodingOrOffset, length) {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw TypeError(
|
||||
throw new TypeError(
|
||||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||||
'or Array-like Object. Received type ' + (typeof value)
|
||||
)
|
||||
@ -3521,6 +3533,12 @@ function from (value, encodingOrOffset, length) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof SharedArrayBuffer !== 'undefined' &&
|
||||
(isInstance(value, SharedArrayBuffer) ||
|
||||
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
throw new TypeError(
|
||||
'The "value" argument must not be of type number. Received type number'
|
||||
@ -3562,8 +3580,8 @@ Buffer.from = function (value, encodingOrOffset, length) {
|
||||
|
||||
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
||||
// https://github.com/feross/buffer/pull/148
|
||||
Buffer.prototype.__proto__ = Uint8Array.prototype
|
||||
Buffer.__proto__ = Uint8Array
|
||||
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
||||
Object.setPrototypeOf(Buffer, Uint8Array)
|
||||
|
||||
function assertSize (size) {
|
||||
if (typeof size !== 'number') {
|
||||
@ -3667,7 +3685,8 @@ function fromArrayBuffer (array, byteOffset, length) {
|
||||
}
|
||||
|
||||
// Return an augmented `Uint8Array` instance
|
||||
buf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
@ -3989,6 +4008,9 @@ Buffer.prototype.inspect = function inspect () {
|
||||
if (this.length > max) str += ' ... '
|
||||
return '<Buffer ' + str + '>'
|
||||
}
|
||||
if (customInspectSymbol) {
|
||||
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
||||
}
|
||||
|
||||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||||
if (isInstance(target, Uint8Array)) {
|
||||
@ -4114,7 +4136,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||||
}
|
||||
}
|
||||
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
||||
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
||||
}
|
||||
|
||||
throw new TypeError('val must be string, number or Buffer')
|
||||
@ -4443,7 +4465,7 @@ function hexSlice (buf, start, end) {
|
||||
|
||||
var out = ''
|
||||
for (var i = start; i < end; ++i) {
|
||||
out += toHex(buf[i])
|
||||
out += hexSliceLookupTable[buf[i]]
|
||||
}
|
||||
return out
|
||||
}
|
||||
@ -4480,7 +4502,8 @@ Buffer.prototype.slice = function slice (start, end) {
|
||||
|
||||
var newBuf = this.subarray(start, end)
|
||||
// Return an augmented `Uint8Array` instance
|
||||
newBuf.__proto__ = Buffer.prototype
|
||||
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
||||
|
||||
return newBuf
|
||||
}
|
||||
|
||||
@ -4969,6 +4992,8 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||||
}
|
||||
} else if (typeof val === 'number') {
|
||||
val = val & 255
|
||||
} else if (typeof val === 'boolean') {
|
||||
val = Number(val)
|
||||
}
|
||||
|
||||
// Invalid ranges are not set to a default, so can range check early.
|
||||
@ -5026,11 +5051,6 @@ function base64clean (str) {
|
||||
return str
|
||||
}
|
||||
|
||||
function toHex (n) {
|
||||
if (n < 16) return '0' + n.toString(16)
|
||||
return n.toString(16)
|
||||
}
|
||||
|
||||
function utf8ToBytes (string, units) {
|
||||
units = units || Infinity
|
||||
var codePoint
|
||||
@ -5161,6 +5181,20 @@ function numberIsNaN (obj) {
|
||||
return obj !== obj // eslint-disable-line no-self-compare
|
||||
}
|
||||
|
||||
// Create lookup table for `toString('hex')`
|
||||
// See: https://github.com/feross/buffer/issues/219
|
||||
var hexSliceLookupTable = (function () {
|
||||
var alphabet = '0123456789abcdef'
|
||||
var table = new Array(256)
|
||||
for (var i = 0; i < 16; ++i) {
|
||||
var i16 = i * 16
|
||||
for (var j = 0; j < 16; ++j) {
|
||||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||||
}
|
||||
}
|
||||
return table
|
||||
})()
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"base64-js":7,"buffer":13,"ieee754":14}],14:[function(require,module,exports){
|
||||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||||
@ -5531,20 +5565,20 @@ process.umask = function() { return 0; };
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
@ -6625,20 +6659,20 @@ module.exports = build;
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
8
index.js
8
index.js
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports.buildF1 = require("./src/f1.js");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals window */
|
||||
|
1842
package-lock.json
generated
1842
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "websnark",
|
||||
"version": "0.0.5",
|
||||
"description": "big integer library to work in Zq",
|
||||
"name": "wasmsnark",
|
||||
"version": "0.0.7",
|
||||
"description": "zksnark wasm library",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha --experimental-worker",
|
||||
"buildwasm": "node tools/buildwasm.js",
|
||||
"build_bn128": "node tools/buildwasm_bn128.js; browserify main_bn128.js -o build/websnark_bn128.js --exclude worker_threads --exclude crypto; cp build/websnark_bn128.js example/bn128/websnark_bn128.js",
|
||||
"build_mnt6753": "node tools/buildwasm_mnt6753.js; browserify main_mnt6753.js -o build/websnark_mnt6753.js --exclude worker_threads --exclude crypto; cp build/websnark_mnt6753.js example/mnt6753/websnark_mnt6753.js"
|
||||
"build_bn128": "node tools/buildwasm_bn128.js; browserify main_bn128.js -o build/wasmsnark_bn128.js --exclude worker_threads --exclude crypto; cp build/wasmsnark_bn128.js example/bn128/wasmsnark_bn128.js",
|
||||
"build_mnt6753": "node tools/buildwasm_mnt6753.js; browserify main_mnt6753.js -o build/wasmsnark_mnt6753.js --exclude worker_threads --exclude crypto; cp build/wasmsnark_mnt6753.js example/mnt6753/wasmsnark_mnt6753.js"
|
||||
},
|
||||
"keywords": [
|
||||
"bigint",
|
||||
@ -23,13 +22,11 @@
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/iden3/websnark.git"
|
||||
"url": "https://github.com/iden3/wasmsnark.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"eslint": "^5.14.0",
|
||||
"eslint-plugin-mocha": "^5.3.0",
|
||||
"eslint-plugin-webassembly": "^1.8.4",
|
||||
"eslint": "^6.8.0",
|
||||
"mocha": "^6.1.4",
|
||||
"package": "^1.0.1",
|
||||
"snarkjs": "^0.1.12",
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const buildTimesScalar = require("../build_timesscalar");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const buildExp = require("./build_timesscalar");
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const buildExp = require("./build_timesscalar");
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const utils = require("./utils.js");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildMem(module, prefix, prefixField) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildMulAcc(windowSize, prefix, curvePrefix, scalarPrefix) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildMultiexp(module, prefix, curvePrefix, pointFieldPrefix, scalarPrefix) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildPol(module, prefix, prefixField) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildTimesScalar(module, fnName, elementLen, opAB, opAA, opCopy, opInit) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module.exports = function buildTimesScalarNAF(module, fnName, elementLen, opAB, opAA, opAmB, opCopy, opInit) {
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly */
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly, Blob, Worker, navigator, Promise, window */
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* globals WebAssembly */
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 0KIMS association.
|
||||
|
||||
This file is part of websnark (Web Assembly zkSnark Prover).
|
||||
This file is part of wasmsnark (Web Assembly zkSnark Prover).
|
||||
|
||||
websnark is a free software: you can redistribute it and/or modify it
|
||||
wasmsnark is a free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
websnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
wasmsnark is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with websnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
along with wasmsnark. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
Loading…
x
Reference in New Issue
Block a user