includes/clientside/static/enanomath.js
changeset 436 242353360e37
equal deleted inserted replaced
435:a434d60e525d 436:242353360e37
       
     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