ECDSA signing, verification, public key recovery, ECDH, and curve arithmetic on secp256k1.
Secp256k1 implements deterministic ECDSA (RFC 6979), Ethereum public key recovery (v = 27 | 28), ECDH key agreement, and raw point operations over the secp256k1 curve (y^2 = x^3 + 7 mod p) backed by @noble/curves/secp256k1.js.
ECDSA signatures have a malleable twin: if (r, s, v) is valid, then (r, n - s, v ^ 1) is also valid on the curve. Ethereum (EIP-2) requires canonical low-s values (1 <= s <= n / 2).
Low-s canonicalization:Secp256k1.sign delegates to @noble/curves with low-s normalization enabled, producing EIP-2 canonical signatures by default.
Deterministic nonces (RFC 6979):sign derives the signing nonce deterministically from (privateKey, messageHash), preventing nonce-reuse private key recovery. Pass { extraEntropy: true } for hedged signatures against fault attacks.
Strict v checking:verify requires v === 27 || v === 28 and confirms in constant time that the recovered public key equals the supplied publicKey. recoverPublicKey accepts 0, 1, 27, or 28.
Errors:sign and derivePublicKey throw InvalidPrivateKeyError for non-32-byte or zero keys (CryptoError on unexpected signing failure). recoverPublicKey and verify throw InvalidSignatureError on malformed lengths or invalid v (for recoverPublicKey).