import { ECDSA } from '@noble/curves/abstract/weierstrass.js'; import { Key, type Signer, Verifier } from './key'; import { RawMap } from './map'; /** * ECDSAKey implements the ECDSA signature algorithm for COSE, as defined in * RFC 9053. Use it with {@link Sign1Message} or {@link SignMessage}. * * Construction signature: `generate(alg, kid?)` — the first argument is the * algorithm (`ES256`/`ES384`/`ES512`), which selects the curve. * * @example * ```ts * const key = ECDSAKey.generate(iana.AlgorithmES256, 'signing-key-1') * const cose = new Sign1Message(payload).toBytes(key) * Sign1Message.fromBytes(key.public(), cose) * ``` * * @see https://datatracker.ietf.org/doc/html/rfc9053#name-ecdsa */ export declare class ECDSAKey extends Key implements Signer, Verifier { /** Decodes a COSE_Key from CBOR bytes into an ECDSAKey. */ static fromBytes(data: Uint8Array): ECDSAKey; /** * Generates a new ECDSA private key for the given algorithm. * * @param alg - The ECDSA algorithm: `iana.AlgorithmES256`, * `iana.AlgorithmES384`, or `iana.AlgorithmES512`. * @param kid - Optional key id. */ static generate(alg: number, kid?: T): ECDSAKey; /** * Imports an ECDSA private key from raw scalar bytes. The algorithm and curve * are inferred from the secret length (32 → ES256, 48 → ES384, ≥65 → ES512). * * @param secret - The raw private scalar bytes. * @param kid - Optional key id. */ static fromSecret(secret: Uint8Array, kid?: T): ECDSAKey; /** * Imports an ECDSA public (verify-only) key from a SEC1 point. Compressed * (`0x02`/`0x03`) and uncompressed (`0x04`) encodings are accepted; the * algorithm and curve are inferred from the point length. * * @param pubkey - The SEC1-encoded public key bytes. * @param kid - Optional key id. */ static fromPublic(pubkey: Uint8Array, kid?: T): ECDSAKey; constructor(kv?: RawMap); get alg(): number; set alg(alg: number); getSecretKey(): Uint8Array; getPublicKey(): Uint8Array; /** * Returns a verify-only copy of this key: the private scalar is removed and * `key_ops` (if present) is narrowed to verify. */ public(): ECDSAKey; sign(message: Uint8Array): Uint8Array; verify(message: Uint8Array, signature: Uint8Array): boolean; } export declare function getCrv(alg: number): number; export declare function getCurve(alg: number): ECDSA;