Hierarchy

  • BN
    • Numberu32

Constructors

  • Parameters

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

    Returns Numberu32

  • Parameters

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

    Returns Numberu32

Properties

BN: typeof BN
wordSize: 26

Methods

  • Returns BN

    Description

    absolute value

  • Parameters

    • b: BN

    Returns BN

    Description

    addition

  • Parameters

    • b: number

    Returns BN

    Description

    addition

  • Parameters

    • b: BN

    Returns BN

    Description

    and

  • Parameters

    • b: number

    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

  • Returns number

    Description

    get number of bits occupied

  • Returns number

    Description

    return number of bytes occupied

  • Returns BN

    Description

    clone number

  • Parameters

    • b: BN

    Returns -1 | 0 | 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 -1 | 0 | 1

    Description

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

  • Parameters

    • b: BN

    Returns BN

    Description

    divide

  • Parameters

    • b: BN

    Returns BN

    Description

    rounded division

  • Parameters

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

    Returns {
        div: BN;
        mod: BN;
    }

    • div: BN
    • mod: BN

    Description

    division with remainder

  • Parameters

    • b: number

    Returns BN

    Description

    divide

  • Parameters

    • b: BN

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

    • a: BN
    • b: BN
    • gcd: BN

    Description

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

  • Parameters

    • b: BN

    Returns boolean

    Description

    a equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a equals b

  • Parameters

    • width: number

    Returns BN

    Description

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

  • Parameters

    • b: BN

    Returns BN

    Description

    GCD

  • Parameters

    • b: BN

    Returns boolean

    Description

    a greater than b

  • Parameters

    • b: BN

    Returns boolean

    Description

    a greater than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a greater than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a greater than b

  • Returns BN

    Description

    absolute value

  • Parameters

    • b: BN

    Returns BN

    Description

    addition

  • Parameters

    • b: number

    Returns BN

    Description

    addition

  • Parameters

    • b: BN

    Returns BN

    Description

    and

  • Parameters

    • b: number

    Returns BN

    Description

    divide

  • Parameters

    • b: number

    Returns BN

    Description

    clear bits with indexes higher or equal to b

  • Parameters

    • b: BN

    Returns BN

    Description

    multiply

  • Parameters

    • b: number

    Returns BN

    Description

    multiply

  • Returns BN

    Description

    negate sign

  • Parameters

    • w: number

    Returns BN

    Description

    not (for the width specified by w)

  • Parameters

    • b: BN

    Returns BN

    Description

    inverse a modulo b

  • Parameters

    • b: BN

    Returns BN

    Description

    or

  • Returns boolean

    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

  • Parameters

    • b: number

    Returns BN

    Description

    shift left

  • Returns BN

    Description

    square

  • Parameters

    • b: BN

    Returns BN

    Description

    subtraction

  • Parameters

    • b: number

    Returns BN

    Description

    subtraction

  • Parameters

    • b: BN

    Returns BN

    Description

    and

  • Parameters

    • b: BN

    Returns BN

    Description

    or

  • Parameters

    • b: number

    Returns BN

    Description

    shift left

  • Parameters

    • b: number

    Returns BN

    Description

    shift right

  • Parameters

    • b: BN

    Returns BN

    Description

    xor

  • Parameters

    • b: BN

    Returns BN

    Description

    xor

  • Parameters

    • b: BN

    Returns boolean

    Description

    a less than b

  • Parameters

    • b: BN

    Returns boolean

    Description

    a less than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a less than or equals b

  • Parameters

    • b: number

    Returns boolean

    Description

    a less than b

  • Parameters

    • b: number

    Returns BN

    Description

    clear bits with indexes higher or equal to b

  • Parameters

    • b: BN

    Returns BN

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Deprecated

    Description

    reduct

  • Parameters

    • b: number

    Returns number

    Description

    reduct

  • Parameters

    • b: BN

    Returns BN

    Description

    multiply

  • Parameters

    • b: number

    Returns BN

    Description

    multiply

  • Returns BN

    Description

    negate sign

  • Parameters

    • w: number

    Returns BN

    Description

    not (for the width specified by w)

  • Parameters

    • b: BN

    Returns BN

    Description

    or

  • Parameters

    • b: BN

    Returns BN

    Description

    raise a to the power of b

  • Parameters

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

    Returns BN

    Description

    set specified bit to value

  • Parameters

    • b: number

    Returns BN

    Description

    shift left

  • Parameters

    • b: number

    Returns BN

    Description

    shift right

  • Returns BN

    Description

    square

  • Parameters

    • b: BN

    Returns BN

    Description

    subtraction

  • Parameters

    • b: number

    Returns BN

    Description

    subtraction

  • Parameters

    • b: number

    Returns boolean

    Description

    test if specified bit is set

  • Parameters

    • Optional endian: Endianness
    • Optional length: number

    Returns number[]

    Description

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

  • Parameters

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

    Returns Buffer

    Description

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

  • Parameters

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

    Returns any[]

  • Returns string

    Description

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

  • Returns number

    Description

    convert to Javascript Number (limited to 53 bits)

  • Parameters

    • reductionContext: ReductionContext

    Returns RedBN

    Description

    Convert number to red

  • Parameters

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

    Returns string

    Description

    convert to base-string and pad with zeroes

  • Parameters

    • width: number

    Returns BN

    Description

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

  • Parameters

    • b: BN

    Returns BN

    Description

    and

  • Parameters

    • b: BN

    Returns -1 | 0 | 1

    Description

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

  • Parameters

    • b: BN

    Returns BN

    Description

    reduct

  • Parameters

    • b: BN

    Returns BN

    Description

    or

  • Parameters

    • b: number

    Returns BN

    Description

    shift left

  • Parameters

    • b: number

    Returns BN

    Description

    shift right

  • Parameters

    • b: BN

    Returns BN

    Description

    xor

  • Parameters

    • b: BN

    Returns BN

    Description

    xor

  • Returns number

    Description

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

  • Construct a Numberu32 from Buffer representation

    Parameters

    • buffer: any

    Returns BN

  • Parameters

    • b: any

    Returns b is BN

    Description

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

  • Parameters

    • left: BN
    • right: BN

    Returns BN

    Description

    returns the maximum of 2 BN instances.

  • Parameters

    • left: BN
    • right: BN

    Returns BN

    Description

    returns the minimum of 2 BN instances.

  • Parameters

    • num: BN

    Returns ReductionContext

    Description

    create a reduction context with the Montgomery trick.

  • Parameters

    • reductionContext: IPrimeName | BN

    Returns ReductionContext

    Description

    create a reduction context