summaryrefslogtreecommitdiff
path: root/docs/Group-Chats.md
blob: e318613dda126c83cac55615c619f622066963ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Massive public group chats.

Note that not all this document has been implemented: only private (invite only) group chats are currently implemented.

Everyone generates a short term public private key pair right before joining 
the chat.

Note that for public group chats it is impossible to protect the chat from 
being spied on by a very dedicated attacker, encryption is therefor used as a 
form of spam/access control.

## Joining the chats


## Protocol


Node format: 
See DHT, currently uses the IPv6 Node_format.

Get nodes (Request):
Packet contents: 
```
[char with a value of 48][Bob's (The reciever's) Public key (client_id) (32 bytes))][Alice's (The sender's) Public key (client_id) (32 bytes)][Random nonce (24 bytes)][Encrypted with the nonce, private key of the sender and public key of the reciever:[char with a value of 48][random 8 byte (ping_id)]
```
Valid replies: a send_nodes packet

Send_nodes (response): 
```
[char with a value of 48][Bob's (The reciever's) Public key (client_id) (32 bytes))][Alice's (The sender's) Public key (client_id) (32 bytes)][Random nonce (24 bytes)][Encrypted with the nonce, private key of the sender and public key of the reciever:[char with a value of 49][random 8 byte (ping_id)][Nodes in node format, length=40 * (number of nodes (maximum of 6 nodes)) bytes]]
```

Broadcast packet:
```
[char with a value of 48][Bob's (The reciever's) Public key (client_id) (32 bytes))][Alice's (The sender's) Public key (client_id) (32 bytes)][nonce][Encrypted with the nonce, private key of the sender and public key of the reciever:[char with a value of 50][Data to send to everyone]]
```


Data to send to everyone:
TODO: signing and spam control + permissions.
[client_id of sender][uint32_t message number][char with a value representing id of message][data]

Note: the message number is increased by 1 for each sent message.

message ids:
0 - ping
sent every ~60 seconds by every peer.
No data.

16 - new_peer
Tell everyone about a new peer in the chat.
[uint8_t public_key[public_key_len]]

17 - ban_peer
Ban a peer
[uint8_t public_key[public_key_len]]

18 - topic change
[uint8_t topic[topiclen]]

48 - name change
[uint8_t name[namelen]]

49 - status change
[uint8_t (status id)]

64 - chat message
[uint8_t message[messagelen]]

65 - action (/me)
[uint8_t message[messagelen]]