libnemo
Version:
Nano cryptocurrency wallet library.
168 lines (167 loc) • 6.57 kB
TypeScript
export declare class base32 {
/**
* Convert a base32 string to a Uint8Array of bytes.
*
* @param {string} base32 - String to convert
* @returns {Uint8Array} Byte array representation of the input string
*/
static toBytes(base32: string): Uint8Array<ArrayBuffer>;
/**
* Convert a base32 string to an ArrayBuffer.
*
* @param {string} base32 - String to convert
* @returns {Uint8Array} Byte array representation of the input string
*/
static toBuffer(base32: string): ArrayBuffer;
}
export declare class bin {
/**
* Convert a binary string to a Uint8Array of bytes.
*
* @param {string} bin - String to convert
* @returns {Uint8Array} Byte array representation of the input string
*/
static toBytes(bin: string): Uint8Array<ArrayBuffer>;
}
export declare class bytes {
static decoder: TextDecoder;
/**
* Write zeroes to memory to erase bytes and then transfers the buffer to
* render it inaccessible to any process.
*
* @param bytes - Buffer or bytes to erase
*/
static erase(bytes?: ArrayBuffer | Uint8Array<ArrayBuffer> | null): void;
/**
* Convert a Uint8Aarray of bytes to a base32 string.
*
* @param {Uint8Array} bytes - Byte array to convert
* @returns {string} Base32 string representation of the input bytes
*/
static toBase32(bytes: ArrayBuffer | Uint8Array): string;
/**
* Convert a Uint8Array of bytes to a binary string.
*
* @param {Uint8Array} bytes - Byte array to convert
* @returns {string} Binary string representation of the input value
*/
static toBin(bytes: Uint8Array<ArrayBuffer>): string;
/**
* Sum an array of bytes to a decimal integer. If the result is larger than
* Number.MAX_SAFE_INTEGER, it will be returned as a bigint.
*
* @param {Uint8Array} bytes - Byte array to convert
* @returns {bigint|number} Decimal sum of the literal byte values
*/
static toDec(bytes: Uint8Array): bigint | number;
/**
* Convert a Uint8Array of bytes to a hexadecimal string.
*
* @param {Uint8Array} bytes - Byte array to convert
* @returns {string} Hexadecimal string representation of the input bytes
*/
static toHex(bytes: ArrayBuffer | Uint8Array): string;
/**
* Convert a Uint8Array of bytes to a UTF-8 text string.
*
* @param {Uint8Array} bytes - Byte array to convert
* @returns {string} UTF-8 encoded text string
*/
static toUtf8(bytes: Uint8Array<ArrayBuffer>): string;
}
export declare class dec {
/**
* Convert a decimal integer to a binary string.
*
* @param {bigint|number|string} decimal - Integer to convert
* @param {number} [padding=0] - Minimum length of the resulting string padded as necessary with starting zeroes
* @returns {string} Binary string representation of the input decimal
*/
static toBin(decimal: bigint | number | string, padding?: number): string;
/**
* Convert a decimal integer to a Uint8Array of bytes. Fractional part is truncated.
*
* @param {bigint|number|string} decimal - Integer to convert
* @param {number} [padding=0] - Minimum length of the resulting array padded as necessary with starting 0x00 bytes
* @returns {Uint8Array} Byte array representation of the input decimal
*/
static toBytes(decimal: bigint | number | string, padding?: number): Uint8Array<ArrayBuffer>;
/**
* Convert a decimal integer to a hexadecimal string.
*
* @param {(bigint|number|string)} decimal - Integer to convert
* @param {number} [padding=0] - Minimum length of the resulting string padded as necessary with starting zeroes
* @returns {string} Hexadecimal string representation of the input decimal
*/
static toHex(decimal: bigint | number | string, padding?: number): string;
}
export declare class hex {
/**
* Convert a hexadecimal string to an array of decimal byte values.
*
* @param {string} hex - Hexadecimal number string to convert
* @param {number}[padding=0] - Minimum length of the resulting array padded as necessary with starting 0 values
* @returns {number[]} Decimal array representation of the input value
*/
static toArray(hex: string, padding?: number): number[];
/**
* Convert a hexadecimal string to a binary string.
*
* @param {string} hex - Hexadecimal number string to convert
* @returns {string} Binary string representation of the input value
*/
static toBin(hex: string): string;
/**
* Convert a hexadecimal string to an ArrayBuffer.
*
* @param {string} hex - Hexadecimal number string to convert
* @param {number} [padding=0] - Minimum length of the resulting array padded as necessary with starting 0x00 bytes
* @returns {ArrayBuffer} Buffer representation of the input value
*/
static toBuffer(hex: string, padding?: number): ArrayBuffer;
/**
* Convert a hexadecimal string to a Uint8Array of bytes.
*
* @param {string} hex - Hexadecimal number string to convert
* @param {number} [padding=0] - Minimum length of the resulting array padded as necessary with starting 0x00 bytes
* @returns {Uint8Array} Byte array representation of the input value
*/
static toBytes(hex: string, padding?: number): Uint8Array<ArrayBuffer>;
}
export declare class obj {
/**
* Convert a numerically-indexed object of 8-bit values to a Uint8Array of bytes.
*
* @param {object} obj - Object to convert
* @returns {Uint8Array} Byte array representation of the input object
*/
static toBytes(obj: {
[key: number]: number;
}): Uint8Array<ArrayBuffer>;
}
export declare class utf8 {
static encoder: TextEncoder;
/**
* Convert a UTF-8 text string to an ArrayBuffer.
*
* @param {string} utf8 - String to convert
* @returns {ArrayBuffer} Buffer representation of the input string
*/
static toBuffer(utf8: string): ArrayBuffer;
/**
* Convert a UTF-8 text string to a Uint8Array of bytes.
*
* @param {string} utf8 - String to convert
* @returns {Uint8Array} Byte array representation of the input string
*/
static toBytes(utf8: string): Uint8Array<ArrayBuffer>;
/**
* Convert a string to a hexadecimal representation
*
* @param {string} utf8 - String to convert
* @returns {string} Hexadecimal representation of the input string
*/
static toHex(utf8: string): string;
}
declare const _default: string;
export default _default;