includes/clientside/static/enanomath.js
changeset 582 a38876c0793c
parent 581 5e8fd89c02ea
child 583 c97d5f0d6636
equal deleted inserted replaced
581:5e8fd89c02ea 582:a38876c0793c
     1 /*
       
     2  * EnanoMath, an abstraction layer for big-integer (arbitrary precision)
       
     3  * mathematics.
       
     4  */
       
     5 
       
     6 var EnanoMathLayers = {};
       
     7 
       
     8 // EnanoMath layer: Leemon (frontend to BigInt library by Leemon Baird)
       
     9 
       
    10 EnanoMathLayers.Leemon = {
       
    11   Base: 10,
       
    12   PowMod: function(a, b, c)
       
    13   {
       
    14     a = str2bigInt(a, this.Base);
       
    15     b = str2bigInt(b, this.Base);
       
    16     c = str2bigInt(c, this.Base);
       
    17     var result = powMod(a, b, c);
       
    18     result = bigInt2str(result, this.Base);
       
    19     return result;
       
    20   },
       
    21   RandomInt: function(bits)
       
    22   {
       
    23     var result = randBigInt(bits);
       
    24     return bigInt2str(result, this.Base);
       
    25   }
       
    26 }
       
    27 
       
    28 var EnanoMath = EnanoMathLayers.Leemon;
       
    29