diff options
author | Case Duckworth | 2023-04-04 16:13:34 -0500 |
---|---|---|
committer | Case Duckworth | 2023-04-04 16:13:34 -0500 |
commit | 25ceaa1fd3575383641b28ab6c3f6f02f6da5883 (patch) | |
tree | 945083e8603ae2585b4cfd30508a72bf7fd8e0bb | |
parent | Add readme (diff) | |
download | postcard-25ceaa1fd3575383641b28ab6c3f6f02f6da5883.tar.gz postcard-25ceaa1fd3575383641b28ab6c3f6f02f6da5883.zip |
Add protocol description
-rw-r--r-- | protocol.txt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/protocol.txt b/protocol.txt new file mode 100644 index 0000000..0fa5ca6 --- /dev/null +++ b/protocol.txt | |||
@@ -0,0 +1,46 @@ | |||
1 | THE POSTCARD PROTOCOL | ||
2 | |||
3 | The postcard protocol is a small client-server protocol built on udp for short | ||
4 | one-off messages. Messages must be contained in one packet (512 bytes); with | ||
5 | metadata taking up around 100 bytes that means messages can be up to around 400 | ||
6 | bytes in length, which is roughly postcard-sized. | ||
7 | |||
8 | A postcard message looks like this (sans leading indentation): | ||
9 | |||
10 | <recipient><newline> | ||
11 | <ed25519 public key of sender><newline> | ||
12 | <message> | ||
13 | |||
14 | A postcard server ("Post office") is a persistent process somewhere online that exists to | ||
15 | receive postcards and deliver them to the proper user. It could be fun to have | ||
16 | a block of ports, each of which serves as one user's "P.O. box" on that server. | ||
17 | If an entire block isn't available, one port could be used and delivery made | ||
18 | using the first line of the postcard. | ||
19 | |||
20 | Spam mitigation has two layers: | ||
21 | |||
22 | 1. The sender must know the recipient's server (and possibly port number) and | ||
23 | user name. Post offices must keep a list of user names and their associated | ||
24 | port numbers, and if the recipient's name and port fail to align, or if the | ||
25 | office doesn't have a user, the message is rejected. | ||
26 | |||
27 | 2. Sender identity is verified using ED25519 public key cryptography (chosen | ||
28 | because of its short length---a mere 32 bytes). Post offices should keep | ||
29 | lists of friends and fuckers, letting the first deliver to their users and | ||
30 | telling the second to shove it. When receiving a message from an unknown | ||
31 | recipient, the post office should hold the message for a given amount of time | ||
32 | and allow a moderator ("postmaster") to decide whether the sender is a | ||
33 | friend or fucker. | ||
34 | |||
35 | UDP was chosen as a protocol precisely for its lossy and unpredictable nature: | ||
36 | postcards themselves can get lost in the mail or damaged by rain or machinery, | ||
37 | after all. However, if a postmaster wants to provide a greater level of | ||
38 | service for senders to their office, they may respond with one of the following | ||
39 | codes upon receipt of message: | ||
40 | |||
41 | (1) HM --- message received but waiting for moderation | ||
42 | (2) OK --- message received and delivered | ||
43 | (3) FU --- fuck off, fucker! | ||
44 | |||
45 | Of course, a postmaster can decide to not send HM or simply not to reply to | ||
46 | fuckers. They can just pretend the message was lost in the mail. | ||