# Transmat protocol description ## ver. 0.1 ### **Dramatis Personae:** *Relay* - Transphase relay Relay *Sender* - sending party *Receiver* - receiving party * *Sender* creates a low-entropy password, derives a key and a `peer_group_id` vaule and sends the message containing the `peer_group_id` to the *Relay* * *Relay* maintains a list of all its peers grouped by their `peer_group_id` value. * If the current message has a new unique `peer_group_id`, then a new peer group is created. * If the current message has a known `peer_group_id`, then a new peer group is created from it and the party that sent the message (normally the *Sender*) is added to that group. * *Sender* passes the low-entropy password to the *Receiver* over a different channel (e.g. phone or SSH). * *Receiver* derives a key and a `peer_group_id` value and sends the message containing the `peer_group_id` to the *Relay*. * This message contains 0 as `chunk_number` so that the *Sender* knows that the transfer should start from the very beginning. * *Relay* forwards this message to all other peers in the corresponding peer group (that is to the *Sender*). * *Sender* receives this message; sends the encrypted chunk and metadata; and then waits for the *Receiver* to send a confirmation that it has successfully received the message. * *Relay* forwards this message to all other peers in the corresponding peer group (that is to the *Receiver*). * *Receiver* decrypts the payload and writes it to the target file. (TODO: Check chunk hash) Then it sends a confirmation to the *Relay*. The confirmation contains the incremented number as the `chunk_id` * If this was the last chunk in the transmission, *Receiver* closes the Websocket connection to the *Relay* * *Sender* receives the confirmation and sends the next encrypted chunk and metadata. * If *Sender* has no more chunks to send, *Sender* closes the Websocket connection to the *Relay*