Skip to content

feat: BRC-42 key derivation (#140)#144

Merged
sgbett merged 3 commits intomasterfrom
feature/140-brc42-key-derivation
Mar 7, 2026
Merged

feat: BRC-42 key derivation (#140)#144
sgbett merged 3 commits intomasterfrom
feature/140-brc42-key-derivation

Conversation

@sgbett
Copy link
Copy Markdown
Owner

@sgbett sgbett commented Mar 7, 2026

Summary

  • Add PrivateKey#derive_child(public_key, invoice_number) — BRC-42 private key derivation
  • Add PublicKey#derive_child(private_key, invoice_number) — BRC-42 public key derivation
  • 9 official BRC-42 spec test vectors (5 private key, 4 public key) all passing
  • 8 unit specs + 13 conformance specs (21 new specs total)

Implements HLR #140. Completes the last Tier 1 gap in the SDK.

Test plan

  • All 9 official BRC-42 test vectors pass (from the BRC specification)
  • Key pair correspondence: priv.derive_child(pub, inv).public_key == pub.derive_child(priv, inv)
  • Different invoice numbers produce different keys
  • Derived keys are valid curve scalars
  • Full suite: 1497 examples, 0 failures

🤖 Generated with Claude Code

sgbett and others added 3 commits March 7, 2026 03:37
BRC-42 key derivation using ECDH shared secret + HMAC-SHA256.
PrivateKey adds scalar, PublicKey adds point — derived keys form
valid pairs matching all three reference SDKs.

Implements sub-task #141 of HLR #140.

Co-Authored-By: Claude <noreply@anthropic.com>
8 specs covering return types, key differentiation, invoice number
variation, determinism, and key pair correspondence between
PrivateKey#derive_child and PublicKey#derive_child.

Implements sub-task #142 of HLR #140.

Co-Authored-By: Claude <noreply@anthropic.com>
13 specs including 9 official BRC-42 test vectors (5 private key,
4 public key) from the BRC specification, plus key pair correspondence,
invoice variation, validity, and determinism properties.

Implements sub-task #143 of HLR #140.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sgbett sgbett merged commit 6968107 into master Mar 7, 2026
7 checks passed
@sgbett sgbett deleted the feature/140-brc42-key-derivation branch March 7, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant