Skip to main content
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.

Sign, Recover, and Address Derivation

Quick Start

Representations

API Reference

Signing, Verification, and Recovery

Key Management, ECDH, and Point Math

Sub-Namespaces and Constants

  • Secp256k1.Signature: fromBytes, fromCompact, toBytes, toCompact
  • Secp256k1.PublicKey: from, fromBytes
  • Secp256k1.PrivateKey: re-exported @tevm/voltaire/PrivateKey methods
  • CURVE_ORDER: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n
  • PRIVATE_KEY_SIZE = 32, PUBLIC_KEY_SIZE = 64, SIGNATURE_COMPONENT_SIZE = 32

Security Invariants and EIP-2 Malleability

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).