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