pawtils
Version:
This repository contains several utils to work with the cryptocurrency [Paw](https://paw.digital/) inside the browser.
110 lines • 4.31 kB
TypeScript
/**
* Decodes the provided base64 encoded wasm stub
* @param stub - The base64 wasm stub
*/
export declare function decodeWasmModule(stub: string): Uint8Array;
/**
* Clamps the provided number between the given min/max range
* @param num - The number to clamp
* @param min - The minimum clamp bound
* @param max - The maximum clamp bound
*/
export declare function clamp(num: number, min: number, max: number): number;
/**
* Converts the provided hex into the equivalent bytes
* @param hex - The hex to convert
*/
export declare function hexToBytes(hex: string): Uint8Array;
/**
* Converts the provided bytes into their hexadecimal equivalent
* @param bytes - The bytes to convert
*/
export declare function bytesToHex(bytes: Uint8Array): string;
/**
* Converts the provided bits into a number
* @param bits - The bits to convert
* @param bitStride - An optional bit stride
*/
export declare function bitsToNumber(bits: Uint8Array, bitStride?: number): number;
/**
* Converts the provided number into it's bit equivalent
* @param number - The number to convert
* @param bitStride - An optional bit stride
*/
export declare function numberToBits(number: number, bitStride?: number): Uint8Array;
/**
* Converts the provided bytes into their bit equivalent
* @param bytes - The bytes to convert
*/
export declare function bytesToBits(bytes: Uint8Array): Uint8Array;
/**
* Converts the provided 1-d bits into N-d bits
* @param bitsn - The 1-d bits to convert
* @param bitStride - The bit stride to use
*/
export declare function bitsToBitsN(bits: Uint8Array, bitStride: number): Uint8Array;
/**
* Converts the provided N-d bits into 1-d bits
* @param bitsn - The N-d bits to convert
* @param bitStride - The bit stride to use
*/
export declare function bitsNToBits(bitsn: Uint8Array, bitStride: number): Uint8Array;
/**
* Converts the provided decimal value into the hexadecimal equivalent
* @param decimal - The decimal value to convert
* @param bytes - The byte stride of the provided value
*/
export declare function decimalToHex(decimal: number, bytes: number): string;
/**
* Indicates if the provided seed is valid
* @param seed - The seed to check
*/
export declare function isSeedValid(seed: Uint8Array): boolean;
/**
* Indicates if the provided hash and work bytes are valid
* @param hash - The hash to validate
* @param work - The work to validate
* @param workMin - The minimum value of the work
*/
export declare function isWorkValid(hash: Uint8Array, work: Uint8Array, workMin: bigint): boolean;
/**
* Converts the provided amount into raw amount
* @param amount - The amount to convert
*/
export declare function getRawFromAmount(amount: string): bigint;
/**
* Converts the provided raw amount into amount
* @param amountRaw - The raw amount to convert
*/
export declare function getAmountFromRaw(amountRaw: bigint): any;
/**
* Returns the private key of the provided seed
* @param seed - The seed to derive from
* @param seedIx - The seed index
*/
export declare function getPrivateKey(seed: Uint8Array, seedIx?: number): Uint8Array;
/**
* Returns the public key of the provided input
* @param input - The private key or address to derive from
*/
export declare function getPublicKey(input: (Uint8Array | string)): Uint8Array;
/**
* Returns the relative address of the public key
* @param publicKey - The public key to derive the address from
*/
export declare function getAccountAddress(publicKey: Uint8Array): string;
/**
* Encrypts the provided hash with the given password
* @param hash - The hash to encrypt
* @param password - The password to encrypt the hash with
* @param iv - An optional initialization vector to encrypt with
*/
export declare function encryptHash(hash: Uint8Array, password: string, iv?: Uint8Array): Promise<Uint8Array>;
/**
* Decrypts the provided encrypted hash with the given password
* @param hash - The hash to decrypt
* @param password - The password to decrypt the hash with
* @param iv - An optional initialization vector to decrypt with
*/
export declare function decryptHash(hash: Uint8Array, password: string, iv?: Uint8Array): Promise<Uint8Array>;
//# sourceMappingURL=utils.d.ts.map