Parse an event that carries a key NIP-01 does not name - #107
Merged
Merged
Conversation
fromJson and the relay message parser refused any key beyond the seven named fields with UnknownField, so a valid event carrying one was dropped, and on a relay connection it failed the whole EVENT message. The id and the signature cover the seven fields and nothing else, so the extra key is now skipped. A key named twice is still refused. Closes #106.
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.
Closes #106.
fromJsonand the relay message parser read the event object with defaultstd.jsonoptions, so a key beyond the seven NIP-01 names failed the parse withUnknownField. A valid event carrying one was dropped, and on a relay connection it failed the wholeEVENTmessage.The id is the hash of the seven named fields and the signature is over the id, so an extra key cannot change what was signed. Both parse paths now share one set of options that skips unknown keys. Duplicate keys are still refused: with two
contentkeys it would be ambiguous which one the signature covers.Tests
an event carrying a field NIP-01 does not name still parses and verifiessigns an event, adds an array-valued and a nested object-valued key, and checks that it parses, keeps its id, verifies, and writes back out byte-identical to what was signed. It failed withUnknownFieldbefore the change.parse EVENT message whose event carries a field NIP-01 does not namecovers the relay message path, which goes throughfromValueLeakyrather thanfromJson. It also failed before the change.an event naming the same field twice is still refusedpins the duplicate-key refusal so a later loosening of the options cannot drop it quietly.All 206 tests pass.