mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 15:37:49 +00:00
Add `rust/src/federation`, starting with the `X-Matrix` request signature and the transport seam the request layer will send through. The signing code comes from matrix-hyper-federation-client (Apache-2.0), changed to use Synapse's canonical JSON serializer, Python's header layout and quoting, and `destination_is` for identity servers. It keeps that crate's signature test vectors. The body is serialized to canonical JSON once, then both signed and sent in that form. The homeserver's signing key crosses to Rust as its algorithm, version and seed, taken from `hs.signing_key`. Rust never reads the key file. `FederationTransport` is what the request layer will send through. `PyTransport` implements it with a Python callable, which is how Rust level tests will inject responses in place of `FakeTransport`. A trial test checks the Rust header is byte-identical to the one `MatrixFederationHttpClient.build_auth_headers` builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R5b7Ruy4cgt27Mjq6Ptxbb