Proposal for a Simple-Validation Replication RPC
When an ssb server receives a new message, it verifies its signature. The message may be sent in a different format than that used for signing, this is true for the current json encoding, and it may be true for future compressing encodings. So in order to verify a message, the server needs to know how to encode it in the correct format. In the case of json messages, this is really painful.
I propose adding a new rpc method to sbot that works like createHistoryStream
, except it emits objects of the form
{
crypto: ".sig.ed25519", // the cryptographic primitive of the signature
signature: [0, 0, 42, 17, ...], // the claimed signature of the raw message
raw: [0, 42, ...] // the raw bytes that can be given to the signing function
}
The receiving server runs the signing algorithm specified by the crypto
field against the raw
buffer. If it matches the signature
, the message is verified. Decode it, then add signature
to the metadata of the decoded object.
This means that servers only need to know how to decode all signing encodings previously used by ssb, but they do not need to know how to convert from transport to signing encoding. The server implementation itself only needs to implement a single message encoding, which it can use for producing its own messages.
This is not intended to replace createHistoryStream, only to allow supplement it.
Drawbacks of this:
- There are usually good reasons for having separate signing and transport encodings, this function ignores them. In the case of the json encoding, that means sending a bunch of whitespace over the wire.
- A server that does not know how to restore a transport encoding from a signature encoding can only relay those messages via the same rpc to other servers.
Advantages:
- allows new server implementations to quickly talk to the main network, fosters experimentation
- reduces the work that each new format imposes on all server implementations
- any implementation can still chose to support old transport encodings for efficiency
- I will never be forced to implement the bizarre json encoding
Of those advantages, the second one alone is enough in my opinion to justify this rpc. The first one will be extremely valuable as well. The fourth one should be completely irrelevant to the decision on whether to add this, but it is true nonetheless, and it makes me happy.
A few more points on potential drawbacks:
- any "serious" implementation should use ebt replication rather than createHistoryStream anyways, so this should not have a lot of impact on overall network performance
- this warrants persisting data in the form it was received in, but iirc the go implementation currently needs to do that anyways (can't find a link though, I might misremember this)
- implementing this should be rather easy, so this will place little burden on future implementations.