Affinidi Messaging

A secure, private and trusted messaging framework based on DIDComm Messaging protocol.

Affinidi Messaging is a communication system built on the DIDComm v2.1 protocol. It ensures complete privacy and control of user data and identity during interactions with individuals, businesses, and AI agents.

Affinidi Messaging offers libraries and tools for implementing the DIDComm Messaging protocol, which builds upon the decentralized architecture of the Decentralised Identifier (DID) standard. This framework includes packages designed to enable secure and private messaging, as well as capabilities for discovering and establishing connections with individuals, businesses, or AI agents.

Core Concepts

  • Decentralised Identifier (DID) - A globally unique identifier that enables secure interactions. The DID is the cornerstone of Self-Sovereign Identity (SSI), a concept that aims to put individuals or entities in control of their digital identities.

  • DID Document - A DID is a URI (Uniform Resource Identifier) that resolves into a DID Document that contains information such as cryptographic public keys, authentication methods, and service endpoints. It allows others to verify signatures, authenticate interactions, and validate data cryptographically.

  • Envelope Encryption - A cryptographic technique that uses multiple layers of encryption to protect the data. A Data Encryption Key (DEK) encrypts the data, and then the Key Encryption Key (KEK) encrypts the DEK. This layered approach enhances security by protecting the data and the key to access it.

  • Mediator - A service that handles and routes messages sent between participants (e.g., users, organisations, another mediator, or even AI agents).

  • DIDComm Message - usually called DIDComm Encrypted Message is a JSON Web Message (JWM), a lightweight, secure, and standardised format for structured communication using JSON. It represents headers, message types, routing metadata, and payloads designed to enable secure and interoperable communication across different systems.

Requirements

  • Rust (1.85.0) 2024 Edition

  • Redis 8.0

Overall Crate Structure

Affinidi Messaging consists of different crates, each providing various libraries and tools that form the solution. Each crate has embedded sub-crates that provide different capabilities to support and run the main crate.

Affinidi Messaging

A messaging server built on DIDComm protocol that facilitates confidential and secure exchanges between senders and recipients.

Affinidi DID Resolver

A high-performance service that resolves and caches the DID document for a certain period, for faster resolution of DID documents and processing of messages.

Affinidi Meeting Place

Affinidi Meeting Place provides a safe and secure method for discovering and connecting with others using decentralised identifiers (DIDs) and the DIDComm Messaging protocol.

Affinidi TDK

The Affinidi Trust Development Kit (TDK) provides common elements for developing privacy-preserving services using decentralised identity technologies.

Get Started

To deploy the DIDComm Mediator from the open-sourced version, follow the steps below:

1. Prerequisites

Before you begin, install the following applications.

  1. Install Rust (1.85.0 2024 Edition) on your machine if you haven’t installed it yet using this guide.

  2. Install Docker on your machine if you haven’t installed it yet using this guide. We will need this to run Redis instance for the mediator to store messages temporarily and mediator configurations.

2. Clone the Mediator Repository

  1. Clone the GitHub repo on your local.
git clone git@github.com:affinidi/affinidi-tdk-rs.git
  1. Navigate to the crates/affinidi-messaging folder.
cd affinidi-tdk-rs/crates/affinidi-messaging

3. Set up the Mediator Instance

  1. Run the Redis Docker container using the command below from your terminal:
docker run --name=redis-local --publish=6380:6380 --hostname=redis --restart=on-failure --detach redis:latest

The latest supported version of Redis is version 8.0.

  1. Run setup_environment to configure the mediator with all the required information to run locally.
cargo run --bin setup_environment
Meeting Place App

Output from setup_environment

Select Local Mediator Configuration and follow the on-screen instructions. Upon successful setup, it will generate the following information:

  • Mediator DID and secrets.
  • Administration DID and secrets.
  • SSL Certificates for local development/testing.
  • Optionally, different users with their DIDs for testing.
  1. After completing the setup, navigate to the affinidi-messaging-mediator directory and run the following command to start the mediator:
cd affinidi-messaging-mediator && cargo run
  1. To verify that the mediator is running, open http://localhost:7037/mediator/v1/.well-known/did.json in your web browser. This page should display your local mediator’s DID document.

4. Test the Mediator Connection

The repository provides examples that you can run to test whether the setup was successful. To do this, follow the steps below:

  1. Open another terminal tab and go to the crates/affinidi-messaging folder.
cd affinidi-tdk-rs/crates/affinidi-messaging
  1. From the terminal, run the following example.
cargo run --example mediator_ping

The above example will execute a code that authenticates to the mediator and send a ping message. If successful, it sends a pong message back.

Enable Logging

To enable logging to see more information when running the example and to learn more about how it works, set the following environment variables from your terminal.

export RUST_LOG=none,affinidi_messaging_helpers=debug,affinidi_messaging_sdk=info

What’s Next

  Explore Meeting Place, an implementation of Affinidi Messaging

  Integrate Affinidi Messaging into your applications