OVIP: 10
Title: Whisper as Transport Layer
Author: David Riegelnig <david.riegelnig@bitcoinsuisse.com>
Discussions-To: https://community.openvasp.org/#narrow/stream/21-protocol-.2F.20ovip
Status: Accepted
Type: Standard
Created: 2020-06-02
This OVIP specifies the transport layer implementation for the OpenVASP protocol using Ethereum Whisper. It is a revision of the initial specification proposed in the OpenVASP White Paper.
The Whisper messaging system has been developed as part of the Ethereum technology stack but can be used separately from the blockchain. It was designed to provide resilience and strong privacy in a peer-to-peer environment and targets message delivery below five seconds on a global scale.
The online documentation about the Whisper protocol can be found here: https://geth.ethereum.org/docs/whisper/whisper-overview.
Node
System operating a Whisper node providing the transport layer service for the OpenVASP protocol.
Connection
Two Nodes sharing a common identifier representing a connection and an associated shared key, which can be used to exchange Envelopes containing an encrypted Message. Both Nodes have sent each other a Whisper topic to be used to send Envelopes related to this connection.
Active Node
Node inviting another node to establish a Connection.
Passive Node
Node responding to an invitation, either accepting or denying the Connection.
Initiator
VASP operating the Active Node.
Responder
VASP operating the Passive Node.
Sender
VASP sending an Envelope.
Receiver
VASP receiving an Envelope.
Envelope
Envelopes are the packets sent and received by Whisper nodes. They contain the encrypted Message and metadata for decryption.
Message
Message part of an Envelope, containing the message Payload, metadata and optional signature. Not to be confused with OpenVASP Messages, which are defined on the higher Session Layer.
Payload
Actual message payload within a Message transmitted by an Envelope.
Whisper Envelopes are the packets sent and received by Whisper nodes. Once decoded, they have the following format:
[ Version, Expiry, TTL, Topic, AESNonce, Data, EnvNonce ]
The table below provides an overview about each of these elements and their usage as part of OpenVASP.
| Element | Description | OpenVASP Usage | See |
|---|---|---|---|
Version |
Currently one byte containing zero | As per Whisper default | |
Expiry |
UNIX time in seconds | As per Whisper default | |
TTL |
Time-to-live in seconds | As indicated in this document | 5./6. |
Topic |
Probabilistic hint about encryption key | As indicated in this document | 5./6. |
AESNonce |
Salt (96-bit) for symmetric encryption | Randomly set for each Envelope | |
Data |
Contains encrypted Whisper Message | Defined Message structure | 4. |
EnvNonce |
Nonce used for Proof-of-Work calculation | As per Whisper default |
Upon receipt of an Envelope, if the node detects a known topic, it tries to decrypt the Data element with the corresponding symmetric or asymmetric key. If decryption is successful, the Message is revealed with the following structure:
| Element | Description | OpenVASP Usage | See |
|---|---|---|---|
flags |
Flags to specifiy Payload structure | As per Whisper default | |
padding |
Random padding data, optional | As per Whisper default | |
payload |
Message Payload | OpenVASP Payload structure | 4.1. |
signature |
Signature, optional | Not used |
The table below shows the structure of the OpenVASP Payload. The last four elements are present depending on the value of the instruction element.
The payload is encoded as a single big-endian, hex-encoded string with '0x' prefix.
| Element | Length | Present | Description | See |
|---|---|---|---|---|
version |
1 byte | Always | OpenVASP Payload version, currently set to zero | |
instruction |
3 bits | Always | Instructions to control a Connection | 4.1.1 |
flags |
5 bits | Always | Reserved for future use, must be set to zero | |
sender |
6 bytes | Always | Sender's VASP Identity | |
connection |
16 bytes | Always | Connection identifier | |
envelopeID |
16 bytes | Always | Randomly set Envelope identifier | |
envelopeACK |
16 bytes | Reference to an Envelope identifier | ||
returnTopic |
4 bytes | Return topic | ||
ecdhPK |
33 bytes | Ephemeral compressed ECDH public key | ||
ovMessage |
arbitrary size | Session Message (JSON) |
The instruction element can have the following values:
| Value | Sent by | Description |
|---|---|---|
000 |
Active or Passive Node | Acknowledge Envelope receipt (ACK) |
001 |
Active Node | Inviting for a Connection (INVITE) |
010 |
Passive Node | Accepting a Connection invitation (ACCEPT) |
011 |
Passive Node | Denying a Connection invitation (DENY) |
100 |
Active or Passive Node | Sending an Envelope over a Connection (UPDATE) |
101 |
Active or Passive Node | Closing a Connection (CLOSE) |
Nodes must acknowledge the receipt of certain Envelopes by returning an OpenVASP Envelope of type ACK. The table below shows which Envelopes must be acknowledged.
| To be acknowledged | Envelopes with instruction value (see 4.1.1) |
|---|---|
| YES | INVITE, ACCEPT, UPDATE, CLOSE |
| NO | DENY, ACK |
This sections explains how the Node is internally handling Connections without being normative about the actual implementation.
Each Node maintains the set of Connections established with other Nodes. Connections have no state, they are either present (and therefore in the set) or not.
Each VASP using the OpenVASP protocol must be contactable via its VASP Identifier. The VASP's Node must therefore always have this Connection in its set, which is called the Permanent Connection.
A Node serving several VASPs (or a VASP group operating with different legal entities) might have several Permanent Connections in its set.
All other Connections are called Transient Connections, as they are only in the set as long as they are open.
Connections have the following properties:
| Element | Description | Value in case of a Transient Connection | Value in case of a Permanent Connection |
|---|---|---|---|
isPermanent |
Flag indicating whether this Connection is a Permanent Connection (see 5.2) | False |
True |
connection |
Connection identifier | Connection identifier | VASP Identifier |
inboundTopic |
Topic used to identify incoming Envelopes related to this Connection | Randomly set Topic | VASP Identifier |
outboundTopic |
Topic used to label outgoing Envelopes related to this Connection | Topic received from connected Node | n/a |
key |
Key used to encrypt/decrypt Envelopes sent/received over this Connection. | Shared key to encrypt/decrypt outbound/inbound Envelopes | Private key to decrypt inbound Envelopes |
The Node maintains a queue of Envelopes sent in order to keep track whether their receipt has been acknowledged by the receiving Node. Only Envelopes that must be acknowledged are included in the queue (see 4.1.2).
Queue items have the following properties:
| Element | Description |
|---|---|
envelopeID |
Envelope identifier |
envelope |
Envelope |
expiry |
Time when the waiting period for the acknowledgement of envelope ends and it is resent |
resends |
Number of times envelope had to be resent |
connection |
Identifier of the associated Connection |
isCLOSE |
Flag whether the Envelope is of type CLOSE (see 4.1.1) |
The Node checks regularly for each item in the Outbound Envelope Queue whether its expiry time has been reached.
If this is the case, the respective Envelope is resent, the expiry time is reset and the value for resents is increased by one.
Nodes should resend Envelopes not being acknowledged with an increasingly larger TTL values (e.g. doubling the TTL with each resend).
Nodes must define a maximal number of resends for Envelopes not getting acknowledged.
If this limit is reached for an item in the Outbound Envelope Queue, the respective Connection is considered interrupted.
In such a case, the Node must:
- If the
isCLOSEflag on the respective Outbound Envelope Queue item isTrue, then delete the respective Connection item from the Connection set. - Delete the respective item from the Outbound Envelope Queue.
- If the
isCLOSEflag on the respective Outbound Envelope Queue item isFalse, then notify the session layer's Exception Handling (see OVIP-7, 3.1) about the interruption.
Inbound Envelopes must be validated as per following steps.
- Check whether
Topic(see 3) is present as aninboundTopicin the Connection set (see 5.3). - Check whether
Data(see 3) can be decrypted with the associatedkeyin the Connection set (see 5.3). - Check whether the
payloadelement of the decrypted message (see 4) conforms to the OpenVASP Payload (see 4.1).
If one of the above mentioned checks fail, the Envelope is ignored and deleted.
Nodes must acknowledge certain Envelopes (see 4.1.2) by returning an OpenVASP Envelope of type ACK.
If required, the Envelope is acknowledged as per following steps.
-
Read
connectionvalue from the Payload of the Envelope to be acknowledged. -
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction000connectionconnectionvalue from the Payload of the Envelope to be acknowledgedenvelopeACKenvelopeIDvalue from the Payload of the Envelope to be acknowledged -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below
Element Value / Specification TopicoutboundTopicvalue looked up in the Connection set based on matchingconnectionvalues.DataMessage inclusing Payload created in step 2, symmetrically encrypted (AES GCM algorithm as per Whisper standard) with keyvalue looked up in the Connection set based on matchingconnectionvalues unless specified otherwise. -
Send Envelope created in step 3.
Received OpenVASP Envelopes of type ACK are processed as per following steps.
-
Read
envelopeACKvalue from the Payload of the Envelope received. -
Lookup item in the Outbound Envelope Queue (see 5.4) based on matching
envelopeID/envelopeACKvalues. -
If a match can be found with the isCLOSE flag set to
False, then delete the item from the queue. -
If a match can be found with the isCLOSE flag set to
True, then:a) delete respective item in the Connection set (see 5.3) based on matching
connection/connectionIDvalues, andb) delete the item from the queue.
An OpenVASP Session knows four state changing operations:
- Initiating a Session,
- Responding to a Session Initiation,
- Ending a Session, and
- Aborting a Session.
In addition, the session layer defines Application Messages that are exchanged during an open session.
The reader is recommended to consult OVIP-7 to understand the session model in full detail. This section describes how a conformant Node must implement the four above listed state changing operations as well as the exchange of Application Messages.
| Element | Description | See |
|---|---|---|
receiver |
VASP Identifier of the Responder | OVIP-7, section 2.1 |
sessionMessage |
Session Request Message | OVIP-7, section 4.1 |
-
Retrieve public
transportKeyavailable from thereceiver's VASP Contract. -
Generate random
connectionIdentifier. -
Generate random
topicAthe Node will listen for to identify incoming Envelopes sent over this Connection. -
Generate Secp256k1 ECDH private key (
ecdhPrivateA) and ECDH public key (ecdhPublicA). -
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction001connectionconnectionIdentifierreturnTopictopicAecdhPKecdhPublicAovMessagesessionMessage -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below.
Element Value / Specification TopicreceiverDataMessage inclusing Payload created in step 6, asymmetrically encrypted with the transportKeyusing SECP-256k1 as per Whisper standard. -
Add item to the set of Connections:
Element Value isPermanentFalseconnectionconnectionIdentifierinboundTopictopicAoutboundTopic(empty) keyecdhPrivateA -
Add item to the Outbound Envelope Queue:
Element Value envelopeIDEnvelope identifier set in step 6 envelopeEnvelope created in step 7 expiryCurrent time + 900 seconds resends0connectionconnectionIdentifierisCLOSEFalse -
Make the Node listen to incoming Envelopes associated to this Connection.
-
Send Envelope created in step 7.
- Return that session invitation has been sent.
- Return Connection identifier (
connectionID) so that the session layer can refer to it throughout the session lifecycle.
Validate and decrypt Envelope (see 5.5).
Send acknowledgement (see 5.6), asymmetrically encrypted by ecdhPK, read from the Payload of received Envelope.
-
Read
connection,envelopeID,returnTopic,ecdhPKandovMessagefrom the Payload of received Envelope. -
Generate random
topicBthe Node will listen for to identify incoming Envelopes sent over this Connection. -
Generate Secp256k1 ECDH private key (
ecdhPrivateB) and ECDH public key (ecdhPublicB). -
Derive
sharedKeybased onecdhPrivateBandecdhPublicAreceived in step 1 using the X25519 key-exchange protocol. -
Add item to the set of Connections:
Element Value isPermanentFalseconnectionconnectionfrom the Payload of received EnvelopeinboundTopictopicBoutboundTopicreturnTopickeysharedKey -
Make the Node listen to incoming Envelopes associated to this Connection.
- Notify that session invitation has been received.
- Provide Connection identifier (
connectionID) so that the session layer can refer to it throughout the session lifecycle. - Pass
ovMessageto session layer.
| Element | Description | See |
|---|---|---|
connectionID |
Connection identifier | |
isAccepted |
True |
|
sessionMessage |
Session Reply Message | OVIP-7, section 4.2 |
-
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction010returnTopicinboundTopicvalue looked up in the Connection set based on matchingconnection/connectionIDvalues.ovMessagesessionMessageecdhPKecdhPublicB -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below
Element Value / Specification TopicoutboundTopicvalue looked up in the Connection set based on matchingconnection/connectionIDvalues.DataMessage inclusing Payload created in step 1, asymmetrically encrypted (ECIES algorithm as per Whisper standard) with ecdhpkAvalue. -
Add item to the Outbound Envelope Queue:
Element Value envelopeIDEnvelope identifier set in step 1 envelopeEnvelope created in step 2 expiryCurrent time + 900 seconds resends0connectionconnectionIDisCLOSEFalse -
Send Envelope created in step 2.
- Return that session acceptance has been sent.
Validate and decrypt Envelope (see 5.5).
-
Read
connection,returnTopic,ecdhPublicBandovMessagefrom the Payload of received Envelope. -
Derive
sharedKeyfromecdhPublicBandecdhPrivateA. -
Look up respective item in the Connection set (see 5.3) based on matching
connection/connectionIDvalues. -
Update respective Connection item:
Element Value outboundTopicreturnTopickeysharedKey
Send acknowledgement (see 5.6). Encrypted symmetrically with sharedKey.
- Notify that session invitation has been accepted.
- Pass
ovMessageto session layer.
| Element | Description | See |
|---|---|---|
connectionID |
Connection identifier | |
isAccepted |
False |
|
sessionMessage |
Session Reply Message | OVIP-7, section 4.2 |
-
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction011ovMessagesessionMessage -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below
Element Value / Specification TopicoutboundTopicvalue looked up in the Connection set based on matchingconnection/connectionIDvalues.DataMessage inclusing Payload created in step 1, asymmetrically encrypted (ECIES algorithm as per Whisper standard) with ecdhpkA value. -
Send Envelope created in step 2.
-
Delete respective item in the Connection set (see 5.3) based on matching
connection/connectionIDvalues.
- Return that session denial has been sent.
Validate and decrypt Envelope (see 5.5).
- Read
connectionandovMessagefrom the Payload of received Envelope. - Delete respective item in the Connection set (see 5.3) based on matching
connection/connectionIDvalues.
- Notify that session invitation has been denied.
- Pass
ovMessageto session layer.
On the level of Node Connections, terminating a session (see OVIP-7, 4.3) or aborting a session (see OVIP-7, 4.4) are implemented the same.
| Element | Description | See |
|---|---|---|
connectionID |
Connection identifier | |
sessionMessage |
Termination Message or Session Abort Message | OVIP-7, section 4.3/4.4 |
-
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction101ovMessagesessionMessage -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below
Element Value / Specification TopicoutboundTopicvalue looked up in the Connection set based on matchingconnection/connectionIDvalues.DataMessage inclusing Payload created in step 1, symmetrically encrypted (AES GCM algorithm as per Whisper standard) with keyvalue looked up in the Connection set based on matchingconnection/connectionIDvalues. -
Add item to the Outbound Envelope Queue:
Element Value envelopeIDEnvelope identifier set in step 1 envelopeEnvelope created in step 2 expiryCurrent time + 900 seconds resends0connectionconnectionIDisCLOSETrue -
Send Envelope created in step 2.
- Return that session termination or session abort has been sent.
Validate and decrypt Envelope (see 5.5).
Send acknowledgement (see 5.6).
- Read
connectionandovMessagefrom the Payload of received Envelope. - Delete respective item in the Connection set (see 5.3) based on matching
connection/connectionIDvalues.
- Notify that session has been terminated or aborted.
- Pass
ovMessageto session layer.
| Element | Description | See |
|---|---|---|
connectionID |
Connection identifier | |
sessionMessage |
Application Message | OVIP-7, section 5 |
-
Create the Payload out of the elements defined in 4.1 and the specified values in the table below.
Element Value instruction100ovMessagesessionMessage -
Create Envelope out of the elements defined in sections 4. and 3. and the specified values in the table below
Element Value / Specification TopicoutboundTopicvalue looked up in the Connection set based on matchingconnection/connectionIDvalues.DataMessage inclusing Payload created in step 1, symmetrically encrypted (AES GCM algorithm as per Whisper standard) with keyvalue looked up in the Connection set based on matchingconnection/connectionIDvalues. -
Add item to the Outbound Envelope Queue:
Element Value envelopeIDEnvelope identifier set in step 1 envelopeEnvelope created in step 2 expiryCurrent time + 900 seconds resends0connectionconnectionIDisCLOSEFalse -
Send Envelope created in step 2.
- Return that Application Message has been sent.
Validate and decrypt Envelope (see 5.5).
Send acknowledgement (see 5.6).
Read connection and ovMessage from the Payload of received Envelope.
- Notify that Application Message has been received.
- Pass
ovMessageto session layer.
Transport layer reliability -- The original specification as per White Paper was amended by introducing acknowledgements in response to community feedback.
Alignment with new layer model -- A better separation between the different layers of OpenVASP was introduced by OVIP-9. This OVIP realigns the specification for using Whisper as transport layer with the new layer model.
Separate encryption on transport layer -- Separating encryption on transport and session layers will allow for a better security architecture as the internet-facing Whisper could be decoupled from the server handling the sessions. Further, it allows the usage of a Whisper node by different session handlers without giving access to session layers details, particularly originator/beneficiary data.
The specification proposed in this OVIP is not backwards compatible.
This OVIP is only superseded by OVIP-0016 in terms of terminology. All consequences of this ovip hold true by replacing the word "Whisper" with the word "Waku".