From b5a7b67d78ad2b8ea52d81704be6b71a9cc80dac Mon Sep 17 00:00:00 2001 From: Semisol <45574030+Semisol@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:02:15 +0300 Subject: [PATCH 1/4] Clarify JSON serialization for the `id` field --- 01.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/01.md b/01.md index 2ff81ebf..9258d2f7 100644 --- a/01.md +++ b/01.md @@ -30,7 +30,7 @@ The only object type that exists is the `event`, which has the following format } ``` -To obtain the `event.id`, we `sha256` the serialized event. The serialization is done over the UTF-8 JSON-serialized string (with no white space or line breaks) of the following structure: +To obtain the `event.id`, we `sha256` the serialized event. The serialization is done over the UTF-8 JSON-serialized string (which is described below) of the following structure: ```json [ @@ -43,6 +43,14 @@ To obtain the `event.id`, we `sha256` the serialized event. The serialization is ] ``` +To prevent implementation differences from creating a different event ID for the same event, the following rules MUST be followed while serializing: +- No whitespace, line breaks or other unnecessary formatting should be included in the output JSON. +- No characters except the following should be escaped, and instead should be included verbatim: + - The line break, `0x0A`, as `\n` + - A double quote, `0x22`, as `\"` + - A backspace, `0x5C`, as `\\` +- UTF-8 should be used for encoding. + ## Communication between clients and relays Relays expose a websocket endpoint to which clients can connect. From 3f8658ecc11e593f85a6a8d7de109d0b8f3254df Mon Sep 17 00:00:00 2001 From: Semisol <45574030+Semisol@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:49:52 +0300 Subject: [PATCH 2/4] Fix typo --- 01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01.md b/01.md index 9258d2f7..70aae443 100644 --- a/01.md +++ b/01.md @@ -48,7 +48,7 @@ To prevent implementation differences from creating a different event ID for the - No characters except the following should be escaped, and instead should be included verbatim: - The line break, `0x0A`, as `\n` - A double quote, `0x22`, as `\"` - - A backspace, `0x5C`, as `\\` + - A backslash, `0x5C`, as `\\` - UTF-8 should be used for encoding. ## Communication between clients and relays From 21d71791c89f41fb93f84b69d6db253bb7b403c4 Mon Sep 17 00:00:00 2001 From: Semisol <45574030+Semisol@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:55:15 +0300 Subject: [PATCH 3/4] Add carriage returns and tab characters since those may be in some events --- 01.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/01.md b/01.md index 70aae443..f5673b38 100644 --- a/01.md +++ b/01.md @@ -49,6 +49,8 @@ To prevent implementation differences from creating a different event ID for the - The line break, `0x0A`, as `\n` - A double quote, `0x22`, as `\"` - A backslash, `0x5C`, as `\\` + - A carriage return, `0x0D`, as `\r` + - A tab character, `0x09`, as `\t` - UTF-8 should be used for encoding. ## Communication between clients and relays From 4d709d1804de45bab3739ce814d4b0c0b211c273 Mon Sep 17 00:00:00 2001 From: Semisol <45574030+Semisol@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:12:47 +0300 Subject: [PATCH 4/4] add form feed and backspace --- 01.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/01.md b/01.md index f5673b38..0840f2e6 100644 --- a/01.md +++ b/01.md @@ -46,11 +46,13 @@ To obtain the `event.id`, we `sha256` the serialized event. The serialization is To prevent implementation differences from creating a different event ID for the same event, the following rules MUST be followed while serializing: - No whitespace, line breaks or other unnecessary formatting should be included in the output JSON. - No characters except the following should be escaped, and instead should be included verbatim: - - The line break, `0x0A`, as `\n` + - A line break, `0x0A`, as `\n` - A double quote, `0x22`, as `\"` - A backslash, `0x5C`, as `\\` - A carriage return, `0x0D`, as `\r` - A tab character, `0x09`, as `\t` + - A backspace, `0x08`, as `\b` + - A form feed, `0x0C`, as `\f` - UTF-8 should be used for encoding. ## Communication between clients and relays