libnexa-ts
Version:
A pure and powerful Nexa SDK library.
54 lines • 2.35 kB
TypeScript
import { default as BN } from 'bn.js';
import { BNOptions } from '../common/interfaces';
export default class BNExtended extends BN {
static Zero: BNExtended;
static One: BNExtended;
static Minus1: BNExtended;
static fromNumber(num: number): BNExtended;
static fromBigInt(num: bigint): BNExtended;
static fromString(str: string, base?: number | "hex"): BNExtended;
static fromBuffer(buf: Uint8Array, opts?: BNOptions): BNExtended;
/**
* Create a BN from a "ScriptNum":
* This is analogous to the constructor for CScriptNum in nexad. Many ops in
* nexad's script interpreter use CScriptNum, which is not really a proper
* bignum. Instead, an error is thrown if trying to input a number bigger than
* 4 bytes. We copy that behavior here. A third argument, `size`, is provided to
* extend the hard limit of 4 bytes, as some usages require more than 4 bytes.
*/
static fromScriptNumBuffer(buf: Uint8Array, fRequireMinimal?: boolean, size?: number): BNExtended;
add(b: BN): BNExtended;
sub(b: BN): BNExtended;
mul(b: BN): BNExtended;
mod(b: BN): BNExtended;
umod(b: BN): BNExtended;
invm(b: BN): BNExtended;
neg(): BNExtended;
toNumber(): number;
toBigInt(): bigint;
toByteArray(opts?: BN.Endianness | BNOptions, length?: number): Uint8Array;
/**
* The corollary to the above, with the notable exception that we do not throw
* an error if the output is larger than four bytes. (Which can happen if
* performing a numerical operation that results in an overflow to more than 4
* bytes).
*/
toScriptNumBuffer(): Uint8Array;
toScriptBigNumBuffer(): Uint8Array;
getSize(): number;
safeAdd(bigNumToAdd: BNExtended, maxSize: number): BNExtended;
safeSub(bigNumToSubtract: BNExtended, maxSize: number): BNExtended;
safeMul(bigNumToMultiply: BNExtended, maxSize: number): BNExtended;
private checkOperationForOverflow;
private toSMBigEndian;
private toBigNumSMBigEndian;
private toSM;
/**
* Instantiate a BigNumber from a "signed magnitude buffer"
* (a buffer where the most significant bit represents the sign (0 = positive, -1 = negative))
*/
private static fromSM;
private static trim;
private static pad;
}
//# sourceMappingURL=bn.extension.d.ts.map