arnaucube
arnaucube/snarkjsPublic Self-hosted repository
Fix 0x parser in old versions of node
Jordi Baylina jordi@baylina.cat
Thu, 25 Oct 2018 09:42:49 +0200
commit

f122fa202fda2c7bf334f35ccf3e4d2af1122fb1

parent

e73706bacb17a24dd52d0376a3137f1cddcdce15

2 files changed, 11 insertions(+), 1 deletions(-)

jump to
M cli.js → cli.js

          
M src/bigint.js → src/bigint.js

@@ -206,7 +206,17 @@ };

} else { - wBigInt = bigInt; + var oldProto = bigInt.prototype; + wBigInt = function(a) { + if ((typeof a == "string") && (a.slice(0,2) == "0x")) { + return bigInt(a.slice(2), 16); + } else { + return bigInt(a); + } + }; + wBigInt.one = bigInt.one; + wBigInt.zero = bigInt.zero; + wBigInt.prototype = oldProto; // Affine wBigInt.genAffine = (q) => {