mleku on Nostr: you can't do that... it's a chicken and egg problem if you are going to make a ...
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
Published at
2024-10-07 17:24:08Event JSON
{
"id": "1757cb50bc68daacd56ecbc589f3470425c3480022fdb0faf33ce60f23d2f44f",
"pubkey": "4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f",
"created_at": 1728321848,
"kind": 1,
"tags": [
[
"e",
"61d540a890c7b8df120b3c8b6440acb1395ff335ae82b47932dfe61d6f45fd11",
"wss://relay.noswhere.com/",
"root"
],
[
"e",
"8107332026d1faa5c53433f3fdbd2133adccfb84dbf5653bc2969c779fc00be9",
"",
"reply"
],
[
"p",
"52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd",
"",
"mention"
],
[
"p",
"1739d937dc8c0c7370aa27585938c119e25c41f6c441a5d34c6d38503e3136ef",
"",
"mention"
],
[
"client",
"noStrudel",
"31990:266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5:1686066542546"
]
],
"content": "you can't do that... it's a chicken and egg problem\n\nif 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\n\nthe 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\n\nthe 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)\n\nso, 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\"\n\nin 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\n\nso, yeah, maybe that's too complicated for people's brains, but ultimately that's how it would have to work",
"sig": "d9ec966a9a4d8dea9c1c6725b888a061a04982491e4768d792eba8084dfd3c2d8d5ee3ec03f833e71c812218f578a56112e58fcbaf260d7b57e653124b2483d3"
}