Skip to content
Almena ID— version v2026-12-beta
Auto
EnglishEN

Example: payment with a token

This page follows UC-01 from start to finish and shows every message exactly as it is written. It is informative: the rules are in the protocols and in the registries. At the end there are test vectors so that two implementations can check that they compute the same thing.

The messages are shown in plaintext, before being encrypted for the recipient. Signatures and long values are abbreviated with …, except in the test vectors.

Who Identifier in the example
Bank did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4
Merchant (an online shop) did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg
Person, with the bank did:peer:4zQmPersonWithBankExample (abbreviated)
Person, with the merchant did:peer:4zQmPersonWithMerchantExample (abbreviated)

The person already has a relationship with the bank and an account credential issued by it. They have never dealt with the merchant.

The example, step by step

The shop shows a QR code at checkout, and the same link next to it.

almena://invite?entity=did%3Akeri%3AIcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg&form=IFormHashSubscription…

The format of the link (registries, 7): links have the form almena://<action>?<parameters>, with the parameters URL-encoded. Actions in v2026-12-beta: invite (parameters entity, required, and form, optional: the network hash of the form version), signin (console sign-in: nonce, key and mailbox) and contact (counter QR code: key, mailbox and exp). A wallet MUST ignore parameters it does not know.

The wallet resolves the merchant’s did:keri, checks its Almena Trust credential, fetches the form and shows it to the person.

The form asks for the name, an email and a means of payment. The person fills in the first two and approves. Being the first message, it carries the full did:peer:4 (long form) and the mailbox.

{
"id": "0b7e5a52-3c1d-4f0e-8a6b-1d2c3e4f5a60",
"type": "urn:almena:msg:exchange:1.0:request",
"from": "did:peer:4zQmPersonWithMerchantExample…",
"to": ["did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg"],
"created_time": 1796292000,
"body": {
"form": "IFormHashSubscription…",
"fields": {
"given_name": "Ana",
"email": "ana@example.org"
},
"mailbox": {
"mediator": "IMediatorNodeExample…",
"uri": "https://mediator.example.net/didcomm"
}
}
}

The thid is omitted: in the first message of a thread it is the message’s own id.

3. The merchant asks for a means of payment

Section titled “3. The merchant asks for a means of payment”
{
"id": "6a1f0c2d-9e8b-4a7c-b6d5-e4f3a2b1c0d9",
"type": "urn:almena:msg:exchange:1.0:presentation-request",
"from": "did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg",
"to": ["did:peer:4zQmPersonWithMerchantExample"],
"created_time": 1796292002,
"thid": "0b7e5a52-3c1d-4f0e-8a6b-1d2c3e4f5a60",
"body": {
"form": "IFormHashSubscription…",
"nonce": "n-4c8f2a9e1b7d",
"nonce_expires": "2026-12-03T10:05:02Z"
}
}

The form’s DCQL query asks for a credential of type urn:almena:vct:token:1. The wallet shows the person their bank credentials; the person chooses one and approves the charge permission for this shop.

It goes through the relationship the person already has with the bank, in a new thread.

{
"id": "5e0b9c1e-6a8f-4d9e-9b1a-2c7d4e6f8a01",
"type": "urn:almena:msg:token:1.0:token-request",
"from": "did:peer:4zQmPersonWithBankExample",
"to": ["did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4"],
"created_time": 1796292030,
"body": {
"merchant": "did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg",
"credential": "iss-2f9a71c0",
"until": "2027-12-31"
}
}

credential is the issuance reference of the account credential the person chose. until is the optional end date of the permission.

{
"id": "c3d4e5f6-0718-4293-a4b5-c6d7e8f90a1b",
"type": "urn:almena:msg:exchange:1.0:issue",
"from": "did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4",
"to": ["did:peer:4zQmPersonWithBankExample"],
"created_time": 1796292031,
"thid": "5e0b9c1e-6a8f-4d9e-9b1a-2c7d4e6f8a01",
"body": {
"credentials": ["eyJhbGciOiJFUzI1NiIsInR5cCI6ImRjK3NkLWp3dCJ9.eyJpc3Mi…~"],
"permission": "perm-91d0b7",
"receipts": [
{
"record": "eyJhbGciOiJFUzI1NiIsImtpZCI6…",
"salt": "o6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6M",
"details": {
"parties": [
"did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4",
"did:peer:4zQmPersonWithBankExample"
],
"ref": "tkp-7f3c9a",
"thid": "5e0b9c1e-6a8f-4d9e-9b1a-2c7d4e6f8a01"
}
}
]
}
}

