import BigNumber from './BigNumber.js'; import Signature from './Signature.js'; import Point from './Point.js'; /** * Generates a digital signature for a given message. * * @function sign * @param msg - The BigNumber message for which the signature has to be computed. * @param key - Private key in BigNumber. * @param forceLowS - Optional boolean flag if True forces "s" to be the lower of two possible values. * @param customK - Optional specification for k value, which can be a function or BigNumber. * @returns Returns the elliptic curve digital signature of the message. * * @example * const msg = new BigNumber('2664878') * const key = new BigNumber('123456') * const signature = sign(msg, key) */ /** * SECURITY NOTE: * * This function implements ECDSA signing and expects `msg` to be the output of * a cryptographic hash function (e.g. SHA-256), not an arbitrary-length message. * * Per FIPS 186-4 / SEC 1, the message representative used by ECDSA must not * exceed the bit length of the curve order `n`. Inputs larger than `n` must be * hashed before signing. * * As a short-term mitigation for TOB-22, this implementation explicitly rejects * messages whose bit length exceeds that of the curve order. * * Long-term, callers SHOULD always hash messages before invoking `sign()`. */ export declare const sign: (msg: BigNumber, key: BigNumber, forceLowS?: boolean, customK?: BigNumber | ((iter: number) => BigNumber)) => Signature; /** * Verifies a digital signature of a given message. * * Message and key used during the signature generation process, and the previously computed signature * are used to validate the authenticity of the digital signature. * * @function verify * @param msg - The BigNumber message for which the signature has to be verified. * @param sig - Signature object consisting of parameters 'r' and 's'. * @param key - Public key in Point. * @returns Returns true if the signature is valid and false otherwise. * * @example * const msg = new BigNumber('2664878', 16) * const key = new Point(new BigNumber(10), new BigNumber(20) * const signature = sign(msg, new BigNumber('123456')) * const isVerified = verify(msg, sig, key) */ /** * SECURITY NOTE: * * This verification routine assumes that `msg` is a hashed message * representative produced using the same hash function used during signing. * * As part of TOB-22 short-term hardening, messages exceeding the curve order * bit length are rejected to prevent misuse with non-hashed inputs. */ export declare const verify: (msg: BigNumber, sig: Signature, key: Point) => boolean; //# sourceMappingURL=ECDSA.d.ts.map