# Class: bn

## sjcl.bn

#### new bn()

Constructs a new bignum from another bignum, a number or a hex string.
Source:

Source:

### Methods

• {
Source:

#### (static) ppr.fullReduce()

mostly constant-time, very expensive full reduction.
• {
Source:

• {
Source:

#### (static) ppr.reduce()

Approximate reduction mod p. May leave a number which is negative or slightly larger than p.
• {
Source:

#### (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.
Source:

this + that. Does not normalize.
Source:

this += that. Does not normalize.
Source:

#### bitLength()

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

#### cnormalize()

Constant-time normalize. Does not allocate additional space.
Source:

#### doubleM()

this *= 2. Requires normalized; ends up normalized.
Source:

#### equals()

Returns true if "this" and "that" are equal. Calls fullReduce(). Equality test is in constant time.
Source:

#### fullReduce()

Reduce and normalize.
Source:

#### getLimb()

Get the i'th limb of this, zero if i is too large.
Source:

#### greaterEquals()

Constant time comparison function. Returns 1 if this >= that, or zero otherwise.
Source:

#### halveM()

this /= 2, rounded down. Requires normalized; ends up normalized.
Source:

#### initWith()

Initializes this with it, either as a bn, a number, or a hex string.
Source:

#### inverseMod()

return inverse mod prime p. p must be odd. Binary extended Euclidean algorithm mod p.
Source:

#### montpowermod()

this ^ x mod N with Montomery reduction
Source:

#### mul()

this * that. Normalizes and reduces.
Source:

#### mulmod()

this * that mod N
Source:

#### normalize()

Propagate carries.
Source:

#### power()

this ^ n. Uses square-and-multiply. Normalizes and reduces.
Source:

this ^ x mod N
Source:

#### reduce()

Reduce mod a modulus. Stubbed for subclassing.
Source:

#### square()

this ^ 2. Normalizes and reduces.
Source:

#### sub()

this - that. Does not normalize.
Source:

#### subM()

this -= that. Does not normalize.
Source:

#### toBits()

Serialize to a bit array
Source:

#### toString()

Convert to a hex string.
Source: