/// import { Buffer } from 'buffer'; import { Curve } from './curve'; /** * An extended ECDSA signature {r, s, v}. */ export interface ECDSASignature { v: number; r: bigint; s: bigint; } export interface Transaction { nonce: number; gasPrice: number | bigint; gasLimit: number | bigint; to: string; value: number | bigint; data: Buffer | string; chainId?: number; } /** * Generate a deterministic value for `k`, according to RFC6979. * * @param {Buffer} hash * @param {Buffer} privateKey * @param {Curve} [curve] */ export declare const generateK: (hash: Buffer, privateKey: Buffer, curve?: Curve) => bigint; /** * Get the message hashed with `hash('\x19Ethereum Signed Message:\n32', hash(message))`. The hash used is Keccak-256, * and the output should match the hashes used by `eth_sign`. * * @param {status} message * @param {boolean} prefix * @return {Buffer} */ export declare const getHashedMessage: (message: string | Buffer, prefix?: boolean) => Buffer; /** * Sign a message with the private key. When `deterministic` is set to `true` (default), this will use RFC6979 * to generate a deterministic k value, otherwise a random k value is used. If a chainId is specified, this will use * EIP-155 for the `v` value. * * Note that the message is automatically hashed and prefixed, to match the hashes used by `eth_sign`, unless `prefix` * is disabled. * * @param {string} message * @param {Buffer} privateKey * @param {boolean} [deterministic] * @param {boolean} [prefix] * @param {number} [chainId] * @param {Curve} [curve] */ export declare const sign: (message: string | Buffer, privateKey: Buffer, deterministic?: boolean, prefix?: boolean, chainId?: number | undefined, curve?: Curve) => ECDSASignature; /** * Sign a transaction with a private key. Returns the RLP encoded signed transaction as Buffer. * * @param {Transaction} transaction * @param {number} chainId * @param {Buffer} privateKey * @return {Buffer} */ export declare const signTransaction: (transaction: Transaction, privateKey: Buffer) => { raw: Buffer; signed: Buffer; }; /** * Verify a message with a signature and public key. Returns true if the signature is valid, or false otherwise. * * @param {string} message * @param {ECDSASignature} signature * @param {Buffer} publicKey * @param {Curve} [curve] */ export declare const verify: (message: string, { r, s }: ECDSASignature, publicKey: Buffer, curve?: Curve) => boolean; /** * Recover an Ethereum address from a message and signature. Returns the address as string. * * @param {string} message * @param {ECDSASignature} signature * @param {Curve} [curve] */ export declare const recover: (message: string, { v, r, s }: ECDSASignature, curve?: Curve) => string;