@isdk/bigint
Version:
The BigInteger class wrapped bn.js and native BitInt
3,204 lines (1,764 loc) • 39.7 kB
Markdown
[@isdk/bigint](../README.md) / [Exports](../modules.md) / BN
# Class: BN
## Hierarchy
- `BN`
↳ **`BN`**
## Table of contents
### Constructors
- [constructor](BN.md#constructor)
### Properties
- [BN](BN.md#bn)
- [wordSize](BN.md#wordsize)
### Methods
- [abs](BN.md#abs)
- [add](BN.md#add)
- [addn](BN.md#addn)
- [and](BN.md#and)
- [andln](BN.md#andln)
- [bincn](BN.md#bincn)
- [bitLength](BN.md#bitlength)
- [byteLength](BN.md#bytelength)
- [clone](BN.md#clone)
- [cmp](BN.md#cmp)
- [cmpn](BN.md#cmpn)
- [copy](BN.md#copy)
- [dec](BN.md#dec)
- [div](BN.md#div)
- [divRound](BN.md#divround)
- [divmod](BN.md#divmod)
- [divn](BN.md#divn)
- [egcd](BN.md#egcd)
- [eq](BN.md#eq)
- [eqn](BN.md#eqn)
- [equal](BN.md#equal)
- [fromTwos](BN.md#fromtwos)
- [gcd](BN.md#gcd)
- [getBit](BN.md#getbit)
- [gt](BN.md#gt)
- [gte](BN.md#gte)
- [gten](BN.md#gten)
- [gtn](BN.md#gtn)
- [iabs](BN.md#iabs)
- [iadd](BN.md#iadd)
- [iaddn](BN.md#iaddn)
- [iand](BN.md#iand)
- [idec](BN.md#idec)
- [idivn](BN.md#idivn)
- [iinc](BN.md#iinc)
- [ileftShift](BN.md#ileftshift)
- [imaskn](BN.md#imaskn)
- [imod](BN.md#imod)
- [imul](BN.md#imul)
- [imuln](BN.md#imuln)
- [inc](BN.md#inc)
- [ineg](BN.md#ineg)
- [inotn](BN.md#inotn)
- [invm](BN.md#invm)
- [ior](BN.md#ior)
- [irightShift](BN.md#irightshift)
- [isEven](BN.md#iseven)
- [isNeg](BN.md#isneg)
- [isNegative](BN.md#isnegative)
- [isOdd](BN.md#isodd)
- [isOne](BN.md#isone)
- [isZero](BN.md#iszero)
- [ishln](BN.md#ishln)
- [ishrn](BN.md#ishrn)
- [isqr](BN.md#isqr)
- [isub](BN.md#isub)
- [isubn](BN.md#isubn)
- [iuand](BN.md#iuand)
- [iumod](BN.md#iumod)
- [iuor](BN.md#iuor)
- [iushln](BN.md#iushln)
- [iushrn](BN.md#iushrn)
- [iuxor](BN.md#iuxor)
- [ixor](BN.md#ixor)
- [leftShift](BN.md#leftshift)
- [lt](BN.md#lt)
- [lte](BN.md#lte)
- [lten](BN.md#lten)
- [ltn](BN.md#ltn)
- [maskn](BN.md#maskn)
- [mod](BN.md#mod)
- [modExp](BN.md#modexp)
- [modInv](BN.md#modinv)
- [modn](BN.md#modn)
- [modrn](BN.md#modrn)
- [mul](BN.md#mul)
- [muln](BN.md#muln)
- [neg](BN.md#neg)
- [notn](BN.md#notn)
- [or](BN.md#or)
- [pow](BN.md#pow)
- [rightShift](BN.md#rightshift)
- [setn](BN.md#setn)
- [shln](BN.md#shln)
- [shrn](BN.md#shrn)
- [sqr](BN.md#sqr)
- [sub](BN.md#sub)
- [subn](BN.md#subn)
- [testn](BN.md#testn)
- [toArray](BN.md#toarray)
- [toArrayLike](BN.md#toarraylike)
- [toBuffer](BN.md#tobuffer)
- [toJSON](BN.md#tojson)
- [toNumber](BN.md#tonumber)
- [toRed](BN.md#tored)
- [toString](BN.md#tostring)
- [toTwos](BN.md#totwos)
- [toUint8Array](BN.md#touint8array)
- [uand](BN.md#uand)
- [ucmp](BN.md#ucmp)
- [umod](BN.md#umod)
- [uor](BN.md#uor)
- [ushln](BN.md#ushln)
- [ushrn](BN.md#ushrn)
- [uxor](BN.md#uxor)
- [xor](BN.md#xor)
- [zeroBits](BN.md#zerobits)
- [isBN](BN.md#isbn)
- [max](BN.md#max)
- [min](BN.md#min)
- [mont](BN.md#mont)
- [red](BN.md#red)
## Constructors
### constructor
• **new BN**(`num`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `num` | ``null`` \| `string` \| `number` \| `boolean` \| `Uint8Array` |
#### Overrides
BNum.constructor
#### Defined in
[src/bn.ts:101](https://github.com/isdk/bigint.js/blob/c098291/src/bn.ts#L101)
## Properties
### BN
▪ `Static` **BN**: typeof `BN`
#### Inherited from
BNum.BN
#### Defined in
[types/index.d.ts:3](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L3)
___
### wordSize
▪ `Static` **wordSize**: ``26``
#### Inherited from
BNum.wordSize
#### Defined in
[types/index.d.ts:4](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L4)
## Methods
### abs
▸ **abs**(): `BN`
**`Description`**
absolute value
#### Returns
`BN`
#### Inherited from
BNum.abs
#### Defined in
[types/index.d.ts:209](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L209)
___
### add
▸ **add**(`b`): `BN`
**`Description`**
addition
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.add
#### Defined in
[types/index.d.ts:219](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L219)
___
### addn
▸ **addn**(`b`): `BN`
**`Description`**
addition
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.addn
#### Defined in
[types/index.d.ts:229](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L229)
___
### and
▸ **and**(`b`): `BN`
**`Description`**
and
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.and
#### Defined in
[types/index.d.ts:364](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L364)
___
### andln
▸ **andln**(`b`): `BN`
**`Description`**
and (NOTE: `andln` is going to be replaced with `andn` in future)
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.andln
#### Defined in
[types/index.d.ts:384](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L384)
___
### bincn
▸ **bincn**(`b`): `BN`
**`Description`**
add `1 << b` to the number
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.bincn
#### Defined in
[types/index.d.ts:468](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L468)
___
### bitLength
▸ **bitLength**(): `number`
**`Description`**
get number of bits occupied
#### Returns
`number`
#### Inherited from
BNum.bitLength
#### Defined in
[types/index.d.ts:89](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L89)
___
### byteLength
▸ **byteLength**(): `number`
**`Description`**
return number of bytes occupied
#### Returns
`number`
#### Inherited from
BNum.byteLength
#### Defined in
[types/index.d.ts:99](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L99)
___
### clone
▸ **clone**(): `BN`
**`Description`**
clone number
#### Returns
`BN`
#### Inherited from
BNum.clone
#### Defined in
[types/index.d.ts:44](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L44)
___
### cmp
▸ **cmp**(`b`): ``0`` \| ``1`` \| ``-1``
**`Description`**
compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
``0`` \| ``1`` \| ``-1``
#### Inherited from
BNum.cmp
#### Defined in
[types/index.d.ts:124](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L124)
___
### cmpn
▸ **cmpn**(`b`): ``0`` \| ``1`` \| ``-1``
**`Description`**
compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
``0`` \| ``1`` \| ``-1``
#### Inherited from
BNum.cmpn
#### Defined in
[types/index.d.ts:134](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L134)
___
### copy
▸ **copy**(`dest`): `void`
Copy value to dest
#### Parameters
| Name | Type |
| :------ | :------ |
| `dest` | `BN` |
#### Returns
`void`
#### Inherited from
BNum.copy
#### Defined in
[types/index.d.ts:504](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L504)
___
### dec
▸ **dec**(`n?`): `BN`
#### Parameters
| Name | Type |
| :------ | :------ |
| `n?` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.dec
#### Defined in
[types/index.d.ts:525](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L525)
___
### div
▸ **div**(`b`): `BN`
**`Description`**
divide
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.div
#### Defined in
[types/index.d.ts:294](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L294)
___
### divRound
▸ **divRound**(`b`): `BN`
**`Description`**
rounded division
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.divRound
#### Defined in
[types/index.d.ts:339](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L339)
___
### divmod
▸ **divmod**(`b`, `mode?`, `positive?`): `Object`
**`Description`**
division with remainder
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
| `mode?` | ``"div"`` \| ``"mod"`` |
| `positive?` | `boolean` |
#### Returns
`Object`
| Name | Type |
| :------ | :------ |
| `div` | `BN` |
| `mod` | `BN` |
#### Inherited from
BNum.divmod
#### Defined in
[types/index.d.ts:309](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L309)
___
### divn
▸ **divn**(`b`): `BN`
**`Description`**
divide
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.divn
#### Defined in
[types/index.d.ts:299](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L299)
___
### egcd
▸ **egcd**(`b`): `Object`
**`Description`**
Extended GCD results `({ a: ..., b: ..., gcd: ... })`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`Object`
| Name | Type |
| :------ | :------ |
| `a` | `BN` |
| `b` | `BN` |
| `gcd` | `BN` |
#### Inherited from
BNum.egcd
#### Defined in
[types/index.d.ts:488](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L488)
___
### eq
▸ **eq**(`b`): `boolean`
**`Description`**
a equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`boolean`
#### Inherited from
BNum.eq
#### Defined in
[types/index.d.ts:179](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L179)
___
### eqn
▸ **eqn**(`b`): `boolean`
**`Description`**
a equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.eqn
#### Defined in
[types/index.d.ts:184](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L184)
___
### equal
▸ **equal**(`x`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `x` | `BN` |
#### Returns
`any`
#### Inherited from
BNum.equal
#### Defined in
[types/index.d.ts:532](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L532)
___
### fromTwos
▸ **fromTwos**(`width`): `BN`
**`Description`**
convert from two's complement representation, where width is the bit width
#### Parameters
| Name | Type |
| :------ | :------ |
| `width` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.fromTwos
#### Defined in
[types/index.d.ts:194](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L194)
___
### gcd
▸ **gcd**(`b`): `BN`
**`Description`**
GCD
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.gcd
#### Defined in
[types/index.d.ts:483](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L483)
___
### getBit
▸ **getBit**(`i`): ``0`` \| ``1``
#### Parameters
| Name | Type |
| :------ | :------ |
| `i` | `number` |
#### Returns
``0`` \| ``1``
#### Inherited from
BNum.getBit
#### Defined in
[types/index.d.ts:533](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L533)
___
### gt
▸ **gt**(`b`): `boolean`
**`Description`**
a greater than b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`boolean`
#### Inherited from
BNum.gt
#### Defined in
[types/index.d.ts:159](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L159)
___
### gte
▸ **gte**(`b`): `boolean`
**`Description`**
a greater than or equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`boolean`
#### Inherited from
BNum.gte
#### Defined in
[types/index.d.ts:169](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L169)
___
### gten
▸ **gten**(`b`): `boolean`
**`Description`**
a greater than or equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.gten
#### Defined in
[types/index.d.ts:174](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L174)
___
### gtn
▸ **gtn**(`b`): `boolean`
**`Description`**
a greater than b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.gtn
#### Defined in
[types/index.d.ts:164](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L164)
___
### iabs
▸ **iabs**(): `BN`
**`Description`**
absolute value
#### Returns
`BN`
#### Inherited from
BNum.iabs
#### Defined in
[types/index.d.ts:214](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L214)
___
### iadd
▸ **iadd**(`b`): `BN`
**`Description`**
addition
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iadd
#### Defined in
[types/index.d.ts:224](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L224)
___
### iaddn
▸ **iaddn**(`b`): `BN`
**`Description`**
addition
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.iaddn
#### Defined in
[types/index.d.ts:234](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L234)
___
### iand
▸ **iand**(`b`): `BN`
**`Description`**
and
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iand
#### Defined in
[types/index.d.ts:369](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L369)
___
### idec
▸ **idec**(`n?`): `BN`
**`Description`**
subtract number n(defaults to 1)
#### Parameters
| Name | Type |
| :------ | :------ |
| `n?` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.idec
#### Defined in
[types/index.d.ts:521](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L521)
___
### idivn
▸ **idivn**(`b`): `BN`
**`Description`**
divide
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.idivn
#### Defined in
[types/index.d.ts:304](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L304)
___
### iinc
▸ **iinc**(`n?`): `BN`
**`Description`**
add number n(defaults to 1)
#### Parameters
| Name | Type |
| :------ | :------ |
| `n?` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.iinc
#### Defined in
[types/index.d.ts:517](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L517)
___
### ileftShift
▸ **ileftShift**(`x`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `x` | `number` \| `BN` |
#### Returns
`any`
#### Inherited from
BNum.ileftShift
#### Defined in
[types/index.d.ts:528](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L528)
___
### imaskn
▸ **imaskn**(`b`): `BN`
**`Description`**
clear bits with indexes higher or equal to `b`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.imaskn
#### Defined in
[types/index.d.ts:464](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L464)
___
### imod
▸ **imod**(`b`): `BN`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.imod
#### Defined in
[types/index.d.ts:522](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L522)
___
### imul
▸ **imul**(`b`): `BN`
**`Description`**
multiply
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.imul
#### Defined in
[types/index.d.ts:264](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L264)
___
### imuln
▸ **imuln**(`b`): `BN`
**`Description`**
multiply
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.imuln
#### Defined in
[types/index.d.ts:274](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L274)
___
### inc
▸ **inc**(`n?`): `BN`
#### Parameters
| Name | Type |
| :------ | :------ |
| `n?` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.inc
#### Defined in
[types/index.d.ts:524](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L524)
___
### ineg
▸ **ineg**(): `BN`
**`Description`**
negate sign
#### Returns
`BN`
#### Inherited from
BNum.ineg
#### Defined in
[types/index.d.ts:204](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L204)
___
### inotn
▸ **inotn**(`w`): `BN`
**`Description`**
not (for the width specified by `w`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `w` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.inotn
#### Defined in
[types/index.d.ts:478](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L478)
___
### invm
▸ **invm**(`b`): `BN`
**`Description`**
inverse `a` modulo `b`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.invm
#### Defined in
[types/index.d.ts:493](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L493)
___
### ior
▸ **ior**(`b`): `BN`
**`Description`**
or
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.ior
#### Defined in
[types/index.d.ts:349](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L349)
___
### irightShift
▸ **irightShift**(`x`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `x` | `number` \| `BN` |
#### Returns
`any`
#### Inherited from
BNum.irightShift
#### Defined in
[types/index.d.ts:530](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L530)
___
### isEven
▸ **isEven**(): `boolean`
**`Description`**
check if value is even
#### Returns
`boolean`
#### Inherited from
BNum.isEven
#### Defined in
[types/index.d.ts:109](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L109)
___
### isNeg
▸ **isNeg**(): `boolean`
**`Description`**
true if the number is negative
#### Returns
`boolean`
#### Inherited from
BNum.isNeg
#### Defined in
[types/index.d.ts:104](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L104)
___
### isNegative
▸ **isNegative**(): `boolean`
**`Description`**
true if the number is negative
#### Returns
`boolean`
#### Inherited from
BNum.isNegative
#### Defined in
[types/index.d.ts:513](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L513)
___
### isOdd
▸ **isOdd**(): `boolean`
**`Description`**
check if value is odd
#### Returns
`boolean`
#### Inherited from
BNum.isOdd
#### Defined in
[types/index.d.ts:114](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L114)
___
### isOne
▸ **isOne**(): `boolean`
**`Description`**
Check value whether is 1
#### Returns
`boolean`
#### Inherited from
BNum.isOne
#### Defined in
[types/index.d.ts:509](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L509)
___
### isZero
▸ **isZero**(): `boolean`
**`Description`**
check if value is zero
#### Returns
`boolean`
#### Inherited from
BNum.isZero
#### Defined in
[types/index.d.ts:119](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L119)
___
### ishln
▸ **ishln**(`b`): `BN`
**`Description`**
shift left
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.ishln
#### Defined in
[types/index.d.ts:419](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L419)
___
### ishrn
▸ **ishrn**(`b`): `BN`
**`Description`**
shift right (unimplemented https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2090)
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.ishrn
#### Defined in
[types/index.d.ts:439](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L439)
___
### isqr
▸ **isqr**(): `BN`
**`Description`**
square
#### Returns
`BN`
#### Inherited from
BNum.isqr
#### Defined in
[types/index.d.ts:284](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L284)
___
### isub
▸ **isub**(`b`): `BN`
**`Description`**
subtraction
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.isub
#### Defined in
[types/index.d.ts:244](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L244)
___
### isubn
▸ **isubn**(`b`): `BN`
**`Description`**
subtraction
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.isubn
#### Defined in
[types/index.d.ts:254](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L254)
___
### iuand
▸ **iuand**(`b`): `BN`
**`Description`**
and
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iuand
#### Defined in
[types/index.d.ts:379](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L379)
___
### iumod
▸ **iumod**(`b`): `BN`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iumod
#### Defined in
[types/index.d.ts:523](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L523)
___
### iuor
▸ **iuor**(`b`): `BN`
**`Description`**
or
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iuor
#### Defined in
[types/index.d.ts:359](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L359)
___
### iushln
▸ **iushln**(`b`): `BN`
**`Description`**
shift left
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.iushln
#### Defined in
[types/index.d.ts:429](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L429)
___
### iushrn
▸ **iushrn**(`b`): `BN`
**`Description`**
shift right
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.iushrn
#### Defined in
[types/index.d.ts:449](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L449)
___
### iuxor
▸ **iuxor**(`b`): `BN`
**`Description`**
xor
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.iuxor
#### Defined in
[types/index.d.ts:404](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L404)
___
### ixor
▸ **ixor**(`b`): `BN`
**`Description`**
xor
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.ixor
#### Defined in
[types/index.d.ts:394](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L394)
___
### leftShift
▸ **leftShift**(`x`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `x` | `number` \| `BN` |
#### Returns
`any`
#### Inherited from
BNum.leftShift
#### Defined in
[types/index.d.ts:529](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L529)
___
### lt
▸ **lt**(`b`): `boolean`
**`Description`**
a less than b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`boolean`
#### Inherited from
BNum.lt
#### Defined in
[types/index.d.ts:139](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L139)
___
### lte
▸ **lte**(`b`): `boolean`
**`Description`**
a less than or equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`boolean`
#### Inherited from
BNum.lte
#### Defined in
[types/index.d.ts:149](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L149)
___
### lten
▸ **lten**(`b`): `boolean`
**`Description`**
a less than or equals b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.lten
#### Defined in
[types/index.d.ts:154](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L154)
___
### ltn
▸ **ltn**(`b`): `boolean`
**`Description`**
a less than b
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.ltn
#### Defined in
[types/index.d.ts:144](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L144)
___
### maskn
▸ **maskn**(`b`): `BN`
**`Description`**
clear bits with indexes higher or equal to `b`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.maskn
#### Defined in
[types/index.d.ts:459](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L459)
___
### mod
▸ **mod**(`b`): `BN`
**`Description`**
reduct
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.mod
#### Defined in
[types/index.d.ts:318](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L318)
___
### modExp
▸ **modExp**(`e`, `n`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `e` | `BN` |
| `n` | `BN` |
#### Returns
`any`
#### Inherited from
BNum.modExp
#### Defined in
[types/index.d.ts:526](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L526)
___
### modInv
▸ **modInv**(`n`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `n` | `BN` |
#### Returns
`any`
#### Inherited from
BNum.modInv
#### Defined in
[types/index.d.ts:527](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L527)
___
### modn
▸ **modn**(`b`): `number`
**`Deprecated`**
**`Description`**
reduct
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`number`
#### Inherited from
BNum.modn
#### Defined in
[types/index.d.ts:329](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L329)
___
### modrn
▸ **modrn**(`b`): `number`
**`Description`**
reduct
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`number`
#### Inherited from
BNum.modrn
#### Defined in
[types/index.d.ts:334](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L334)
___
### mul
▸ **mul**(`b`): `BN`
**`Description`**
multiply
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.mul
#### Defined in
[types/index.d.ts:259](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L259)
___
### muln
▸ **muln**(`b`): `BN`
**`Description`**
multiply
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.muln
#### Defined in
[types/index.d.ts:269](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L269)
___
### neg
▸ **neg**(): `BN`
**`Description`**
negate sign
#### Returns
`BN`
#### Inherited from
BNum.neg
#### Defined in
[types/index.d.ts:199](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L199)
___
### notn
▸ **notn**(`w`): `BN`
**`Description`**
not (for the width specified by `w`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `w` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.notn
#### Defined in
[types/index.d.ts:473](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L473)
___
### or
▸ **or**(`b`): `BN`
**`Description`**
or
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.or
#### Defined in
[types/index.d.ts:344](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L344)
___
### pow
▸ **pow**(`b`): `BN`
**`Description`**
raise `a` to the power of `b`
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.pow
#### Defined in
[types/index.d.ts:289](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L289)
___
### rightShift
▸ **rightShift**(`x`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `x` | `number` \| `BN` |
#### Returns
`any`
#### Inherited from
BNum.rightShift
#### Defined in
[types/index.d.ts:531](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L531)
___
### setn
▸ **setn**(`b`): `BN`
**`Description`**
set specified bit to 1
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.setn
#### Defined in
[types/index.d.ts:409](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L409)
___
### shln
▸ **shln**(`b`): `BN`
**`Description`**
shift left
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.shln
#### Defined in
[types/index.d.ts:414](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L414)
___
### shrn
▸ **shrn**(`b`): `BN`
**`Description`**
shift right
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.shrn
#### Defined in
[types/index.d.ts:434](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L434)
___
### sqr
▸ **sqr**(): `BN`
**`Description`**
square
#### Returns
`BN`
#### Inherited from
BNum.sqr
#### Defined in
[types/index.d.ts:279](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L279)
___
### sub
▸ **sub**(`b`): `BN`
**`Description`**
subtraction
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.sub
#### Defined in
[types/index.d.ts:239](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L239)
___
### subn
▸ **subn**(`b`): `BN`
**`Description`**
subtraction
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.subn
#### Defined in
[types/index.d.ts:249](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L249)
___
### testn
▸ **testn**(`b`): `boolean`
**`Description`**
test if specified bit is set
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`boolean`
#### Inherited from
BNum.testn
#### Defined in
[types/index.d.ts:454](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L454)
___
### toArray
▸ **toArray**(`endian?`, `length?`): `number`[]
**`Description`**
convert to byte Array, and optionally zero pad to length, throwing if already exceeding
#### Parameters
| Name | Type |
| :------ | :------ |
| `endian?` | `Endianness` |
| `length?` | `number` |
#### Returns
`number`[]
#### Inherited from
BNum.toArray
#### Defined in
[types/index.d.ts:64](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L64)
___
### toArrayLike
▸ **toArrayLike**(`ArrayType`, `endian?`, `length?`): `Buffer`
**`Description`**
convert to an instance of `type`, which must behave like an Array
#### Parameters
| Name | Type |
| :------ | :------ |
| `ArrayType` | `BufferConstructor` |
| `endian?` | `Endianness` |
| `length?` | `number` |
#### Returns
`Buffer`
#### Inherited from
BNum.toArrayLike
#### Defined in
[types/index.d.ts:69](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L69)
▸ **toArrayLike**(`ArrayType`, `endian?`, `length?`): `any`[]
#### Parameters
| Name | Type |
| :------ | :------ |
| `ArrayType` | `any`[] |
| `endian?` | `Endianness` |
| `length?` | `number` |
#### Returns
`any`[]
#### Inherited from
BNum.toArrayLike
#### Defined in
[types/index.d.ts:75](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L75)
___
### toBuffer
▸ **toBuffer**(`endian?`, `length?`): `Buffer`
**`Description`**
convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)
#### Parameters
| Name | Type |
| :------ | :------ |
| `endian?` | `Endianness` |
| `length?` | `number` |
#### Returns
`Buffer`
#### Inherited from
BNum.toBuffer
#### Defined in
[types/index.d.ts:84](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L84)
___
### toJSON
▸ **toJSON**(): `string`
**`Description`**
convert to JSON compatible hex string (alias of toString(16))
#### Returns
`string`
#### Inherited from
BNum.toJSON
#### Defined in
[types/index.d.ts:59](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L59)
___
### toNumber
▸ **toNumber**(): `number`
**`Description`**
convert to Javascript Number (limited to 53 bits)
#### Returns
`number`
#### Inherited from
BNum.toNumber
#### Defined in
[types/index.d.ts:54](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L54)
___
### toRed
▸ **toRed**(`reductionContext`): `RedBN`
**`Description`**
Convert number to red
#### Parameters
| Name | Type |
| :------ | :------ |
| `reductionContext` | `ReductionContext` |
#### Returns
`RedBN`
#### Inherited from
BNum.toRed
#### Defined in
[types/index.d.ts:498](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L498)
___
### toString
▸ **toString**(`base?`, `length?`): `string`
**`Description`**
convert to base-string and pad with zeroes
#### Parameters
| Name | Type |
| :------ | :------ |
| `base?` | `number` \| ``"hex"`` |
| `length?` | `number` |
#### Returns
`string`
#### Inherited from
BNum.toString
#### Defined in
[types/index.d.ts:49](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L49)
___
### toTwos
▸ **toTwos**(`width`): `BN`
**`Description`**
convert to two's complement representation, where width is bit width
#### Parameters
| Name | Type |
| :------ | :------ |
| `width` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.toTwos
#### Defined in
[types/index.d.ts:189](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L189)
___
### toUint8Array
▸ **toUint8Array**(`endian?`, `length?`): `any`
#### Parameters
| Name | Type |
| :------ | :------ |
| `endian?` | ``"le"`` \| ``"be"`` |
| `length?` | `number` |
#### Returns
`any`
#### Inherited from
BNum.toUint8Array
#### Defined in
[types/index.d.ts:534](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L534)
___
### uand
▸ **uand**(`b`): `BN`
**`Description`**
and
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.uand
#### Defined in
[types/index.d.ts:374](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L374)
___
### ucmp
▸ **ucmp**(`b`): ``0`` \| ``1`` \| ``-1``
**`Description`**
compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
``0`` \| ``1`` \| ``-1``
#### Inherited from
BNum.ucmp
#### Defined in
[types/index.d.ts:129](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L129)
___
### umod
▸ **umod**(`b`): `BN`
**`Description`**
reduct
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.umod
#### Defined in
[types/index.d.ts:323](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L323)
___
### uor
▸ **uor**(`b`): `BN`
**`Description`**
or
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.uor
#### Defined in
[types/index.d.ts:354](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L354)
___
### ushln
▸ **ushln**(`b`): `BN`
**`Description`**
shift left
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.ushln
#### Defined in
[types/index.d.ts:424](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L424)
___
### ushrn
▸ **ushrn**(`b`): `BN`
**`Description`**
shift right
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `number` |
#### Returns
`BN`
#### Inherited from
BNum.ushrn
#### Defined in
[types/index.d.ts:444](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L444)
___
### uxor
▸ **uxor**(`b`): `BN`
**`Description`**
xor
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.uxor
#### Defined in
[types/index.d.ts:399](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L399)
___
### xor
▸ **xor**(`b`): `BN`
**`Description`**
xor
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.xor
#### Defined in
[types/index.d.ts:389](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L389)
___
### zeroBits
▸ **zeroBits**(): `number`
**`Description`**
return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)
#### Returns
`number`
#### Inherited from
BNum.zeroBits
#### Defined in
[types/index.d.ts:94](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L94)
___
### isBN
▸ `Static` **isBN**(`b`): b is BN
**`Description`**
returns true if the supplied object is a BN.js instance
#### Parameters
| Name | Type |
| :------ | :------ |
| `b` | `any` |
#### Returns
b is BN
#### Inherited from
BNum.isBN
#### Defined in
[types/index.d.ts:29](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L29)
___
### max
▸ `Static` **max**(`left`, `right`): `BN`
**`Description`**
returns the maximum of 2 BN instances.
#### Parameters
| Name | Type |
| :------ | :------ |
| `left` | `BN` |
| `right` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.max
#### Defined in
[types/index.d.ts:34](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L34)
___
### min
▸ `Static` **min**(`left`, `right`): `BN`
**`Description`**
returns the minimum of 2 BN instances.
#### Parameters
| Name | Type |
| :------ | :------ |
| `left` | `BN` |
| `right` | `BN` |
#### Returns
`BN`
#### Inherited from
BNum.min
#### Defined in
[types/index.d.ts:39](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L39)
___
### mont
▸ `Static` **mont**(`num`): `ReductionContext`
**`Description`**
create a reduction context with the Montgomery trick.
#### Parameters
| Name | Type |
| :------ | :------ |
| `num` | `BN` |
#### Returns
`ReductionContext`
#### Inherited from
BNum.mont
#### Defined in
[types/index.d.ts:24](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L24)
___
### red
▸ `Static` **red**(`reductionContext`): `ReductionContext`
**`Description`**
create a reduction context
#### Parameters
| Name | Type |
| :------ | :------ |
| `reductionContext` | `BN` \| `IPrimeName` |
#### Returns
`ReductionContext`
#### Inherited from
BNum.red
#### Defined in
[types/index.d.ts:19](https://github.com/isdk/bigint.js/blob/c098291/types/index.d.ts#L19)