From 29720cd152bd12f08b155895fddfc0ad65eaca7a Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Fri, 16 Oct 2015 19:00:36 +0100 Subject: [PATCH] Initial attempt at describing the event redaction algorithm --- specification/event_signing.rst | 60 +++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/specification/event_signing.rst b/specification/event_signing.rst index bde58f0c..2f61566e 100644 --- a/specification/event_signing.rst +++ b/specification/event_signing.rst @@ -190,9 +190,63 @@ in the event JSON in a ``hash`` object under a ``sha256`` key. event_json_object["unsigned"] = unsigned return event_json_object -Then all non-essential keys are stripped from the event object, and the -resulting object which included the ``hash`` key is signed using the JSON -signing algorithm +The event is then stripped of all non-essential keys both at the top level and +within the ``content`` object. Essential top-level keys given below; any +top-level keys not in this list are removed. + +.. code:: + + auth_events + depth + event_id + hashes + membership + origin + origin_server_ts + prev_events + prev_state + room_id + sender + signatures + state_key + type + +A new ``content`` object is constructed for the resulting event that contains +only the essential keys of the original event. If the original event lacked a +``content`` object at all, a new blank one is created for it. + +The keys that are considered essential for the ``content`` object depend on the +the ``type`` of the event. These are: + +.. code:: + + type is "m.room.aliases": + aliases + + type is "m.room.create": + creator + + type is "m.room.history_visibility": + history_visibility + + type is "m.room.join_rules": + join_rule + + type is "m.room.member": + membership + + type is "m.room.power_levels": + ban + events + events_default + kick + redact + state_default + users + users_default + +The resulting stripped object with the new ``content`` object and the original +``hashes`` key is then signed using the JSON signing algorithm. .. code:: python