Browse Source

Negative numbers and fix in comparator

master
Jordi Baylina 4 years ago
parent
commit
273ab79665
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
3 changed files with 4 additions and 8 deletions
  1. +3
    -4
      circuits/compconstant.circom
  2. +1
    -1
      circuits/pointbits.circom
  3. +0
    -3
      test/smtprocessor.js

+ 3
- 4
circuits/compconstant.circom

@ -46,12 +46,11 @@ template CompConstant(ct) {
slsb = in[i*2]; slsb = in[i*2];
smsb = in[i*2+1]; smsb = in[i*2+1];
if ((cmsb==0)&(clsb==0)) {
if ((cmsb==0)&&(clsb==0)) {
parts[i] <== -b*smsb*slsb + b*smsb + b*slsb; 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; 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; parts[i] <== b*smsb*slsb - a*smsb + a;
} else { } else {
parts[i] <== -a*smsb*slsb + a; parts[i] <== -a*smsb*slsb + a;

+ 1
- 1
circuits/pointbits.circom

@ -61,7 +61,7 @@ function sqrt(n) {
r = r*b; r = r*b;
} }
if (r > ((-1) >> 1)) {
if (r < 0 ) {
r = -r; r = -r;
} }

+ 0
- 3
test/smtprocessor.js

@ -104,8 +104,6 @@ describe("SMT Processor test", function () {
await testInsert(tree, key, value, circuit); await testInsert(tree, key, value, circuit);
}); });
it("Should remove an element", async () => { it("Should remove an element", async () => {
await testDelete(tree, 111, circuit); await testDelete(tree, 111, circuit);
await testDelete(tree, 333, circuit); await testDelete(tree, 333, circuit);
@ -207,5 +205,4 @@ describe("SMT Processor test", function () {
await testUpdate(tree1, 9, 999, circuit); await testUpdate(tree1, 9, 999, circuit);
await testUpdate(tree1, 32, 323232, circuit); await testUpdate(tree1, 32, 323232, circuit);
}); });
}); });

Loading…
Cancel
Save