UNPKG

tiny-crypto-suite

Version:

Tiny tools, big crypto — seamless encryption and certificate handling for modern web and Node apps.

79 lines 3.54 kB
export default TinyEthSecp256k1; declare class TinyEthSecp256k1 extends TinySecp256k1 { /** @typedef {import('js-sha3')} JsSha3 */ /** @typedef {import('elliptic').ec.KeyPair} KeyPair */ /** @typedef {import('./index.mjs').ValidationResult} ValidationResult */ /** * Creates an instance of TinyEthSecp256k1. * * @param {Object} [options] - Optional parameters for the instance. * @param {string|null} [options.prefix='0x'] - Crypto prefix used during message verification. * @param {'keccak256'} [options.type='keccak256'] - The type of address to generate. * @param {string|null} [options.msgPrefix='\x19Ethereum Signed Message:\n'] - Message prefix used during message signing. * @param {string|null} [options.privateKey=null] - String representation of the private key. * @param {BufferEncoding} [options.privateKeyEncoding='hex'] - Encoding used for the privateKey string. */ constructor({ prefix, type, msgPrefix, privateKey, privateKeyEncoding, }?: { prefix?: string | null | undefined; type?: "keccak256" | undefined; msgPrefix?: string | null | undefined; privateKey?: string | null | undefined; privateKeyEncoding?: BufferEncoding | undefined; }); /** * Dynamically imports the `jsSha3` module and stores it in the instance. * Ensures the module is loaded only once (lazy singleton). * * @returns {Promise<JsSha3>} The loaded `jsSha3` module. */ fetchJsSha3(): Promise<typeof import("js-sha3")>; jsSha3: typeof import("js-sha3") | undefined; /** * Returns the initialized `jsSha3` instance from the jsSha3 module. * * @returns {JsSha3} The jsSha3 instance. * @throws Will throw an error if `jsSha3` is not initialized. */ getJsSha3(): typeof import("js-sha3"); /** * Returns the public key in hexadecimal. * @returns {string} */ getPublicKeyHex(): string; /** * Generate the Ethereum address from the public key. * @param {Buffer} [pubKey=this.getPublicKeyBuffer(false).subarray(1)] - The pubKey buffer (remove byte 0x04). * @returns {string} */ getAddress(pubKey?: Buffer): string; /** * Returns the public key in vanilla format. * * @returns {Buffer} Hash160 representation of the public key. */ getPubVanillaAddress(): Buffer; /** * Returns the address in keccak256 format. * * @param {string} address - Whether to return the compressed version of the key. * @returns {Buffer} - Hash160 representation of the public key. */ addressToVanilla(address: string): Buffer; /** * Recovers the address from the message and the signature. * @param {string|Buffer} message The original message. * @param {Buffer|string} signature - Signature in DER format (base64-encoded or Buffer). * @param {Object} [options] - Optional signing parameters. * @param {BufferEncoding} [options.encoding='utf8'] - Encoding for input message if it is a string. * @param {string} [options.prefix] - Optional prefix (defaults to Ethereum prefix or instance default). * @returns {string|null} */ recoverMessage(message: string | Buffer, signature: Buffer | string, options?: { encoding?: BufferEncoding | undefined; prefix?: string | undefined; }): string | null; #private; } import TinySecp256k1 from './index.mjs'; import { Buffer } from 'buffer'; //# sourceMappingURL=TinyEthSecp256k1.d.mts.map