UNPKG

@ecash/lib

Version:

Library for eCash transaction building

184 lines (179 loc) 5.42 kB
/* tslint:disable */ /* eslint-disable */ /** * Calculate SHA512(data). * @param {Uint8Array} data * @returns {Uint8Array} */ export function sha512(data: Uint8Array): Uint8Array; /** * Calculate SHA256(SHA256(data)). * @param {Uint8Array} data * @returns {Uint8Array} */ export function sha256d(data: Uint8Array): Uint8Array; /** * Calculate SHA256(data). * @param {Uint8Array} data * @returns {Uint8Array} */ export function sha256(data: Uint8Array): Uint8Array; /** * Calculate RIPEMD160(SHA256(data)), commonly used as address hash. * @param {Uint8Array} data * @returns {Uint8Array} */ export function shaRmd160(data: Uint8Array): Uint8Array; /** * ECC signatures with libsecp256k1. */ export class Ecc { free(): void; /** * Create a new Ecc instance. */ constructor(); /** * Derive a public key from secret key. * @param {Uint8Array} seckey * @returns {Uint8Array} */ derivePubkey(seckey: Uint8Array): Uint8Array; /** * Sign an ECDSA signature. * @param {Uint8Array} seckey * @param {Uint8Array} msg * @returns {Uint8Array} */ ecdsaSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array; /** * Sign a Schnorr signature. * @param {Uint8Array} seckey * @param {Uint8Array} msg * @returns {Uint8Array} */ schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array; /** * Return whether the given secret key is valid, i.e. whether is of correct * length (32 bytes) and is on the curve. * @param {Uint8Array} seckey * @returns {boolean} */ isValidSeckey(seckey: Uint8Array): boolean; /** * Add a scalar to a secret key. * @param {Uint8Array} a * @param {Uint8Array} b * @returns {Uint8Array} */ seckeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array; /** * Add a scalar to a public key (adding G*b). * @param {Uint8Array} a * @param {Uint8Array} b * @returns {Uint8Array} */ pubkeyAdd(a: Uint8Array, b: Uint8Array): Uint8Array; } /** * Instance to calculate SHA256 in a streaming fashion */ export class Sha256H { free(): void; /** * Create new hasher instance */ constructor(); /** * Feed bytes into the hasher * @param {Uint8Array} data */ update(data: Uint8Array): void; /** * Finalize the hash and return the result * @returns {Uint8Array} */ finalize(): Uint8Array; /** * Clone the hasher * @returns {Sha256H} */ clone(): Sha256H; } /** * Instance to calculate SHA512 in a streaming fashion */ export class Sha512H { free(): void; /** * Create new hasher instance */ constructor(); /** * Feed bytes into the hasher * @param {Uint8Array} data */ update(data: Uint8Array): void; /** * Finalize the hash and return the result * @returns {Uint8Array} */ finalize(): Uint8Array; /** * Clone the hasher * @returns {Sha512H} */ clone(): Sha512H; } export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly sha512h_new: () => number; readonly sha512h_update: (a: number, b: number, c: number) => void; readonly sha512h_finalize: (a: number, b: number) => void; readonly sha512h_clone: (a: number) => number; readonly __wbg_sha512h_free: (a: number) => void; readonly sha256h_new: () => number; readonly sha256h_update: (a: number, b: number, c: number) => void; readonly sha256h_finalize: (a: number, b: number) => void; readonly sha256h_clone: (a: number) => number; readonly __wbg_sha256h_free: (a: number) => void; readonly sha512: (a: number, b: number, c: number) => void; readonly sha256d: (a: number, b: number, c: number) => void; readonly sha256: (a: number, b: number, c: number) => void; readonly shaRmd160: (a: number, b: number, c: number) => void; readonly ecc_new: () => number; readonly ecc_derivePubkey: (a: number, b: number, c: number, d: number) => void; readonly ecc_ecdsaSign: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly ecc_schnorrSign: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly ecc_isValidSeckey: (a: number, b: number, c: number) => number; readonly ecc_seckeyAdd: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly ecc_pubkeyAdd: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly __wbg_ecc_free: (a: number) => void; readonly ecash_secp256k1_context_create: (a: number) => number; readonly ecash_secp256k1_context_destroy: (a: number) => void; readonly secp256k1_default_illegal_callback_fn: (a: number, b: number) => void; readonly secp256k1_default_error_callback_fn: (a: number, b: number) => void; readonly __wbindgen_export_0: (a: number, b: number) => number; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export_1: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {SyncInitInput} module * * @returns {InitOutput} */ export function initSync(module: SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {InitInput | Promise<InitInput>} module_or_path * * @returns {Promise<InitOutput>} */ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;