协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
bitcoin-secp256k1【开发与工程】secp256k1 elliptic curve: parameters, group law, key encoding, point serialization, library bindings (libsecp256k1 in C, Rust, Python). USE WHEN: low-level key/point operations, debugging signature failures, understanding why Bitcoin uses this curve specifically.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
The elliptic curve Bitcoin uses for all signatures (ECDSA + Schnorr).
Defined by SECG (SEC 2: Recommended Elliptic Curve Domain Parameters).
p = 2^256 - 2^32 - 977 (the field prime)
a = 0
b = 7
G = (0x79BE667E_F9DCBBAC_55A06295_CE870B07_029BFCDB_2DCE28D9_59F2815B_16F81798,
0x483ADA77_26A3C465_5DA4FBFC_0E1108A8_FD17B448_A6855419_9C47D08F_FB10D4B8)
n = 0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFE_BAAEDCE6_AF48A03B_BFD25E8C_D0364141
h = 1 (cofactor)
The curve equation: y^2 = x^3 + 7 (mod p).
k*G is the public key for private scalar k.0x04 || x || y (32-byte each).0x02 || x if y even, 0x03 || x if y odd.x. Implicit even-y convention.λ = ... allows fast multiplication: any point P
has a known (λ·P) derivable cheaply, used in optimized scalar mult.The ~128-bit figure above is classical security. Shor's algorithm solves the discrete log on an elliptic curve in polynomial time, so no secp256k1 key size helps against a cryptographically relevant quantum computer; the exposed surface is any published public key (a Taproot x-only key sits in the scriptPubKey, a reused-address ECDSA key sits in a spent input). None of this changes how you sign or verify today.
Two consensus-track drafts frame the response. Both are Draft in the BIPs repo as of September 2026, with no activation parameters:
Detail lives in schnorr/SKILL.md (BIP340 key exposure) and ../../protocol/proposals/SKILL.md (output types, migration policy, rescue mechanics). libsecp256k1 ships no post-quantum module.
a^(p-2) mod p or
extended Euclidean. Constant-time required for security.The C library maintained at github.com/bitcoin-core/secp256k1:
secp256k1_ec_*, secp256k1_ecdsa_*,
secp256k1_xonly_* / secp256k1_keypair_* (extrakeys),
secp256k1_schnorrsig_* (BIP340), secp256k1_ecdh_*,
secp256k1_recovery_*, secp256k1_musig_* (MuSig2, BIP327 — the C
prefix has no 2), secp256k1_ellswift_* (BIP324),
secp256k1_silentpayments_* (BIP352). All modules are configure-time
options; as of master (September 2026) every one defaults to enabled
except recovery, which is off by default.secp256k1-frost is a third-party fork, not a
libsecp256k1 module — see frost/SKILL.md.rust-secp256k1, python-bitcoinlib (via cffi),
secp256k1-node, etc.Avoid rolling your own EC math in production. Subtle errors here are catastrophic.
v0.8.0 (2026-08-03). Modules are exactly: ecdh, ellswift, extrakeys, musig, recovery, schnorrsig, silentpayments.
silentpayments module (BIP352 send/receive; needs
full transaction data, no light-client scanning yet) and
secp256k1_context_set_sha256_compression. secp256k1_ellswift_xdh
now rejects secret keys >= the curve order instead of silently
reducing them.secp256k1_context_no_precomp (use
secp256k1_context_static), the secp256k1_schnorrsig_sign alias
(use secp256k1_schnorrsig_sign32) and the SECP256K1_GNUC_PREREQ
macro. The two symbols break old callers at link time; the macro
breaks them at compile time.const and
removed the deprecated secp256k1_ec_privkey_* aliases (use
secp256k1_ec_seckey_*); CMake minimum rose to 3.22 and CMake builds
stopped being experimental. v0.7.1 (2026-01-26) is maintenance: wider
stack-secret clearing, a parallel unit-test framework, and a fix for
an x86_64 assembly feature check that could silently fall back to the
slower C implementation.rust-secp256k1 (crate secp256k1) is at 0.33.1 on crates.io
(2026-08-29). The 0.32 series added MuSig2 support and removed the
Secp256k1 context from the public API in favour of a global
context — a breaking change for every caller.(P + Q) operations.n (group order) with p (field prime) — they differ.Math.random() in
JS) → catastrophic. Shipped-hardware case: Coldcard's July 2026
advisory — a build/link error routed rng_get() to MicroPython's
Yasmarang PRNG from March 2021 on (~40 bits of effective search space
on Mk2/Mk3, ~72 on Mk4/Mk5/Q, both preliminary). Fixed in 5.6.0
(Mk4/Mk5), 1.5.0Q (Q), 4.2.0 (Mk2/Mk3), Edge 6.6.0X/6.6.0QX; updating
does not repair an already-generated seed. Details in
../../hardware/coldcard/SKILL.md.