@types/bn.js
- Version 5.1.6
- Published
- 13.9 kB
- 1 dependency
- MIT license
Install
npm i @types/bn.js
yarn add @types/bn.js
pnpm add @types/bn.js
Overview
TypeScript definitions for bn.js
Index
Classes
BN
- abs()
- add()
- addn()
- and()
- andln()
- bincn()
- bitLength()
- BN
- byteLength()
- clone()
- cmp()
- cmpn()
- copy()
- div()
- divmod()
- divn()
- divRound()
- egcd()
- eq()
- eqn()
- fromTwos()
- gcd()
- gt()
- gte()
- gten()
- gtn()
- iabs()
- iadd()
- iaddn()
- iand()
- idivn()
- imaskn()
- imul()
- imuln()
- ineg()
- inotn()
- invm()
- ior()
- isBN()
- isEven()
- ishln()
- ishrn()
- isNeg()
- isOdd()
- isqr()
- isub()
- isubn()
- isZero()
- iuand()
- iuor()
- iushln()
- iushrn()
- iuxor()
- ixor()
- lt()
- lte()
- lten()
- ltn()
- maskn()
- max()
- min()
- mod()
- modn()
- modrn()
- mont()
- mul()
- muln()
- neg()
- notn()
- or()
- pow()
- red()
- setn()
- shln()
- shrn()
- sqr()
- sub()
- subn()
- testn()
- toArray()
- toArrayLike()
- toBuffer()
- toJSON()
- toNumber()
- toRed()
- toString()
- toTwos()
- uand()
- ucmp()
- umod()
- uor()
- ushln()
- ushrn()
- uxor()
- wordSize
- xor()
- zeroBits()
Interfaces
Type Aliases
Classes
class BN
class BN {}
constructor
constructor(number: any, base?: number | 'hex', endian?: BN.Endianness);
constructor
constructor(number: any, endian?: BN.Endianness);
property BN
static BN: typeof BN;
property wordSize
static wordSize: number;
method abs
abs: () => BN;
absolute value
method add
add: (b: BN) => BN;
addition
method addn
addn: (b: number) => BN;
addition
method and
and: (b: BN) => BN;
and
method andln
andln: (b: number) => BN;
and (NOTE:
andln
is going to be replaced withandn
in future)
method bincn
bincn: (b: number) => BN;
add
1 << b
to the number
method bitLength
bitLength: () => number;
get number of bits occupied
method byteLength
byteLength: () => number;
return number of bytes occupied
method clone
clone: () => BN;
clone number
method cmp
cmp: (b: BN) => -1 | 0 | 1;
compare numbers and return
-1 (a < b)
,0 (a == b)
, or1 (a > b)
depending on the comparison result
method cmpn
cmpn: (b: number) => -1 | 0 | 1;
compare numbers and return
-1 (a < b)
,0 (a == b)
, or1 (a > b)
depending on the comparison result
method copy
copy: (dest: BN) => void;
Copy to dest number
method div
div: (b: BN) => BN;
divide
method divmod
divmod: ( b: BN, mode?: 'div' | 'mod', positive?: boolean) => { div: BN; mod: BN };
division with remainder
method divn
divn: (b: number) => BN;
divide
method divRound
divRound: (b: BN) => BN;
rounded division
method egcd
egcd: (b: BN) => { a: BN; b: BN; gcd: BN };
Extended GCD results
({ a: ..., b: ..., gcd: ... })
method eq
eq: (b: BN) => boolean;
a equals b
method eqn
eqn: (b: number) => boolean;
a equals b
method fromTwos
fromTwos: (width: number) => BN;
convert from two's complement representation, where width is the bit width
method gcd
gcd: (b: BN) => BN;
GCD
method gt
gt: (b: BN) => boolean;
a greater than b
method gte
gte: (b: BN) => boolean;
a greater than or equals b
method gten
gten: (b: number) => boolean;
a greater than or equals b
method gtn
gtn: (b: number) => boolean;
a greater than b
method iabs
iabs: () => BN;
absolute value
method iadd
iadd: (b: BN) => BN;
addition
method iaddn
iaddn: (b: number) => BN;
addition
method iand
iand: (b: BN) => BN;
and
method idivn
idivn: (b: number) => BN;
divide
method imaskn
imaskn: (b: number) => BN;
clear bits with indexes higher or equal to
b
method imul
imul: (b: BN) => BN;
multiply
method imuln
imuln: (b: number) => BN;
multiply
method ineg
ineg: () => BN;
negate sign
method inotn
inotn: (w: number) => BN;
not (for the width specified by
w
)
method invm
invm: (b: BN) => BN;
inverse
a
modulob
method ior
ior: (b: BN) => BN;
or
method isBN
static isBN: (b: any) => b is BN;
returns true if the supplied object is a BN.js instance
method isEven
isEven: () => boolean;
check if value is even
method ishln
ishln: (b: number) => BN;
shift left
method ishrn
ishrn: (b: number) => BN;
shift right (unimplemented https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2086)
method isNeg
isNeg: () => boolean;
true if the number is negative
method isOdd
isOdd: () => boolean;
check if value is odd
method isqr
isqr: () => BN;
square
method isub
isub: (b: BN) => BN;
subtraction
method isubn
isubn: (b: number) => BN;
subtraction
method isZero
isZero: () => boolean;
check if value is zero
method iuand
iuand: (b: BN) => BN;
and
method iuor
iuor: (b: BN) => BN;
or
method iushln
iushln: (b: number) => BN;
shift left
method iushrn
iushrn: (b: number) => BN;
shift right
method iuxor
iuxor: (b: BN) => BN;
xor
method ixor
ixor: (b: BN) => BN;
xor
method lt
lt: (b: BN) => boolean;
a less than b
method lte
lte: (b: BN) => boolean;
a less than or equals b
method lten
lten: (b: number) => boolean;
a less than or equals b
method ltn
ltn: (b: number) => boolean;
a less than b
method maskn
maskn: (b: number) => BN;
clear bits with indexes higher or equal to
b
method max
static max: (left: BN, right: BN) => BN;
returns the maximum of 2 BN instances.
method min
static min: (left: BN, right: BN) => BN;
returns the minimum of 2 BN instances.
method mod
mod: (b: BN) => BN;
reduct
method modn
modn: (b: number) => number;
Deprecated
reduct
method modrn
modrn: (b: number) => number;
reduct
method mont
static mont: (num: BN) => BN.ReductionContext;
create a reduction context with the Montgomery trick.
method mul
mul: (b: BN) => BN;
multiply
method muln
muln: (b: number) => BN;
multiply
method neg
neg: () => BN;
negate sign
method notn
notn: (w: number) => BN;
not (for the width specified by
w
)
method or
or: (b: BN) => BN;
or
method pow
pow: (b: BN) => BN;
raise
a
to the power ofb
method red
static red: (reductionContext: BN | BN.IPrimeName) => BN.ReductionContext;
create a reduction context
method setn
setn: (b: number, value: boolean | 0 | 1) => BN;
set specified bit to value
method shln
shln: (b: number) => BN;
shift left
method shrn
shrn: (b: number) => BN;
shift right
method sqr
sqr: () => BN;
square
method sub
sub: (b: BN) => BN;
subtraction
method subn
subn: (b: number) => BN;
subtraction
method testn
testn: (b: number) => boolean;
test if specified bit is set
method toArray
toArray: (endian?: BN.Endianness, length?: number) => number[];
convert to byte Array, and optionally zero pad to length, throwing if already exceeding
method toArrayLike
toArrayLike: { (ArrayType: any, endian?: BN.Endianness, length?: number): Buffer; (ArrayType: any[], endian?: BN.Endianness, length?: number): any[];};
convert to an instance of
type
, which must behave like an Array
method toBuffer
toBuffer: (endian?: BN.Endianness, length?: number) => Buffer;
convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)
method toJSON
toJSON: () => string;
convert to JSON compatible hex string (alias of toString(16))
method toNumber
toNumber: () => number;
convert to Javascript Number (limited to 53 bits)
method toRed
toRed: (reductionContext: BN.ReductionContext) => RedBN;
Convert number to red
method toString
toString: (base?: number | 'hex', length?: number) => string;
convert to base-string and pad with zeroes
method toTwos
toTwos: (width: number) => BN;
convert to two's complement representation, where width is bit width
method uand
uand: (b: BN) => BN;
and
method ucmp
ucmp: (b: BN) => -1 | 0 | 1;
compare numbers and return
-1 (a < b)
,0 (a == b)
, or1 (a > b)
depending on the comparison result
method umod
umod: (b: BN) => BN;
reduct
method uor
uor: (b: BN) => BN;
or
method ushln
ushln: (b: number) => BN;
shift left
method ushrn
ushrn: (b: number) => BN;
shift right
method uxor
uxor: (b: BN) => BN;
xor
method xor
xor: (b: BN) => BN;
xor
method zeroBits
zeroBits: () => number;
return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)
Interfaces
interface MPrime
interface MPrime {}
interface ReductionContext
interface ReductionContext {}
Type Aliases
type Endianness
type Endianness = 'le' | 'be';
type IPrimeName
type IPrimeName = 'k256' | 'p224' | 'p192' | 'p25519';
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/bn.js
.
- Markdown[](https://www.jsdocs.io/package/@types/bn.js)
- HTML<a href="https://www.jsdocs.io/package/@types/bn.js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3840 ms. - Missing or incorrect documentation? Open an issue for this package.