Hierarchy

  • BN

Constructors

  • Parameters

    • number: string | number | BN | number[] | Uint8Array | Buffer
    • Optional base: number | "hex"
    • Optional endian: Endianness

    Returns BN

  • Parameters

    • number: string | number | BN | number[] | Uint8Array | Buffer
    • Optional endian: Endianness

    Returns BN

Properties

BN: typeof BN
wordSize: 26

Methods

  • Description

    absolute value

    Returns BN

  • Description

    addition

    Parameters

    Returns BN

  • Description

    addition

    Parameters

    • b: number

    Returns BN

  • Description

    and

    Parameters

    Returns BN

  • Description

    and (NOTE: andln is going to be replaced with andn in future)

    Parameters

    • b: number

    Returns BN

  • Description

    add 1 << b to the number

    Parameters

    • b: number

    Returns BN

  • Description

    get number of bits occupied

    Returns number

  • Description

    return number of bytes occupied

    Returns number

  • Description

    clone number

    Returns BN

  • Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

    Parameters

    Returns 0 | 1 | -1

  • Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

    Parameters

    • b: number

    Returns 0 | 1 | -1

  • Description

    divide

    Parameters

    Returns BN

  • Description

    rounded division

    Parameters

    Returns BN

  • Description

    division with remainder

    Parameters

    • b: BN
    • Optional mode: "div" | "mod"
    • Optional positive: boolean

    Returns {
        div: BN;
        mod: BN;
    }

  • Description

    divide

    Parameters

    • b: number

    Returns BN

  • Description

    Extended GCD results ({ a: ..., b: ..., gcd: ... })

    Parameters

    Returns {
        a: BN;
        b: BN;
        gcd: BN;
    }

  • Description

    a equals b

    Parameters

    Returns boolean

  • Description

    a equals b

    Parameters

    • b: number

    Returns boolean

  • Description

    convert from two's complement representation, where width is the bit width

    Parameters

    • width: number

    Returns BN

  • Description

    GCD

    Parameters

    Returns BN

  • Description

    a greater than b

    Parameters

    Returns boolean

  • Description

    a greater than or equals b

    Parameters

    Returns boolean

  • Description

    a greater than or equals b

    Parameters

    • b: number

    Returns boolean

  • Description

    a greater than b

    Parameters

    • b: number

    Returns boolean

  • Description

    absolute value

    Returns BN

  • Description

    addition

    Parameters

    Returns BN

  • Description

    addition

    Parameters

    • b: number

    Returns BN

  • Description

    and

    Parameters

    Returns BN

  • Description

    divide

    Parameters

    • b: number

    Returns BN

  • Description

    clear bits with indexes higher or equal to b

    Parameters

    • b: number

    Returns BN

  • Description

    multiply

    Parameters

    Returns BN

  • Description

    multiply

    Parameters

    • b: number

    Returns BN

  • Description

    negate sign

    Returns BN

  • Description

    not (for the width specified by w)

    Parameters

    • w: number

    Returns BN

  • Description

    inverse a modulo b

    Parameters

    Returns BN

  • Description

    or

    Parameters

    Returns BN

  • Description

    check if value is even

    Returns boolean

  • Description

    true if the number is negative

    Returns boolean

  • Description

    check if value is odd

    Returns boolean

  • Description

    check if value is zero

    Returns boolean

  • Description

    shift left

    Parameters

    • b: number

    Returns BN

  • Description

    square

    Returns BN

  • Description

    subtraction

    Parameters

    Returns BN

  • Description

    subtraction

    Parameters

    • b: number

    Returns BN

  • Description

    and

    Parameters

    Returns BN

  • Description

    or

    Parameters

    Returns BN

  • Description

    shift left

    Parameters

    • b: number

    Returns BN

  • Description

    shift right

    Parameters

    • b: number

    Returns BN

  • Description

    xor

    Parameters

    Returns BN

  • Description

    xor

    Parameters

    Returns BN

  • Description

    a less than b

    Parameters

    Returns boolean

  • Description

    a less than or equals b

    Parameters

    Returns boolean

  • Description

    a less than or equals b

    Parameters

    • b: number

    Returns boolean

  • Description

    a less than b

    Parameters

    • b: number

    Returns boolean

  • Description

    clear bits with indexes higher or equal to b

    Parameters

    • b: number

    Returns BN

  • Description

    reduct

    Parameters

    Returns BN

  • Deprecated

    Description

    reduct

    Parameters

    • b: number

    Returns number

  • Description

    reduct

    Parameters

    • b: number

    Returns number

  • Description

    multiply

    Parameters

    Returns BN

  • Description

    multiply

    Parameters

    • b: number

    Returns BN

  • Description

    negate sign

    Returns BN

  • Description

    not (for the width specified by w)

    Parameters

    • w: number

    Returns BN

  • Description

    or

    Parameters

    Returns BN

  • Description

    raise a to the power of b

    Parameters

    Returns BN

  • Description

    set specified bit to value

    Parameters

    • b: number
    • value: boolean | 0 | 1

    Returns BN

  • Description

    shift left

    Parameters

    • b: number

    Returns BN

  • Description

    shift right

    Parameters

    • b: number

    Returns BN

  • Description

    square

    Returns BN

  • Description

    subtraction

    Parameters

    Returns BN

  • Description

    subtraction

    Parameters

    • b: number

    Returns BN

  • Description

    test if specified bit is set

    Parameters

    • b: number

    Returns boolean

  • Description

    convert to byte Array, and optionally zero pad to length, throwing if already exceeding

    Parameters

    • Optional endian: Endianness
    • Optional length: number

    Returns number[]

  • Description

    convert to an instance of type, which must behave like an Array

    Parameters

    • ArrayType: BufferConstructor
    • Optional endian: Endianness
    • Optional length: number

    Returns Buffer

  • Parameters

    • ArrayType: any[]
    • Optional endian: Endianness
    • Optional length: number

    Returns any[]

  • Description

    convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)

    Parameters

    • Optional endian: Endianness
    • Optional length: number

    Returns Buffer

  • Description

    convert to JSON compatible hex string (alias of toString(16))

    Returns string

  • Description

    convert to Javascript Number (limited to 53 bits)

    Returns number

  • Description

    Convert number to red

    Parameters

    Returns RedBN

  • Description

    convert to base-string and pad with zeroes

    Parameters

    • Optional base: number | "hex"
    • Optional length: number

    Returns string

  • Description

    convert to two's complement representation, where width is bit width

    Parameters

    • width: number

    Returns BN

  • Description

    and

    Parameters

    Returns BN

  • Description

    compare numbers and return -1 (a < b), 0 (a == b), or 1 (a > b) depending on the comparison result

    Parameters

    Returns 0 | 1 | -1

  • Description

    reduct

    Parameters

    Returns BN

  • Description

    or

    Parameters

    Returns BN

  • Description

    shift left

    Parameters

    • b: number

    Returns BN

  • Description

    shift right

    Parameters

    • b: number

    Returns BN

  • Description

    xor

    Parameters

    Returns BN

  • Description

    xor

    Parameters

    Returns BN

  • Description

    return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)

    Returns number

  • Description

    returns true if the supplied object is a BN.js instance

    Parameters

    • b: any

    Returns b is BN

  • Description

    returns the maximum of 2 BN instances.

    Parameters

    Returns BN

  • Description

    returns the minimum of 2 BN instances.

    Parameters

    Returns BN

  • Description

    create a reduction context with the Montgomery trick.

    Parameters

    Returns ReductionContext

Generated using TypeDoc