Repository navigation
Add decode and verify commands - #14
Merged
Merged
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two read-only utility commands.
decode (closes #10)
Decodes a NIP-19 bech32 entity (or bare hex pubkey) into its underlying fields, one
label valueline per field:npub/nsec/note-> hex pubkey / seckey / idnprofile/nevent/naddr(andnoffer/ndebit/nmanage) -> pubkey/id/kind/identifier plus any embedded relay hintsBacked by
bech32.decodeNostr. Undecodable input printsinvalid: ...and exits non-zero.verify (closes #11)
Reads an event from an arg or stdin, recomputes its id from the canonical NIP-01 form, confirms it matches the
idfield, and verifies the Schnorr signature. Printsvalid, orinvalid: <reason>and exits non-zero on id mismatch, bad signature, malformed JSON, or a far-futurecreated_at. Backed byEvent.validate.Verified manually against NIP-19 test vectors (npub/nsec/note/nprofile) and round-tripped signed events (valid, tampered content -> id mismatch, tampered sig -> sig mismatch, malformed -> error).
zig buildandzig build testpass.Follow-up:
encode(#12) andfetch(#13).