Digital signatures

ECDSA-secp256k1

Elliptic Curve Digital Signature Algorithm on NIST curves and secp256k1

standard Safe API

About ECDSA-secp256k1

ECDSA-secp256k1 is one of 13 ECDSA variants in the NextSSL registry, a digital signature scheme. It uses a 65-byte public key, a 32-byte secret key, a 64-byte signature and a 32-byte seed. It takes the parameter deterministic (default 0). Its registry entry cites SEC 2, RFC 6979 and RFC 8812. It is also known as es256k. NextSSL lists it in the standard tier and exposes it through the safe API.

Overview

ECDSA is the elliptic-curve version of the Digital Signature Algorithm and the most widely deployed signature scheme on the internet. It provides compact, fast classical signatures but is not secure against large quantum computers.

A key pair is a secret scalar d and a public point Q = dG on an elliptic curve. To sign, the signer picks a per-signature secret nonce k, computes the x-coordinate r of kG, and combines r, the message hash and d into the value s. Verification uses only Q, the hash and (r, s). Security relies on the elliptic curve discrete logarithm problem.

The nonce is the scheme's weak point. Reusing k, or leaking even a few bits of it across many signatures, allows recovery of the private key, as happened with the Sony PlayStation 3 signing key and several cryptocurrency wallets. RFC 6979 deterministic nonce generation removes the dependence on a random number generator, and FIPS 186-5 permits it. ECDSA signatures are also malleable: (r, -s) is a valid signature when (r, s) is.

Four curves are present: NIST P-256, P-384 and P-521, as specified in FIPS 186-5 and SEC 2, and secp256k1, the Koblitz curve used by Bitcoin and Ethereum and registered for JOSE and COSE in RFC 8812. Hashes are normally SHA-256 for P-256 and secp256k1, SHA-384 for P-384 and SHA-512 for P-521. Signatures are commonly encoded either as a DER sequence or as fixed-length r and s concatenated.

History

1992–2023
  1. ECDSA proposed by Scott Vanstone

  2. Standardised in ANSI X9.62

  3. Added to FIPS 186-2

  4. Deterministic nonces specified in RFC 6979

  5. FIPS 186-5 published

How it works

  1. KeyGen picks a random scalar d and computes Q = dG.
  2. Sign hashes the message to e, chooses a nonce k (random or per RFC 6979), and sets r = x(kG) mod n.
  3. It computes s = k^-1 (e + r*d) mod n and outputs (r, s).
  4. Verify computes u1 = e/s and u2 = r/s and checks that x(u1*G + u2*Q) equals r.

Security notes

Broken by a large quantum computer running Shor's algorithm, so migration to ML-DSA or hybrid signatures is advised for long-lived keys. Nonce reuse or bias leaks the private key; use RFC 6979 or hedged nonces and constant-time scalar multiplication.

Typical uses

TLS certificates and WebPKICryptocurrency transactions on secp256k1JWT/JOSE and COSE token signingCode and document signing

Sizes

FieldBytesMeaning
pk65Public key
sk32Secret key
sig64Signature
seed32Seed
ctx0Context string

Parameters

NameTypeRangeDefaultRequired
deterministic u32 0 – 1 0 no

Parameters are passed as a string, for example nextssl_mac("hmac", "hash=sha512", …). Omitted parameters take their declared default.

Use it

from nextssl_demo import NextSSL

ns = NextSSL()              # safe API: safe and standard tiers
pk, sk = ns.call("sign_keygen", "ecdsa-secp256k1", None, outs=2)
sig = ns.call("sign_detached", "ecdsa-secp256k1", None, sk, b"message", b"")[0]
ok  = ns.check("verify_detached", "ecdsa-secp256k1", None, pk, b"message", b"", sig)

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Frequently asked questions

What is ECDSA-secp256k1?

ECDSA-secp256k1 is a signature in the ECDSA family. ECDSA is the elliptic-curve version of the Digital Signature Algorithm and the most widely deployed signature scheme on the internet. It is also known as es256k.

What are the ECDSA-secp256k1 sizes?

In NextSSL, ECDSA-secp256k1 uses: public key 65 bytes, signature 64 bytes.

Is ECDSA-secp256k1 post-quantum?

No. ECDSA-secp256k1 is a classical signature based on elliptic curves or discrete logarithms, which a large quantum computer running Shor's algorithm could break. For post-quantum use, look at ML-DSA or SLH-DSA.

Who designed ECDSA-secp256k1 and when?

ECDSA-secp256k1 belongs to the ECDSA family, first published in 1992 by Scott Vanstone (proposal); standardised by ANSI and NIST. Its origin: FIPS 186-5, ANSI X9.62, SEC 1.

Which standards define ECDSA-secp256k1?

ECDSA-secp256k1 is referenced by SEC 2, RFC 6979, RFC 8812.

Is ECDSA-secp256k1 safe to use?

ECDSA-secp256k1 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.

What other ECDSA variants are there?

NextSSL also registers ecdsa-p256, ecdsa-p384, ecdsa-p521, libecc-ecdsa-brainpoolp256r1-sha256, libecc-ecdsa-brainpoolp320r1-sha384, libecc-ecdsa-brainpoolp384r1-sha384 and more in the ECDSA family.