The token is an SD-JWT VC. Its payload, decoded:

{
"iss": "did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4",
"iat": 1796292031,
"exp": 1798884031,
"vct": "urn:almena:vct:token:1",
"cnf": { "kid": "did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg" },
"ref": "tkp-7f3c9a",
"status": { "status_list": { "idx": 4113, "uri": "urn:almena:data:status-list:1:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4:3" } }
}
  • cnf points to the merchant’s did:keri, not to a specific key: the merchant can rotate keys without the token losing validity.
  • ref is the random reference that only the bank understands; it is different in each token.
  • exp is 30 days after iat (provisional value).
  • status.uri is the name of the bank’s revocation list number 3 (network, 1.2), which any node serves at GET /1.0/status/IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4/3 (interface, 6).
  • There is nothing about the person.

The record of the receipt is the record exactly as it is published, a JWS signed with the bank’s record key (network, 7.1.2). Its content, decoded:

{
"type": "urn:almena:data:record:1",
"entity": "did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4",
"node": "did:keri:INodeOfTheBankExample…",
"seq": 1287,
"prev": "Ihx3…",
"op": "token.issued",
"time": "2026-12-03T10:00:31Z",
"commitment": "_zyZxkkxDmiyGZ7kb3ReKwXuyEV26lhQjrSzxO3Awsc"
}
  • prev is the network hash of the previous record in the chain: the SHA-256 of its JWS, in CESR (network, 1.1).

6. The wallet delivers the token to the merchant

Section titled “6. The wallet delivers the token to the merchant”

In the same thread as step 2.

{
"id": "8d9e0f1a-2b3c-4d5e-9f60-718293a4b5c6",
"type": "urn:almena:msg:exchange:1.0:request",
"from": "did:peer:4zQmPersonWithMerchantExample",
"to": ["did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg"],
"created_time": 1796292035,
"thid": "0b7e5a52-3c1d-4f0e-8a6b-1d2c3e4f5a60",
"body": {
"form": "IFormHashSubscription…",
"presentations": ["eyJhbGciOiJFUzI1NiIsInR5cCI6ImRjK3NkLWp3dCJ9.eyJpc3Mi…~"]
}
}

The token travels without a Key Binding JWT: its holder is the merchant, so the wallet cannot sign one, and the nonce does not apply to it. The merchant checks the bank’s signature, that vct is urn:almena:vct:token:1, that cnf is its own did:keri and that it is not revoked. Proof of possession comes later, in step 8, because token-redeem is signed by the merchant’s did:keri. Other credentials in the same request keep their Key Binding JWT with the nonce.

First the ack (only the header with the thid), then the result:

{
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"type": "urn:almena:msg:exchange:1.0:result",
"from": "did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg",
"to": ["did:peer:4zQmPersonWithMerchantExample"],
"created_time": 1796292037,
"thid": "0b7e5a52-3c1d-4f0e-8a6b-1d2c3e4f5a60",
"body": {
"result": "accepted",
"receipts": [
{ "record": "eyJ… (relationship.created)", "salt": "…", "details": { "…": "…" } },
{ "record": "eyJ… (presentation.verified)", "salt": "…", "details": { "…": "…" } }
]
}
}

Responses carry receipts, a list, because the first response of a relationship carries two: relationship.created and that of the operation.

On the day of the charge, through the relationship between the merchant and the bank:

{
"id": "f0e1d2c3-b4a5-4968-8776-655443322110",
"type": "urn:almena:msg:token:1.0:token-redeem",
"from": "did:keri:IcgloQMw1LT4EwgdltxSXcrFopZbdyLZ1-_uRsc0HATg",
"to": ["did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4"],
"created_time": 1796378400,
"body": {
"token": "eyJhbGciOiJFUzI1NiIsInR5cCI6ImRjK3NkLWp3dCJ9.eyJpc3Mi…~",
"amount": { "value": "19.90", "currency": "EUR" },
"concept": "Subscription, December 2026"
}
}

