you can't do that... it's a chicken and egg problem

if you are going to make a canonical binary encoding, exactly the same as the json canonical you do not hash on the hash (obviously) or the signature (also obviously) but when i say obviously, you don't realise that until you think about it

the ID and signature are external to the event, even if they appear in the naive version sent over the wire, that is only there really for fast access, a convenience, but to make the hash again you remove the signature and ID from the event and remove the object keys and replace it with a strict faithful ordering as received otherwise

the same rules can be applied to a binary encoding, so a hypothetical "b" tag could be added with other variations but if the signature is missing that is not an available verification method, so fall back to the json canonical for that, as the signature field is also present there, and would be retained in a binary wire format for the same reason (legacy, perhaps, but probably it will never go away, and good i say)

so, yeah, in summary IDs and Signature fields are inherently external to the data, thus they can be added or removed with impunity and if we were to propose a NIP to use them, this makes it simpler to explain, "b tags must not be added in the canonical form to derive the json ID hash"

in this way the event can be sent on the wire with this binary signature on it, enabling the forming of the binary encoding corresponding to it later, but it has to be omitted

so, yeah, maybe that's too complicated for people's brains, but ultimately that's how it would have to work

yes, I’m also saying the new binary signature is another detached field like id/sig

Reply to this note

Please Login to reply.

Discussion

but how to preserve it in the json object so the binary version can be derived/verified from it? easier to stick with existing fields but define a strict meaning to one that is then essentially exempted from the indexing rule, this way clients won't break decoding it even if they don't use it

adding more keys to the object is going to break them, and you do want to keep these extra fields (sans ID) in other encodings

yes, my suggestion would be then, that you put the tags so it's `["b","",""] and the rest is implied by the canonical encoding rule

we don't have to have the ID in the wire format, period, so it doesn't have to be in the tag either, actually

i personally am very much in favour of making a gradual move towards this by suggesting that relays and clients with some nip-11 flag understand events that are in canonical format, and then you can add a futher tag with a list of supported encoders and the in-event signature for other formats, which are optional, only the json form is mandatory, can have signatures for your faster verification form the binary form. done.

also just need to point out - the signer of an event could make an after-the-fact amendment to add the tag with another tag that refers to the replaced version that gives you your new (multiple) signature tags as i described, much like the parameterised replaceable protocol already existing

Ok - this might be left curve but... Why would we not just encode using CBOR, then attach a signature. 🤷‍♂️ Seems like that's all we'd need.

Relays could destructure however they want for indexing but the data structure and event creation/encode/decode would be super simple.