A key event receipt is a cryptographic message structure in KERI consisting of a body that references a key event and attachments containing one or more witness signatures, providing distributed attestation that designated witnesses have observed and validated the referenced key event.
Related Concepts
No related concepts available
Comprehensive Explanation
key-event-receipt
Structure Definition
A key event receipt is a fundamental data structure in the KERI (Key Event Receipt Infrastructure) protocol that serves as cryptographic evidence that one or more witnesses have received, verified, and attested to a specific key event. Unlike the key event itself, which represents a state change in an AID's control authority, a key event receipt is a separate message that provides independent verification of that event's existence and validity.
Core Components
The key event receipt consists of two mandatory components:
Body: A reference structure that identifies the key event being receipted. Rather than duplicating the entire key event, the body contains identifying information that uniquely points to the event, typically including:
The AID (Autonomic Identifier) of the event being receipted
The sequence number of the event
The SAID (Self-Addressing Identifier) digest of the event
Attachments: One or more cryptographic signatures from witnesses. The specification uses "MUST" to indicate this is a protocol-level requirement - a key event receipt without witness signatures is invalid. Each signature attachment:
Is created by a witness using its own private key
Attests to the witness's observation and validation of the referenced event
Is encoded using CESR (Composable Event Streaming Representation)
Implementation Notes
Critical Implementation Details
Receipt Generation Timing
Witnesses should generate receipts immediately after successful event validation to minimize latency. However, implementations must handle:
Asynchronous processing: Receipt generation should not block event reception
Queue management: Events should be queued for validation to handle bursts
Retry logic: Failed receipt transmissions should be retried with exponential backoff
Signature Attachment Format
CESR signature attachments use specific framing codes:
Verify the event digest matches the receipt's reference
Confirm sequence numbers align
Witness Signature Verification:
Identify the witness from the receipt's identifier field
Retrieve the witness's current public key from its KEL
Verify the signature using the witness's public key
Confirm the witness was designated by the controller at the time of the event
Threshold Validation:
Count valid witness receipts for the event
Compare against the controller's witness threshold (TOAD)
Determine if sufficient witnesses have receipted the event
Receipt Storage
Key event receipts are stored in KERLs (Key Event Receipt Logs), which combine:
The KEL (Key Event Log) containing the events themselves
All consistent key event receipt messages from witnesses
This combined structure enables validators to verify both the events and their witness attestations as a unified verifiable data structure.
Usage Context
Role in KERI Protocol
Key event receipts serve multiple critical functions in KERI:
Distributed Consensus: Receipts enable witnesses to reach agreement on key events without requiring a shared ledger or blockchain. The KAACE (KERI's Agreement Algorithm for Control Establishment) uses receipts to achieve Byzantine fault-tolerant consensus.
Duplicity Detection: When a controller creates conflicting versions of an event (duplicity), witnesses will receipt different versions. Comparing receipts from multiple witnesses reveals this duplicity, as witnesses will have signed different event digests.
Availability: Receipts enable indirect mode operation where validators can verify events even when the controller is offline. Witnesses maintain receipted events and can provide them to validators on demand.
Accountability: The TOAD mechanism uses receipts to establish accountability. When M witnesses receipt an event, the controller accepts accountability for that event, even if some witnesses are faulty.
Lifecycle Management
Key event receipts follow a specific lifecycle:
Generation: Created immediately after a witness validates an event
Promulgation: Distributed to other witnesses and stored in the witness's database
Collection: Gathered by validators who need to verify the event
Archival: Stored permanently in KERLs as part of the verifiable history
Verification: Used repeatedly by validators to confirm event validity
Receipts are never deleted or modified - they form part of the immutable audit trail for an identifier's history.
Integration with Other Structures
Key event receipts interact with several other KERI data structures:
KEL (Key Event Log): Receipts reference events in the KEL and are combined with the KEL to form a KERL
KERL (Key Event Receipt Log): The combined structure of KEL + receipts that provides the complete verifiable history
Witness Pools: Collections of witnesses that generate receipts according to the controller's configuration
OOBI (Out-Of-Band Introduction): Used to discover witnesses and retrieve their receipts
TEL (Transaction Event Log): Credential registries that use receipts to anchor credential state changes
Operational Modes
Key event receipts enable different operational modes in KERI:
Direct Mode: Controllers exchange events directly without witnesses. Receipts are not used in pure direct mode, though controllers may still receipt each other's events.
Indirect Mode: Witnesses receipt events and provide them to validators. This is the primary use case for key event receipts.
Hybrid Mode: Some events are witnessed while others are exchanged directly, allowing flexible security/performance trade-offs.
Security Properties
Key event receipts provide several security guarantees:
Non-repudiation: A witness cannot deny having receipted an event, as the receipt contains its cryptographic signature
Tamper-evidence: Any modification to a receipted event is detectable because the receipt's event digest will no longer match
Duplicity evidence: Conflicting receipts from the same witness for different versions of an event prove duplicitous behavior
Threshold security: The TOAD mechanism ensures that compromising fewer than M witnesses cannot prevent event validation
Performance Considerations
Key event receipts impact system performance in several ways:
Network overhead: Each witness generates and transmits a receipt, multiplying network traffic by the number of witnesses
Storage requirements: KERLs are larger than KELs due to receipt storage
Verification cost: Validators must verify multiple witness signatures for each event
Latency: Event finality depends on collecting sufficient receipts, which requires network round-trips
These costs are offset by the security benefits of distributed consensus and duplicity detection.
Implementation Patterns
Witness Receipt Generation
Witnesses implement receipt generation as an asynchronous process:
Event arrives via HTTP POST or TCP stream
Event is queued for validation
Validation occurs in background thread
Receipt is generated and signed
Receipt is stored in local database
Receipt is transmitted to configured endpoints
This asynchronous pattern prevents blocking on cryptographic operations and enables high throughput.
Receipt Collection Strategies
Validators can collect receipts using different strategies:
Eager collection: Request receipts immediately after receiving an event
Lazy collection: Defer receipt collection until validation is needed
Batch collection: Request receipts for multiple events simultaneously
Subscription: Subscribe to witness receipt streams for continuous updates
The choice depends on latency requirements, network conditions, and validation frequency.