-
Notifications
You must be signed in to change notification settings - Fork 1
DIDComm v2 Mediator Implementation
As a general principle, the Mediator implements the latest specifications and protocols from DIF and Aries Interoperability Profiles, in particular:
- DIF DIDComm Messaging V2
- Aries RFC 0434: Out-of-Band Protocol 1.1
-
Aries RFC 0160: Connection Protocolreplaced by Aries RFC 0023 - Aries RFC 0023: DID Exchange Protocol 1.0
- Aries RFC 0211: Mediator Coordination Protocol
- Aries RFC 0092: Transports Return Route
- Aries RFC 0212: Pickup Protocol 2.0
- Peer DID Method Specification
The initial implementation uses HTTPS transport with Transport Return Route, meaning that the mobile user sends messages to the mediator as HTTPS POST requests, and receives a message back from the mediator in the HTTPS response body.
Additionally, the Pickup Protocol is implemented so mobile users can retrieve pending messages from the mediator asynchronously. Future releases will implement a websocket transport with Live Mode capability that adds a better realtime communication when both parties are online.
In the following process Alice(A) wants to invite Bob(B) to create a connection by exchanging DID (did:peer). Since A is a mobile user and can't provide a direct link to communicate, she will use a mediator(M) as a means to be reached out. B may or may not need a mediator, but if that is the case, the mediator can be the same (M) or another.
The process below includes as reference the @type of the message as defined in Aries protocols:
- Initially, A needs to connect with M, so M provides to A an out-of-band invitation in an URL or QR code stating a connection URL in
serviceEndoint
and a did:peer inrecipientKeys
("@type": "https://didcomm.org/out-of-band/%VER/invitation"). Note that this did:peer is a general invite DID used only for initial communication set up. -
A creates a dedicated did:peer to connect to M
A.didpeer@A:M
. -
A generates a request messsage ("@type": "https://didcomm.org/didexchange/1.0/request") providing her DID documment for key
A.didpeer@A:M
. The message is encrypted with M invitation keys and POSTed to the URL obteined inserviceEndpoint
-
M creates a dedicated did:peer to connect to A
M.didpeer@M:A
-
M responds the received http POST message with a response message ("@type": "https://didcomm.org/didexchange/1.0/response") providing the DID documment for
M.didpeer@M:A
. Message is encrypted forA.didpeer@A:M
- To conlcude the communication setup, A sends a complete message to M ("@type": "https://didcomm.org/didexchange/1.0/complete"), that M responds with 200 success. This final message is still encrypted with M's invitation keys. Subsecuent communication will use
M.didpeer@M:A
andA.didpeer@A:M
. - Now A starts a mediation request by POSTing a mediate-request message ("@type": "https://didcomm.org/coordinate-mediation/1.0//mediate-request") to M, which is replied with a mediate-grant message("@type": "https://didcomm.org/coordinate-mediation/1.0//mediate-grant"). Messages are encrypted with
A.didpeer@A:M
andM.didpeer@M:A
. The mediate-grant message provides theendpoint
androuting-keys
needed by B (TODO: check if routing-keys are per mediate-grant or per user) -
A creates a did:peer to invite B
A.didpeer@Ainvite:B
-
A updates the list of recipient keys in M by POSTing a keylist-update message to M ("@type": "https://didcomm.org/coordinate-mediation/1.0//keylist-update") including
A.didpeer@Ainvite:B
- M responds the keylist-update with a keylist-update-response message("@type": "https://didcomm.org/coordinate-mediation/1.0//keylist-update-response")
-
A creates an out-of-band inviation with mediator
endpoint
androuting-keys
, andA.didpeer@A:B
inrecipientKeys
("@type": "https://didcomm.org/out-of-band/%VER/invitation"). B gets this message as a QR code or URL -
B creates a dedicated did:peer to communicate with A
B.didpeer@B:A
-
B creates a request messsage ("@type": "https://didcomm.org/didexchange/1.0/request") providing
B.didpeer@B:A
DID document. He may also needs to add aserviceEndpoint
and/orrouting-keys
if using also a mediator. The message is encrypted withA.didpeer@Ainvite:B
keys. -
B wraps the message in a Forward message ("type": "https://didcomm.org/routing/2.0/forward") and encrypts with M
routing-keys
-
B POST the message to M at
endpoint
defined in the out-of-band invitation -
M unpacks the forward message, inspects the
to
field, looks up keys in its DB and stores the message as pending delivery for A - Asynchronously, A checks with M if there're pending messsages by POSTing to M a status-request ("@type": "https://didcomm.org/messagepickup/2.0/status-request") that is replied with the status message ("@type": "https://didcomm.org/messagepickup/2.0/status")
- If there're pending messages, A POST a delivery-request message to M ("@type": "https://didcomm.org/messagepickup/2.0/delivery-request") that is responded with the delivery message ("@type": "https://didcomm.org/messagepickup/2.0/delivery") that includes message from B.
- A finalizes the message pickup with a messages-received message ("@type": "https://didcomm.org/messagepickup/2.0/messages-received")
- After receiving the connection request from B, A generates a new dedicated did:peer to connect with B
A.didpeer@A:B
. -
A updates the list of recipient keys in M by POSTing a keylist-update message to M ("@type": "https://didcomm.org/coordinate-mediation/1.0//keylist-update") including
A.didpeer@A:B
and removingA.didpeer@Ainvite:B
. -
A creates a response message ("@type": "https://didcomm.org/didexchange/1.0/response") including her DID documment with key
A.didpeer@A:B
, mediator's routing key, and mediator's endpoint inserviceEndpoint
. Message is encrypted forB.didpeer@B:A
-
A sends the message to B using B
serviceEndpoint
orrouting-keys
. That process may require a mediator as well, that can be same mediator or another. - B sends the complete message to finalize communication setup and wrap it in a Forward message as before.
- A receives the complete message from the mediator by quering M for message pickup as before
- A and B are now ready to communicate
NOTE: all post message from A will have the decorator for Transports Return Route
(TODO: check mediation_id
)