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] 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 2ff81eb..9258d2f 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.