diff --git a/rfc/0004_ws2p_v1.md b/rfc/0004_ws2p_v1.md index a836a5d123de803b69b4762c6035e2e8623f4160..cf2a647657b1e3d7d5cdcd1c80c8a12eea3bc720 100644 --- a/rfc/0004_ws2p_v1.md +++ b/rfc/0004_ws2p_v1.md @@ -10,6 +10,7 @@ This document details the current specifications of WS2P v1 as they are already * [Endpoint format](#endpoint-format) * [Getting endpoints from other Duniter nodes](#getting-endpoints-from-other-duniter-nodes) * [Priority of WS2P outcoming connections](#priority-of-ws2p-outcoming-connections) +* [Overview on the format of ws2p messages](#overview-on-the-format-of-ws2p-messages) * [Establishing a WS2P connection](#establishing-a-ws2p-connection) * [Rules for accepting an incoming connection](#rules-for-accepting-an-incoming-connection) * [HEAD messages](#head-messages) @@ -84,6 +85,13 @@ If the key is a member: +1 If the key is preferred/privileged: +2 If the key is the same as yourself: +4 (for multi-node) +## Overview on the format of ws2p messages + +Most ws2p messages exist in two formats : + +JSON: this is the format used to transmit the message through the websocket. +RAW: this is the format used to sign the message. Messages received in JSON must therefore be converted to raw format in order to verify the validity of their signature. + ## Establishing a WS2P connection After sorting all WS2P endpoints according to the criteria described in the previous section, @@ -100,7 +108,7 @@ for each connection attempt, the process is as follows: ### CONNECT message -It's a JSON object : +JSON format : { auth: 'CONNECT', @@ -119,6 +127,8 @@ RAW format of the example message above : `WS2P:CONNECT:g1:D9D2zaJoWYWveii1JRYLV ### ACK message +JSON format : + { auth: 'ACK', pub: "D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx", @@ -130,10 +140,13 @@ sig: ed25519 signature of the RAW format message in base64. raw format : `WS2P:ACK:currency_name:pub:challenge` -_*The challenge is the one we have written in our own CONNECT message._ +_*The challenge is the one we have written in our own CONNECT message. +The challenge is not retransmitted in json format of ACK messages because the remote node is supposed to already have this information._ ### OK message +JSON format : + { auth: 'OK', sig @@ -143,7 +156,8 @@ sig: ed25519 signature of the RAW format message in base64. raw format : `WS2P:OK:currency_name:pub:challenge` -_**Be careful**, this time the challenge is the one that **the remote node sent us** in **its own CONNECT message**._ +_**Be careful**, this time the challenge is the one that **the remote node sent us** in **its own CONNECT message**. +The challenge is not retransmitted in json format of OK messages because the remote node is supposed to already have this information._ ## Rules for accepting an incoming connection