| Crates.io | trql-client |
| lib.rs | trql-client |
| version | 0.1.0 |
| created_at | 2026-01-08 11:34:32.462996+00 |
| updated_at | 2026-01-08 11:34:32.462996+00 |
| description | Trust Registry |
| homepage | https://affinidi.com/ |
| repository | https://github.com/affinidi/affinidi-trust-registry-rs |
| max_upload_size | |
| id | 2030022 |
| size | 25,108 |
A high-performance, Rust-based implementation of a Trust Registry, fully compliant with the Trust Registry Query Protocol (TRQP) v2.0 specification. Built for scalability and reliability, it enables secure, standards-based verification of trusted entities within decentralised identity ecosystems.
Get the Trust Registry up and running quickly with default settings (DIDComm disabled).
cargo run --bin setup-trust-registry --features="dev-tools"
ENABLE_DIDCOMM=false RUST_LOG=info cargo run --bin trust-registry
The Trust Registry will start on http://localhost:3232 using CSV file storage with sample data from ./sample-data/data.csv.
# Query authorization
curl --location 'http://localhost:3232/authorization' \
--header 'Content-Type: application/json' \
--data '{
"authority_id": "did:example:authority1",
"entity_id": "did:example:entity1",
"action": "action1",
"resource": "resource1"
}'
For more details on how to set up and run the Trust Registry, see the Set up Trust Registry section.
A Trust Registry is a system that maintains and provides authoritative information about which entities, such as organisations, issuers, and verifiers, are authorised to perform specific actions on defined resources within a trust framework. Each entity is identified by its Decentralised Identifier (DID), ensuring cryptographic integrity and interoperability across decentralised identity ecosystems.
In decentralised identity and verifiable credentials, verifiers need to answer critical trust questions before accepting or validating credentials, such as:
The Trust Registry provides a standardised, queryable database that answers these trust questions by maintaining trust records and their permitted roles within a governance framework.
Authorisation Queries: “Has Authority A authorised Entity B to take Action X on Resource Y?”
Recognition Queries: "Does Authority X recognise Entity B as an authority to authorise taking Action X on Resource Y?”
The Trust Registry links:
This ensures security, compliance, and interoperability across decentralised identity systems.
Credential Issuance Verification
Verifies whether an issuer is authorised by a government or regulatory body to issue specific credential types (e.g., driver’s licences, professional certifications).
Trust Framework Compliance
Ensures that all participants in a digital trust ecosystem, such as issuers, verifiers, and relying parties, are recognised and approved by the appropriate governance authorities.
trust-registry: Unified server providing both RESTful API (TRQP endpoints for recognition and authorisation queries) and optional DIDComm messaging interface for CRUD admin operations.
Storage backends: Stores authoritative records about the entities for querying. It supports the following storage types:
Verify that your Rust installation meets the requirements.
rustc --version
cargo --version
To deploy and run a DIDComm mediator, see the deployment options page in the documentation.
Configure the environment to run Trust Registry. The setup command creates the .env file with default configurations. For testing environments, it generates .env.test or .env.pipeline files with the appropriate test configurations.
Prerequisites: You must have a running and accessible DIDComm mediator instance before proceeding. The mediator provides the messaging layer for secure communication between administrators, verifiers, and the Trust Registry.
If you don't have a mediator yet, see deployment options.
To enable DIDComm for managing and querying trust records, run the following command with your mediator's DID:
cargo run --bin setup-trust-registry --features="dev-tools" -- \
--mediator-did=<MEDIATOR_DID>
The command generates the following:
csv) and audit log format (json).To enable DIDComm for admin operations only, set the --only-admin-operations=true option:
cargo run --bin setup-trust-registry --features="dev-tools" -- \
--mediator-did=<MEDIATOR_DID> \
--only-admin-operations=true
This option ensures that the Trust Registry (TR) starts with Explicit Allow mode. In this mode, it only allows the admin DIDs specified in the environment file to send messages to perform administrative operations, such as creating, updating, and deleting trust records. Querying using TRQP is not accepted in this configuration.
After successful setup, it displays the command to run the Trust Registry.
RUST_LOG=info cargo run --bin trust-registry
To configure the Trust Registry without integration with DIDComm, run the following command:
cargo run --bin setup-trust-registry --features="dev-tools"
The command generates the following:
csv) and audit log format (json).After successful setup, it displays the command to run the Trust Registry.
ENABLE_DIDCOMM=false RUST_LOG=info cargo run --bin trust-registry
For more details on setting up the Trust Registry, refer to the setup guide document.
After setting up the Trust Registry, review the Docker settings in ./docker-compose.yaml. Start the containers using the following command:
docker compose up --build
The Trust Registry will be available at http://localhost:3232.
Note: The sample-data folder is mounted as a volume to synchronise the changes from data.csv to the container automatically. If you have configured a different path for the data using CSV as the storage backend, configure the Docker settings accordingly.
Redis is a high-performance, in-memory data store that can be used as a storage backend for Trust Registry. Redis provides fast read/write operations and is ideal for production deployments requiring low-latency access to trust records.
Install Redis (if not already available)
# macOS
brew install redis
# Ubuntu/Debian
sudo apt-get install redis-server
# Docker
docker run -d -p 6379:6379 redis:7-alpine
Start Redis (if installed locally)
redis-server
Configure Trust Registry to use Redis
Set the following environment variables:
TR_STORAGE_BACKEND=redis
REDIS_URL="redis://localhost:6379"
For Redis with authentication:
REDIS_URL="redis://username:password@localhost:6379"
For Redis with a specific database:
REDIS_URL="redis://localhost:6379/0"
Run Trust Registry
ENABLE_DIDCOMM=false RUST_LOG=info cargo run --bin trust-registry
entity_id|authority_id|action|resourceFor production deployments:
Enable Persistence: Configure Redis persistence to prevent data loss
# In redis.conf
save 900 1
save 300 10
save 60 10000
appendonly yes
Use Authentication: Always enable Redis authentication in production
# In redis.conf
requirepass your_strong_password
Configure Memory Limits: Set appropriate memory limits and eviction policies
# In redis.conf
maxmemory 2gb
maxmemory-policy noeviction
Use TLS: For secure connections, use Redis with TLS
export REDIS_URL="rediss://username:password@host:6380"
Monitor Performance: Use Redis monitoring tools to track performance
redis-cli INFO
redis-cli MONITOR
Example docker-compose.yaml configuration:
version: '3.8'
services:
redis:
image: redis:7-alpine
command: redis-server --requirepass your_password --appendonly yes
ports:
- "6379:6379"
volumes:
- redis-data:/data
restart: unless-stopped
trust-registry:
build: .
environment:
- TR_STORAGE_BACKEND=redis
- REDIS_URL=redis://:your_password@redis:6379
- ENABLE_DIDCOMM=false
- CORS_ALLOWED_ORIGINS=http://localhost:3000
- AUDIT_LOG_FORMAT=json
ports:
- "3232:3232"
depends_on:
- redis
restart: unless-stopped
volumes:
redis-data:
To migrate existing trust records to Redis:
TR_STORAGE_BACKEND environment variable to redisConnection Issues:
# Test Redis connectivity
redis-cli -h localhost -p 6379 ping
# Expected output: PONG
View stored records:
# List all keys
redis-cli KEYS "*|*|*|*"
# Get a specific record
redis-cli GET "did:example:entity1|did:example:authority1|action1|resource1"
Clear all test data:
redis-cli FLUSHDB
You can test the Trust Registry by querying the sample data stored in ./sample-data/data.csv:
curl --location 'http://localhost:3232/recognition' \
--header 'Content-Type: application/json' \
--data '{
"authority_id": "did:example:authority1",
"entity_id": "did:example:entity1",
"action": "action1",
"resource": "resource1"
}'
The API will return whether the specified entity is recognised by the given authority for the requested action and resource.
To query Trust Registry using DIDComm, refer to the Trust Registry Recognition Query protocol.
curl --location 'http://localhost:3232/authorization' \
--header 'Content-Type: application/json' \
--data '{
"authority_id": "did:example:authority1",
"entity_id": "did:example:entity1",
"action": "action1",
"resource": "resource1"
}'
The API will return whether the specified entity is authorised under the given authority for the requested action and resource.
To query Trust Registry using DIDComm, refer to the Trust Registry Authorization Query protocol.
Testing Tips:
./sample-data/data.csv to expand test coverage.context field contains a valid JSON object encoded in Base64. Invalid or malformed data should trigger appropriate error responses.Note: This section applies only when DIDComm is enabled. See Run with DIDComm Enabled for setup instructions.
You can manage trust records stored in the Trust Registry using DIDComm by sending messages to the Trust Registry's DID. DIDComm provides a secure, interoperable way to exchange messages between an administrator and the Trust Registry, making it ideal for trust record operations such as creating, updating, or querying records.
For reference, see the test-client implementation, which demonstrates how to build DIDComm clients and send these messages.
To run the sample client and interact with the Trust Registry:
MEDIATOR_DID="<TRUST_REGISTRY_MEDIATOR_DID>" TRUST_REGISTRY_DID="<TRUST_REGISTRY_DID>" cargo run --bin test-client
See Trust Registry Administration section for more details.
See the list of environment variables and their usage.
| Variable Name | Description | Required |
|---|---|---|
TR_STORAGE_BACKEND |
Storage backend for trust records. Options: csv, ddb, redis. |
Yes |
FILE_STORAGE_PATH |
Path to the CSV file when using CSV as the storage backend. | Required when TR_STORAGE_BACKEND = csv |
DDB_TABLE_NAME |
DynamoDB table name for storing trust records when using DDB as the storage backend. | Required when TR_STORAGE_BACKEND = ddb |
REDIS_URL |
Redis connection URL when using Redis as the storage backend. Format: redis://host:port or redis://username:password@host:port/db. |
Required when TR_STORAGE_BACKEND = redis |
CORS_ALLOWED_ORIGINS |
Comma-separated list of allowed URLs for CORS. | Yes |
AUDIT_LOG_FORMAT |
Output format for audit logs. Options: text, json. |
Yes |
MEDIATOR_DID |
Decentralised Identifier (DID) of the DIDComm mediator used as a transport layer for managing trust records. | Required when DIDComm is enabled |
ADMIN_DIDS |
Comma-separated list of DIDs authorised to manage trust records in the Trust Registry. | Required when DIDComm is enabled |
PROFILE_CONFIG |
Trust Registry DID and DID secrets for DIDComm communication. See Profile Config Options for configuration formats. Sensitive information, do not share. | Required when DIDComm is enabled |
ACL_MODE |
ACL Mode for Trust Registry when DIDComm is enabled. ExplicitDeny - public mode, ExplicitAllow - private mode | default: ExplicitDeny |
The PROFILE_CONFIG environment variable uses a URI-based loader that supports multiple configuration options. The loader allows you to store DID and DID secrets securely according to your deployment requirements.
| Scheme | Format | Description |
|---|---|---|
| Direct Value | PROFILE_CONFIG='<JSON_STRING>' |
Store the configuration directly as an inline JSON string in the environment variable. Recommended for local development. |
| String Protocol | PROFILE_CONFIG='string://<JSON_STRING>' |
Explicitly specify the value as a string literal. Same functionality as the direct value option. |
| File System | PROFILE_CONFIG='file://path/to/config.json' |
Load configuration from a JSON file on the local filesystem. The path must be accessible by the application. |
| AWS Secrets Manager | PROFILE_CONFIG='aws_secrets://<SECRET_NAME>' |
Retrieve configuration from AWS Secrets Manager. The secret value must be stored in plaintext format as a JSON string. |
| AWS Parameter Store | PROFILE_CONFIG='aws_parameter_store://<PARAMETER_NAME>' |
Load configuration from AWS Systems Manager Parameter Store. The parameter value must be a JSON string. |
Expected Value:
All options must provide the Trust Registry DID and DID secrets in the following JSON structure:
{
"alias": "Trust Registry",
"did": "did:peer:2.VzDna...",
"secrets": [
{
"id": "did:peer:2.VzDna...#key-1",
"privateKeyJwk": {
"crv": "P-256",
"kty": "EC",
"x": "RgvVBx01Mva...",
"y": "U5pT2A5WdIkD..."
},
"type": "JsonWebKey2020"
},
{
"id": "did:peer:2.VzDna...#key-2",
"privateKeyJwk": {
"crv": "secp256k1",
"d": "...",
"kty": "EC",
"x": "O9pWQXY...",
"y": "TQk8LY_BcY..."
},
"type": "JsonWebKey2020"
}
]
}
Examples:
# Direct value (local development)
PROFILE_CONFIG='{"alias":"Trust Registry","did":"did:peer:2.VzDna...","secrets":[...]}'
# File-based configuration
PROFILE_CONFIG='file:///etc/trust-registry/config.json'
# AWS Secrets Manager
PROFILE_CONFIG='aws_secrets://prod/trust-registry/profile'
# AWS Parameter Store
PROFILE_CONFIG='aws_parameter_store:///trust-registry/profile'
Note: If no URI scheme is specified, the loader parses the value as a direct string literal by default.
If you face any issues or have suggestions, please don't hesitate to contact us using this link.
If you have a technical issue with the project's codebase, you can also create an issue directly in GitHub.
Ensure the bug was not already reported by searching on GitHub under Issues.
If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behaviour that is not occurring.
Want to contribute?
Head over to our CONTRIBUTING guidelines.