The amount is a decimal written as text, so that no precision is lost, and the currency is ISO 4217. The bank rejects a message whose id it has already received.

A result with the receipt of token.redeemed, whose details are the merchant, the bank, this thread and the ref of the token. Or a problem report with code e.p.request_rejected if it does not accept the charge. If it is the first message between the merchant and the bank, either response also carries the receipt of relationship.created (protocols).

1. Derivation of the pairwise identifier’s keys

Section titled “1. Derivation of the pairwise identifier’s keys”

The rule is in cryptography, 5: SLIP-10 over P-256, all levels hardened.

Input Value
Seed (32 bytes) 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
Entity did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4
SHA-256 of the entity (UTF-8) b156a75fc3b7ab30042d48b8f03855045ffc2266347cae4386978ce0845188d6
a, b, c, d 827762527, 1136110384, 70076600, 1882739972

Each index is 4 bytes of the hash, in order and big-endian, with the most significant bit set to 0.

Path Private key Public key (compressed)
m/4279373'/827762527'/1136110384'/70076600'/1882739972'/0' deb5c0cba65551a35f0c15732184e9b01909846554b1f15ff8695b2cddbac610 026e13086f657623b3a78067b11bcff7d6c4abc898f106ae54ea940338bff8b765
…/1' (seed of the hybrid key) 93d0d74c526bf3f4a3ea1758929ff9181398369465ba28b5273d940f657ed203 —

The hybrid key of k = 1 (cryptography, 3), whose two parts the KEM derives from that seed:

Value
Public key (pub) 1,249 bytes: the ML-KEM-768 public key (1,184 bytes) followed by the uncompressed P-256 point (65 bytes)
Its first 16 bytes 7e73360c051d0d5404f3912683e68cfb
Its last 16 bytes 13111a28faf5643455cae171f43ce413
SHA-256 of pub f8abc08f6f0848732f19b00d5312f9d34b908a5b83ee8771d9428169486fe075

The document of cryptography, 5 with the keys of vector 1, serialized with JCS:

Value
x of #key-0 bhMIb2V2I7OngGexG8_31sSryJjxBq5U6pQDOL_4t2U
y of #key-0 iMlprJ6jc2E2qJPXpxVg2F6hHX0CQ2TAajEABfSxSXo
pub of #key-1 The 1,249 bytes above in base64url (1,666 characters)
JCS of the document 2,022 bytes, with SHA-256 ec5df114725ad2d0811f09d98087ea5510a40b58b057edabc9c331be43a12d79
did:peer:4, short form did:peer:4zQmbkfvJ1vcXcwjsZ4JXkddduzajQRUEdy3yubbgnmqrqJG
did:peer:4, long form 2,823 characters: the short form, : and the encoded document

The rule (network, 7.1.2): commitment = SHA-256(salt ‖ JCS(details)), where the salt is 32 random bytes, JCS is the JSON canonicalization of RFC 8785 (keys sorted, no spaces) and parties is sorted alphabetically. The salt and the commitment are written in base64url without padding.

The token.issued record of step 5:

Value
Salt (hex) a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3
Salt (base64url) o6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6M
JCS(details) {"parties":["did:keri:IKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4","did:peer:4zQmPersonWithBankExample"],"ref":"tkp-7f3c9a","thid":"5e0b9c1e-6a8f-4d9e-9b1a-2c7d4e6f8a01"}
Commitment (hex) ff3c99c649310e68b2199ee46f745e2b05eec84576ea58508eb4b3c4edc0c2c7
Commitment (base64url) _zyZxkkxDmiyGZ7kb3ReKwXuyEV26lhQjrSzxO3Awsc

A real salt MUST be random. The one above is fixed only so that the vector can be reproduced.

The rule (network, 1.1): the SHA-256 of the bytes as they are published, in CESR with the code I. CESR puts a zero byte in front of the 32 bytes of the hash, encodes the 33 bytes in base64url and puts I in place of the first character.

Value
Data The 3 bytes abc
SHA-256 (hex) ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
Hash on the network ILp4Fr-PAc_qQUFA3l2uIiOwA2Gjlhd6nLQQ_2HyABWt