Skip to content

Commit 652277d

Browse files
committed
add usage guidelines for waku content topics
update communities spec as per content topic changes (#118) - Update content topic usage as per https://forum.vac.dev/t/status-communities-review-and-proposed-usage-of-waku-content-topics/335 - Update symmetric encryption done at content topic level before messages are handed over to waku - Update about shard or pubsub topic usage
1 parent 08b363d commit 652277d

File tree

2 files changed

+72
-16
lines changed

2 files changed

+72
-16
lines changed

status/56/communities.md

+59-14
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,31 @@ 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+
320+
-a universal chat identifier is used for all community chats.
321+
<!-- Don't enforce any constraints on the unique id generation -->
322+
323+
All messages are encrypted before they are handed over to waku ir-respective of the encryption explained above.
324+
All community chats are encrypted using a symmetric key generated from universal chat id using pbkdf2.
325+
326+
```js
327+
symKey = pbkdf2(password:universalChatID, salt:nil, iteration-count:65356,key-length:32, hash-func: random-sha256)
328+
```
329+
309330
### Content topic usage
310331

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

314336
#### Advertising a Community
315337

@@ -334,16 +356,15 @@ for i = 0; i < topicLen; i++ {
334356
contentTopic = "/waku/1/0x" + topic + "/rfc26"
335357
```
336358

337-
#### Community channels/chats
359+
#### Community event messages
338360

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.
361+
Message such as community description
362+
MUST be sent to the content topic derived from the public key of the community.
363+
The content topic
364+
MUST be the hex-encoded keccak-256 hash of the public key of the community.
344365

345366
```js
346-
hash = hex(keccak256(encodeToHex(compressedPublicKey + chatId)))
367+
hash = hex(keccak256(encodeToHex(publicKey)))
347368

348369
topicLen = 4
349370
if len(hash) < topicLen {
@@ -357,15 +378,16 @@ for i = 0; i < topicLen; i++ {
357378
contentTopic = "/waku/1/0x" + topic + "/rfc26"
358379
```
359380

360-
#### Community event messages
381+
#### Community Requests
382+
383+
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.
361384

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.
364385
The content topic
365-
MUST be the hex-encoded keccak-256 hash of the public key of the community.
386+
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.
366387

367388
```js
368-
hash = hex(keccak256(encodeToHex(publicKey)))
389+
universalChatId = publicKey+"-memberUpdate"
390+
hash = hex(keccak256(encodeToHex(universalChatId))[2:])
369391

370392
topicLen = 4
371393
if len(hash) < topicLen {
@@ -379,6 +401,30 @@ for i = 0; i < topicLen; i++ {
379401
contentTopic = "/waku/1/0x" + topic + "/rfc26"
380402
```
381403

404+
#### Community Shard Info
405+
406+
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.
407+
408+
```js
409+
chatID = publicKey+"-shard-info"
410+
hash = hex(keccak256(encodeToHex(chatID))[2:])
411+
412+
topicLen = 4
413+
if len(hash) < topicLen {
414+
topicLen = len(hash)
415+
}
416+
var topic [4]byte
417+
for i = 0; i < topicLen; i++ {
418+
topic[i] = hash[i]
419+
}
420+
421+
contentTopic = "/waku/1/0x" + topic + "/rfc26"
422+
```
423+
424+
#### Community channels/chats
425+
426+
All channels/chats shall use a single content-topic which is derived from a universal chat id irrespective of their individual unique chat ids.
427+
382428
### Community Management
383429

384430
The flows for Community management are as described below.
@@ -391,8 +437,7 @@ according to the wire format "CommunityDescription".
391437
3. The Community owner publishes the Community metadata on a content topic
392438
derived from the public key of the Community.
393439
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,
440+
The Community metadata is sent during fixed intervals,
396441
to ensure that the Community metadata is available to members.
397442
The Community metadata SHOULD be sent every time the Community metadata is updated.
398443
4. The Community owner MAY advertise the Community out of band,

waku/informational/23/topics.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,26 @@ As an example, here's the content topic used for an upcoming testnet:
120120

121121
### Content Topic Naming Recommendations
122122

123-
Application names should be unique to avoid conflicting issues with other protocols.
124-
Applications should specify their version (if applicable) in the version field.
123+
Application names SHOULD be unique to avoid conflicting issues with other protocols.
124+
Applications SHOULD specify their version (if applicable) in the version field.
125125
The `{content-topic-name}` portion of the content topic is up to the application,
126126
and depends on the problem domain.
127127
It can be hierarchical, for instance to separate content, or
128128
to indicate different bandwidth and privacy guarantees.
129129
The encoding field indicates the serialization/encoding scheme
130130
for the [WakuMessage payload](../../standards/core/14/message.md/#payloads) field.
131131

132+
### Content Topic usage guidelines
133+
134+
Applications SHOULD be mindful while designing/using content topics so that a bloat of content-topics does not happen.
135+
A content-topic bloat causes performance degradation in Store and Filter protocols while trying to retrieve messages.
136+
137+
Store queries have been noticed to be considerably slow (e.g doubling of response-time when content-topic count is increased from 10 to 100) when a lot of content-topics are involved in a single query.
138+
Similarly number of filter subscriptions increase, which increases complexity on client side to maintain and manage these subscriptions.
139+
140+
Applications SHOULD analyze the query/filter criteria for fetching messages from the network and select/design content topics to match such filter criteria.
141+
e.g: even though applications may want to segregate messages into different sets based on some application logic, if those sets of messages are always fetched/queried together from the network, then all those messages SHOULD use a single content-topic.
142+
132143
## Differences with Waku v1
133144

134145
In [5/WAKU1](../../deprecated/5/waku0.md) there is no actual routing.

0 commit comments

Comments
 (0)