From 2fa9503ad671da991816f94b3e42cbcaada7318b Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Sun, 15 Sep 2019 10:49:19 +0200 Subject: [PATCH] better info in runtime constraint assertion --- src/bigint.js | 5 +++++ src/calculateWitness.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bigint.js b/src/bigint.js index b2c594c..54bfac8 100644 --- a/src/bigint.js +++ b/src/bigint.js @@ -226,6 +226,11 @@ if (typeof(BigInt) != "undefined") { return this != b; }; + wBigInt.prototype.toJSNumber = function() { + return Number(this); + }; + + } else { var oldProto = bigInt.prototype; diff --git a/src/calculateWitness.js b/src/calculateWitness.js index 0b33615..25044d0 100644 --- a/src/calculateWitness.js +++ b/src/calculateWitness.js @@ -223,11 +223,11 @@ class RTCtx { return this.witness[sId]; } - assert(a,b) { + assert(a,b,errStr) { const ba = bigInt(a); const bb = bigInt(b); if (!ba.equals(bb)) { - throw new Error("Constraint doesn't match: " + ba.toString() + " != " + bb.toString()); + throw new Error("Constraint doesn't match "+ this.currentComponent+": "+ errStr + " -> "+ ba.toString() + " != " + bb.toString()); } } }