Class sjcl.bn
Defined in: bn.js.
Constructor Attributes  Constructor Name and Description 

sjcl.bn(it)

Method Attributes  Method Name and Description 

add(that)
this + that.


addM(that)
this += that.


Return the length in bits, rounded up to the nearest byte.


Constanttime normalize.


doubleM()
this *= 2.


equals(that)
Returns true if "this" and "that" are equal.


<static> 
sjcl.bn.fromBits(bits)

Reduce and normalize.


getLimb(i)
Get the i'th limb of this, zero if i is too large.


greaterEquals(that)
Constant time comparison function.


halveM()
this /= 2, rounded down.


initWith(it)
Initializes this with it, either as a bn, a number, or a hex string.


inverseMod(p)
return inverse mod prime p.


mul(that)
this * that.


mulmod(that, N)
this * that mod N


Propagate carries.


power(l)
this ^ n.


powermod(x, N)
this ^ x mod N


<static> 
sjcl.bn.ppr.fullReduce()
mostly constanttime, very expensive full reduction.

<static> 
sjcl.bn.ppr.inverse()

<static> 
sjcl.bn.ppr.reduce()
Approximate reduction mod p.

<static> 
sjcl.bn.pseudoMersennePrime(exponent, coeff)
Creates a new subclass of bn, based on reduction modulo a pseudoMersenne prime,
i.e.

reduce()
Reduce mod a modulus.


square()
this ^ 2.


sub(that)
this  that.


subM(that)
this = that.


toBits(len)
Serialize to a bit array


toString()
Convert to a hex string.

Method Detail
add(that)
this + that. Does not normalize.
 Parameters:
 that
addM(that)
this += that. Does not normalize.
 Parameters:
 that
bitLength()
Return the length in bits, rounded up to the nearest byte.
cnormalize()
Constanttime normalize. Does not allocate additional space.
doubleM()
this *= 2. Requires normalized; ends up normalized.
equals(that)
Returns true if "this" and "that" are equal. Calls fullReduce().
Equality test is in constant time.
 Parameters:
 that
<static>
sjcl.bn.fromBits(bits)
 Parameters:
 bits
fullReduce()
Reduce and normalize.
getLimb(i)
Get the i'th limb of this, zero if i is too large.
 Parameters:
 i
greaterEquals(that)
Constant time comparison function.
Returns 1 if this >= that, or zero otherwise.
 Parameters:
 that
halveM()
this /= 2, rounded down. Requires normalized; ends up normalized.
initWith(it)
Initializes this with it, either as a bn, a number, or a hex string.
 Parameters:
 it
inverseMod(p)
return inverse mod prime p. p must be odd. Binary extended Euclidean algorithm mod p.
 Parameters:
 p
mul(that)
this * that. Normalizes and reduces.
 Parameters:
 that
mulmod(that, N)
this * that mod N
 Parameters:
 that
 N
normalize()
Propagate carries.
power(l)
this ^ n. Uses squareandmultiply. Normalizes and reduces.
 Parameters:
 l
powermod(x, N)
this ^ x mod N
 Parameters:
 x
 N
<static>
sjcl.bn.ppr.fullReduce()
mostly constanttime, very expensive full reduction.
<static>
sjcl.bn.ppr.inverse()
<static>
sjcl.bn.ppr.reduce()
Approximate reduction mod p. May leave a number which is negative or slightly larger than p.
<static>
sjcl.bn.pseudoMersennePrime(exponent, coeff)
Creates a new subclass of bn, based on reduction modulo a pseudoMersenne prime,
i.e. a prime of the form 2^e + sum(a * 2^b),where the sum is negative and sparse.
 Parameters:
 exponent
 coeff
reduce()
Reduce mod a modulus. Stubbed for subclassing.
square()
this ^ 2. Normalizes and reduces.
sub(that)
this  that. Does not normalize.
 Parameters:
 that
subM(that)
this = that. Does not normalize.
 Parameters:
 that
toBits(len)
Serialize to a bit array
 Parameters:
 len
toString()
Convert to a hex string.