UNPKG

ecash-lib

Version:

Library for eCash transaction building

181 lines (180 loc) 4.56 kB
/* tslint:disable */ /* eslint-disable */ /** * Verify a signature for the given cryptographic algorithm. * Intended to be used in X509 certificate verification. * Throw an exception if the algorithm is not supported. * @param {string} algo_oid * @param {string | undefined} params * @param {Uint8Array} sig * @param {Uint8Array} msg * @param {Uint8Array} pk */ export function publicKeyCryptoVerify(algo_oid: string, params: string | undefined, sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void; /** * Throw an exception if the given algo is not supported, otherwise do nothing. * @param {string} algo_oid * @param {string | undefined} [params] */ export function publicKeyCryptoAlgoSupported(algo_oid: string, params?: string): void; /** * 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; /** * Verify an ECDSA signature. * @param {Uint8Array} sig * @param {Uint8Array} msg * @param {Uint8Array} pk */ ecdsaVerify(sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void; /** * Sign a Schnorr signature. * @param {Uint8Array} seckey * @param {Uint8Array} msg * @returns {Uint8Array} */ schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array; /** * Verify a Schnorr signature. * @param {Uint8Array} sig * @param {Uint8Array} msg * @param {Uint8Array} pk */ schnorrVerify(sig: Uint8Array, msg: Uint8Array, pk: Uint8Array): void; /** * 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; /** * Create a compact ECDSA signature (65 bytes), which allows reconstructing * the used public key. * The format is one header byte, followed by two times 32 bytes for the * serialized r and s values. * The header byte: 0x1B = first key with even y, * 0x1C = first key with odd y, * 0x1D = second key with even y, * 0x1E = second key with odd y, * add 0x04 for compressed keys. * @param {Uint8Array} seckey * @param {Uint8Array} msg * @returns {Uint8Array} */ signRecoverable(seckey: Uint8Array, msg: Uint8Array): Uint8Array; /** * Recover the public key of a signature signed by signRecoverable. * @param {Uint8Array} sig * @param {Uint8Array} msg * @returns {Uint8Array} */ recoverSig(sig: Uint8Array, msg: 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; }