mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
`create_local_event_from_event_dict` encoded the event as canonical JSON three times: once for the content hash, once to sign the redacted event, and once to parse it as an `Event`, which then hashed it again for the event ID. A Rust `LocalEventSigner`, one per homeserver, now takes the canonical JSON once, adds the content hash and the signature, and builds the `Event`. The signed bytes are the redacted event without its signatures, which is also what the reference hash covers, so the event ID comes from them without another pass. Hashes and signatures already on the event (a make_join template) are kept, as before. Numbers keep the text Python's encoder gave them, so floats and large integers in old room versions hash and sign as they did. An event the room version cannot parse is still a 400. A make_join template with a non-object `hashes` or `signatures` entry, or no `content`, is now a 400 too, where it used to raise a 500. Saves about 45 us per event on this host. ed25519 signing is 25 us of what is left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVLsNh6akt4ifEizY4D1ta