Files
solon/scripts
GandClaude Opus 5 55f993cf93 deps: @noble v3, proven byte-identical on the signing path (#85)
@noble/secp256k1 2.3.0 -> 3.1.0 and @noble/hashes 1.8.0 -> 2.3.0. Both are
breaking majors on the code that decides whether a vote is real, so the
interesting part is not the upgrade — it is the evidence that it changed
nothing.

The tests could not supply that evidence. Every one of them signed and
verified with the same code, so a change that altered the wire format on both
sides would have passed all fifteen while silently invalidating every
signature a real wallet produces. Four known-answer tests now close that:

- Address derivation is anchored to BIP173's own published vector. The key is
  secret exponent 1, so its public key is the secp256k1 generator and its
  P2WPKH address is the one written into the spec.
- The signed-message digest is rebuilt from the spec inside the test rather
  than imported, and compared byte for byte.
- The signature base64 is asserted literally. RFC6979 makes signing
  deterministic, so this is stable across versions unless nonce derivation or
  encoding moved.
- OpenSSL, via node:crypto, verifies the signature independently. It is the
  only check in the repo that is not noble verifying noble.

All four were written and run against v2 first, so they are known to hold
before the upgrade rather than fitted to it afterwards. They pass unchanged on
v3: the golden signature is the same base64, so every signature already stored
in the treasury's audit trail still verifies.

The API moves themselves:

- hmac wiring is now secp.hashes.{sha256,hmacSha256}, and hmacSha256 takes a
  single message instead of varargs.
- sign() returns bytes, not a Signature. Recovery comes from
  format: 'recovered' (65 bytes, recovery || r || s), and prehash: false is
  now load-bearing — the Bitcoin digest is already double-sha256, and letting
  the library hash again would sign the wrong value.
- Signature.fromCompact().recoverPublicKey() became the top-level
  recoverPublicKey(), so verification rebuilds the recovered encoding from the
  Bitcoin header || r || s layout.
- randomPrivateKey -> randomSecretKey; secret keys are bytes, no longer hex.
- @noble/hashes v2 moved its submodules: sha256 to sha2.js, ripemd160 to
  legacy.js, and every deep import now needs the .js extension.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 14:44:28 +00:00
..