From 273ab7966526a7be7821d18e96c49acc4973a087 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Mon, 16 Mar 2020 20:41:11 +0100 Subject: [PATCH] Negative numbers and fix in comparator --- circuits/compconstant.circom | 7 +++---- circuits/pointbits.circom | 2 +- test/smtprocessor.js | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/circuits/compconstant.circom b/circuits/compconstant.circom index 96a6f1b..e7fb3f0 100644 --- a/circuits/compconstant.circom +++ b/circuits/compconstant.circom @@ -46,12 +46,11 @@ template CompConstant(ct) { slsb = in[i*2]; smsb = in[i*2+1]; - - if ((cmsb==0)&(clsb==0)) { + if ((cmsb==0)&&(clsb==0)) { parts[i] <== -b*smsb*slsb + b*smsb + b*slsb; - } else if ((cmsb==0)&(clsb==1)) { + } else if ((cmsb==0)&&(clsb==1)) { parts[i] <== a*smsb*slsb - a*slsb + b*smsb - a*smsb + a; - } else if ((cmsb==1)&(clsb==0)) { + } else if ((cmsb==1)&&(clsb==0)) { parts[i] <== b*smsb*slsb - a*smsb + a; } else { parts[i] <== -a*smsb*slsb + a; diff --git a/circuits/pointbits.circom b/circuits/pointbits.circom index ec4d2e7..9084a8e 100644 --- a/circuits/pointbits.circom +++ b/circuits/pointbits.circom @@ -61,7 +61,7 @@ function sqrt(n) { r = r*b; } - if (r > ((-1) >> 1)) { + if (r < 0 ) { r = -r; } diff --git a/test/smtprocessor.js b/test/smtprocessor.js index 8b418e5..8467073 100644 --- a/test/smtprocessor.js +++ b/test/smtprocessor.js @@ -104,8 +104,6 @@ describe("SMT Processor test", function () { await testInsert(tree, key, value, circuit); }); - - it("Should remove an element", async () => { await testDelete(tree, 111, circuit); await testDelete(tree, 333, circuit); @@ -207,5 +205,4 @@ describe("SMT Processor test", function () { await testUpdate(tree1, 9, 999, circuit); await testUpdate(tree1, 32, 323232, circuit); }); - });