Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "snarkjs", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "zkSNARKs implementation in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -172,2 +172,6 @@ /* | ||
wBigInt.prototype.div = function(c) { | ||
return this / c; | ||
}; | ||
wBigInt.prototype.mod = function(c) { | ||
@@ -178,3 +182,13 @@ return this % c; | ||
wBigInt.prototype.modPow = function(e, m) { | ||
return this ** e % m; | ||
let acc = wBigInt.one; | ||
let exp = this; | ||
let rem = e; | ||
while (rem) { | ||
if (rem & wBigInt.one) { | ||
acc = (acc * exp) %m; | ||
} | ||
exp = (exp * exp) % m; | ||
rem = rem >> wBigInt.one; | ||
} | ||
return acc; | ||
}; | ||
@@ -223,2 +237,6 @@ | ||
wBigInt.prototype.div = function(c) { | ||
return this.divide(c); | ||
}; | ||
// Affine | ||
@@ -438,4 +456,27 @@ wBigInt.genAffine = (q) => { | ||
wBigInt.leBuff2int = function(buff) { | ||
let res = wBigInt.zero; | ||
for (let i=0; i<buff.length; i++) { | ||
const n = wBigInt(buff[i]); | ||
res = res.add(n.shl(i*8)); | ||
} | ||
return res; | ||
}; | ||
wBigInt.leInt2Buff = function(n, len) { | ||
let r = n; | ||
let o =0; | ||
const buff = Buffer.alloc(len); | ||
while ((r.greater(wBigInt.zero))&&(o<buff.length)) { | ||
let c = Number(r.and(wBigInt("255"))); | ||
buff[o] = c; | ||
o++; | ||
r = r.shr(8); | ||
} | ||
if (r.greater(wBigInt.zero)) throw new Error("Number does not feed in buffer"); | ||
return buff; | ||
}; | ||
module.exports = wBigInt; | ||
@@ -55,3 +55,3 @@ /* | ||
if (typeof(ctx.witness[idx]) == "undefined") { | ||
throw new Error("Input Signal not assigned: " + circuit.signalNames(i)); | ||
throw new Error("Input Signal not assigned: " + circuit.signalNames(idx)); | ||
} | ||
@@ -58,0 +58,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443581
6346