Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data exchange protocol message definition #1936

Merged
merged 10 commits into from
Jun 26, 2024
74 changes: 74 additions & 0 deletions docs/messageData.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Expecting a connection (federation#expect)](#expecting-a-connection-federationexpect)
- [Initiating a connection (federation#init)](#initiating-a-connection-federationinit)
- [Confirming or Aborting the connection attempt (federation#result)](#confirming-or-aborting-the-connection-attempt-federationresult)
- [Exchanging tokens to share data between LAOs (federation#tokens_exchange)](#exchanging-tokens-to-share-data-between-LAOs-federationtokens_exchange)


<!-- END doctoc.sh generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -3311,4 +3312,77 @@ This message is sent by Bob's server. The purpose of this message is to provide
]
}
```
## Exchanging tokens to share data between LAOs (federation#tokens_exchange)
For now, data exchange is only implemented for social media channel.

This message is sent by both organizers to their servers to be broadcast. The message include the pop tokens of the other LAO. Upon receiving this message, participants will be able to subscribe to each channel /root/lao_id/social/token.
<details>
<summary>
💡 See an example
</summary>

```json5
// ../protocol/examples/messageData/federation_tokens_exchange/federation_tokens_exchange.json
{
"object": "federation",
"action": "tokens_exchange",
"lao_id": "fzJSZjKf-2cbXH7kds9H8NORuuFIRLkevJlN7qQemjo=",
"roll_call_id": "fEvAfdtNrykd9NPYl9ReHLX-6IP6SFLKTZJLeGUHZ_U=" ,
"tokens": ["M5ZychEi5rwm22FjwjNuljL1qMJWD2sE7oX9fcHNMDU="],
"timestamp": 1712854874
}
```
</details>

```json5
// ../protocol/query/method/message/data/dataFederationTokensExchange.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/message/data/dataFederationTokensExchange.json",
"description": "Sent by an organizer client to its server, to broadcast the Pop tokens",
"type": "object",
"properties": {
"object": {
"const": "federation"
},
"action": {
"const": "tokens_exchange"
},
"lao_id": {
"type": "string",
"contentEncoding": "base64",
"$comment": "Hash : HashLen(organizer, creation, name)"
},
"roll_call_id": {
"type": "string",
"contentEncoding": "base64",
"$comment": "last roll call id"
},
"tokens": {
"description": "[Array[Base64String]] list of Pop tokens",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"contentEncoding": "base64"
},
"$comment": "List must be sorted according to byte encoding: -,0...9,A...Z,_,a...z"
},
"timestamp": {
"type": "integer",
"description": "[Timestamp] of the tokens' exchange",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"object",
"action",
"lao_id",
"roll_call_id",
"tokens",
"timestamp"
]
}

```
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.5.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"object": "federation",
"action": "tokens_exchange",
"lao_id": "fzJSZjKf-2cbXH7kds9H8NORuuFIRLkevJlN7qQemjo=",
"roll_call_id": "fEvAfdtNrykd9NPYl9ReHLX-6IP6SFLKTZJLeGUHZ_U=" ,
"tokens": ["M5ZychEi5rwm22FjwjNuljL1qMJWD2sE7oX9fcHNMDU="],
"timestamp": 1712854874
}
3 changes: 3 additions & 0 deletions protocol/query/method/message/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
{
"$ref": "dataFederationResult.json"
},
{
"$ref": "dataFederationTokensExchange.json"
},
{
"$ref": "dataWitnessMessage.json"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/message/data/dataFederationTokensExchange.json",
"description": "Sent by an organizer client to its server, to broadcast the Pop tokens",
"type": "object",
"properties": {
"object": {
"const": "federation"
},
"action": {
"const": "tokens_exchange"
},
"lao_id": {
"type": "string",
"contentEncoding": "base64",
"$comment": "Hash : HashLen(organizer, creation, name)"
},
"roll_call_id": {
"type": "string",
"contentEncoding": "base64",
"$comment": "last roll call id"
},
"tokens": {
"description": "[Array[Base64String]] list of Pop tokens",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"contentEncoding": "base64"
},
"$comment": "List must be sorted according to byte encoding: -,0...9,A...Z,_,a...z"
},
"timestamp": {
"type": "integer",
"description": "[Timestamp] of the tokens' exchange",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"object",
"action",
"lao_id",
"roll_call_id",
"tokens",
"timestamp"
]
}
2 changes: 2 additions & 0 deletions protocol/test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const message_data_federation_expect_schema = require("../query/method/message/d
const message_data_federation_challenge_request_schema = require("../query/method/message/data/dataFederationChallengeRequest.json")
const message_data_federation_challenge_schema = require("../query/method/message/data/dataFederationChallenge.json")
const message_data_federation_result_schema = require("../query/method/message/data/dataFederationResult.json")
const message_data_federation_tokens_exchange_schema = require("../query/method/message/data/dataFederationTokensExchange.json")

const message_data_chirp_add_schema = require("../query/method/message/data/dataAddChirp.json");
const message_data_chirp_notify_add_schema = require("../query/method/message/data/dataNotifyAddChirp.json");
Expand Down Expand Up @@ -124,6 +125,7 @@ ajv.addSchema([
message_data_federation_challenge_request_schema,
message_data_federation_challenge_schema,
message_data_federation_result_schema,
message_data_federation_tokens_exchange_schema,

message_data_chirp_notify_add_schema,
message_data_chirp_add_schema,
Expand Down
3 changes: 3 additions & 0 deletions protocol/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ test("message data: federation", () => {
federation_result = require("../examples/messageData/federation_result/federation_result.json");
expect(federation_result).toBeValid(messageDataSchema);

federation_tokens_exchange = require("../examples/messageData/federation_tokens_exchange/federation_tokens_exchange.json");
expect(federation_tokens_exchange).toBeValid(messageDataSchema);

});

test("message data: chirp", () => {
Expand Down
Loading