miracl / core

MIRACL Core
Apache License 2.0
199 stars 68 forks source link

JS library doesn't compile #30

Closed chenyan2002 closed 2 years ago

chenyan2002 commented 3 years ago

I noticed there is no CI running for JavaScript, and the code there doesn't compile.

Most of the errors are easy to fix, but I don't know the right fix for islarger function in fp.js. (fx doesn't exist)

--- a/javascript/src/bls.js
+++ b/javascript/src/bls.js
@@ -56,7 +56,7 @@ var BLS = function(ctx) {
             return b;
         },

-        stringtobytes: function(str) {
+        stringtobytes: function(s) {
             var b = [],
                 i;
--- a/javascript/src/ecp2.js
+++ b/javascript/src/ecp2.js
@@ -179,7 +179,7 @@ var ECP2 = function(ctx) {
             W.affine();
                    W.x.toBytes(t);

-            if ((ctx.FP.MODBITS-1)%8<=4 && ECP.ALLOW_ALT_COMPRESS) alt=true;
+            if ((ctx.FP.MODBITS-1)%8<=4 && ctx.ECP.ALLOW_ALT_COMPRESS) alt=true;
@@ -628,7 +628,7 @@ var ECP2 = function(ctx) {
         var typ= b[0];
         var P = new ECP2();

-        if ((ctx.FP.MODBITS-1)%8<=4 && ECP.ALLOW_ALT_COMPRESS) alt=true;
+        if ((ctx.FP.MODBITS-1)%8<=4 && ctx.ECP.ALLOW_ALT_COMPRESS) alt=true;
--- a/javascript/src/fp2.js
+++ b/javascript/src/fp2.js
@@ -55,9 +55,9 @@ var FP2 = function(ctx) {

         islarger: function() {
             if (this.iszilch()) return 0;
-            var cmp=this.b.larger();
+            var cmp=this.b.islarger();
             if (cmp!=0) return cmp;
-            return this.a.larger();
+            return this.a.islarger();
         },
mcarrickscott commented 3 years ago

Thanks, you are right, will fix