Skip to content

Commit 1a972eb

Browse files
committed
feat: update communities spec as per update content-topic changes
1 parent b589da2 commit 1a972eb

File tree

1 file changed

+57
-15
lines changed

1 file changed

+57
-15
lines changed

status/56/communities.md

+57-15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: Status Communities allow multiple users to communicate in a discuss
99
editor: Aaryamann Challani <p1ge0nh8er@proton.me>
1010
contributors:
1111
- Andrea Piana <andreap@status.im>
12+
- Prem Chaitanya Prathi <prem@waku.org>
1213
---
1314

1415
## Abstract
@@ -306,10 +307,30 @@ message CommunityDescription {
306307

307308
Note: The usage of the clock is described in the [Clock](#clock) section.
308309

310+
### Pubsub topic or shard usage
311+
312+
Status network uses static sharding as explained in [Relay Sharding](https://github.com/waku-org/specs/blob/master/standards/core/relay-sharding.md#static-sharding)
313+
314+
All communities by default use the default shard `32` for most of their messages and use shard `64` for a few specific messages like community event messages.
315+
316+
A community can be assigned a dedicated shard (in the range of 1-1024) after creation in which case all messages of the community are sent on that specific shard except for the community event messages.
317+
318+
### Content topic level encryption
319+
-a universal chat identifier is used for all community chats.
320+
<!-- Don't enforce any constraints on the unique id generation -->
321+
322+
All messages are encrypted before they are handed over to waku ir-respective of the encryption explained above.
323+
All community chats are encrypted using a symmetric key generated from universal chat id using pbkdf2.
324+
325+
```js
326+
symKey = pbkdf2(password:universalChatID, salt:nil, iteration-count:65356,key-length:32, hash-func: random-sha256)
327+
```
328+
309329
### Content topic usage
310330

311331
"Content topic" refers to the field in [14/WAKU2-MESSAGE](../../waku/standards/core/14/message.md/#message-attributes),
312-
further elaborated in [10/WAKU2](../../waku/standards/core/10/waku2.md/#overview-of-protocol-interaction).
332+
further elaborated in [10/WAKU2](../../waku/standards/core/10/waku2.md/#overview-of-protocol-interaction).
333+
The content-topic usage follows the guidelines specified at [23/topics](../../waku/informational/23/topics.md#content-topic-usage-guidelines)
313334

314335
#### Advertising a Community
315336

@@ -334,16 +355,15 @@ for i = 0; i < topicLen; i++ {
334355
contentTopic = "/waku/1/0x" + topic + "/rfc26"
335356
```
336357

337-
#### Community channels/chats
358+
#### Community event messages
338359

339-
The unique identifier for a community channel/chat is the chat id.
340-
<!-- Don't enforce any constraints on the unique id generation -->
341-
The content topic, that Community channels/chats uses,
342-
MUST be the hex-encoded keccak-256 hash of the public key of the community
343-
concatenated with the chat id.
360+
Message such as community description
361+
MUST be sent to the content topic derived from the public key of the community.
362+
The content topic
363+
MUST be the hex-encoded keccak-256 hash of the public key of the community.
344364

345365
```js
346-
hash = hex(keccak256(encodeToHex(compressedPublicKey + chatId)))
366+
hash = hex(keccak256(encodeToHex(publicKey)))
347367

348368
topicLen = 4
349369
if len(hash) < topicLen {
@@ -357,15 +377,15 @@ for i = 0; i < topicLen; i++ {
357377
contentTopic = "/waku/1/0x" + topic + "/rfc26"
358378
```
359379

360-
#### Community event messages
380+
#### Community Requests
381+
Requests to leave, join, kick and ban, as well as key exchange messages, MUST be sent to the content topic derived from the public key of the community on the common shard.
361382

362-
Requests to leave, join, kick and ban, as well as key exchange messages,
363-
MUST be sent to the content topic derived from the public key of the community.
364383
The content topic
365-
MUST be the hex-encoded keccak-256 hash of the public key of the community.
384+
MUST be the keccak-256 hash of hex-encoded universal chat id (public key appended with fixed string) of the community omitting the first 2 bytes.
366385

367386
```js
368-
hash = hex(keccak256(encodeToHex(publicKey)))
387+
universalChatId = publicKey+"-memberUpdate"
388+
hash = hex(keccak256(encodeToHex(universalChatId))[2:])
369389

370390
topicLen = 4
371391
if len(hash) < topicLen {
@@ -379,6 +399,29 @@ for i = 0; i < topicLen; i++ {
379399
contentTopic = "/waku/1/0x" + topic + "/rfc26"
380400
```
381401

402+
#### Community Shard Info
403+
If a community is assigned a dedicated shard then the shard info for that community is published on a content topic derived from a specialized key. This is useful for users joining the new community so that they can subscribe to this specific content topic.
404+
405+
```js
406+
chatID = publicKey+"-shard-info"
407+
hash = hex(keccak256(encodeToHex(chatID))[2:])
408+
409+
topicLen = 4
410+
if len(hash) < topicLen {
411+
topicLen = len(hash)
412+
}
413+
var topic [4]byte
414+
for i = 0; i < topicLen; i++ {
415+
topic[i] = hash[i]
416+
}
417+
418+
contentTopic = "/waku/1/0x" + topic + "/rfc26"
419+
```
420+
421+
#### Community channels/chats
422+
423+
All channels/chats shall use a single content-topic which is derived based on a universal chat id ir-respective of their individual unique chat ids.
424+
382425
### Community Management
383426

384427
The flows for Community management are as described below.
@@ -391,8 +434,7 @@ according to the wire format "CommunityDescription".
391434
3. The Community owner publishes the Community metadata on a content topic
392435
derived from the public key of the Community.
393436
the Community metadata SHOULD be encrypted with the public key of the Community.
394-
<!-- TODO: Verify this-->
395-
The Community metadata MAY be sent during fixed intervals,
437+
The Community metadata is sent during fixed intervals,
396438
to ensure that the Community metadata is available to members.
397439
The Community metadata SHOULD be sent every time the Community metadata is updated.
398440
4. The Community owner MAY advertise the Community out of band,

0 commit comments

Comments
 (0)