Add keys chapter

Introduces PublicKey and SecretKey as distinct type-safe wrappers around
secp256k1, with hex and NIP-19 bech32 (npub/nsec) encoding. SecretKey has
a redacted Debug impl and no Display to reduce accidental leakage; it
exposes material only through explicit to_hex / to_nsec. FromStr on both
types auto-detects hex vs. bech32. Eight round-trip tests cover encoding,
auto-detection, prefix validation, debug redaction, and generation.
This commit is contained in:
Jon Staab
2026-04-13 15:16:32 -07:00
parent ce4dce9779
commit 5364854881
9 changed files with 1248 additions and 2 deletions
+6 -1
View File
@@ -8,5 +8,10 @@ description = "Struct definitions and stateless utilities related to nostr"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
secp256k1 = { version = "0.29", features = ["global-context", "serde"] }
secp256k1 = { version = "0.29", features = ["global-context", "serde", "rand"] }
hex = "0.4"
bech32 = "0.11"
rand = "0.8"
scrypt = { version = "0.11", default-features = false, features = ["std"] }
chacha20poly1305 = "0.10"
unicode-normalization = "0.1"