Message Encryption Test Vector Execution Guide
Normative test vectors · Common execution rules
Coverage
File: message-encryption-v1.json. Sections: envelope_signature, payload, timeline, and notification.
Fixed Inputs and References
envelope_signature provides signing input and results, and payload provides fixed inputs and results for message encryption and key boxes. timeline contains a complete request and key boxes for both sender and recipient; notification uses that request's envelope, certificate, and key boxes for field, signature, and retry checks.
Restore the surrounding references according to the following table:
| Reference field | Target in the same file |
|---|---|
envelope_signature.unsigned_object_ref |
/payload/encryption/envelope |
envelope_signature.recipient_boxes_ref |
/payload/encryption/recipient_boxes |
notification.base_envelope_ref, notification.variants[].envelope_ref |
/timeline/request/envelope |
notification.signing_private_key_ref, notification.signing_public_key_ref |
/timeline/sender_signing_private_key, /timeline/request/signer_certificate/signing_public_key |
notification.variants[].signing_input_utf8_hex_ref |
/timeline/envelope_signing_input_utf8_hex |
notification.signature_tampering[].envelope_ref, notification.retry_cases[].accepted_envelope_ref, notification.retry_cases[].retry_envelope_ref |
The original envelope or the complete envelope at /notification/variants/1/envelope or /notification/variants/2/envelope |
Each test independently copies the specified envelope, first deleting the root fields listed in remove, then adding or replacing the root fields given by set.
Execution Steps and Assertions
Envelope Validation and Recipient Decryption
Reconstruct the signing input from the restored unsigned envelope, compare it with the supplied input and signature, and verify the signature. Unwrap the recipient key box and decrypt the body, comparing the AAD, key derivation, and encryption/decryption results individually.
For each entry in notification.variants, reconstruct and compare signing_input_utf8_hex and device_signature, and validate the envelope's format and signature. Using the fixed inputs in timeline, recompute the message AAD, sender and recipient key boxes, and payload encryption/decryption, comparing intermediate values and encryption/decryption results with the original vector.
notification.field_cases applies operations to base_envelope and compares field validation results with expected_format_valid; when the format is valid, also compare expected_allows_push. This set does not verify signatures. notification.signature_tampering applies operations to the specified envelope while retaining the original signature, reconstructs the signing input, and compares expected_signature_valid.
AAD Authentication Rejection
payload.aad_rejection_cases uses the fixed content key, nonce, and ciphertext from payload.encryption. First reconstruct the message AAD object from that envelope and network_context, then replace the input fields specified by each case's aad_overrides, regenerate the Canonical JSON bytes, and directly perform AES-GCM authenticated decryption. expected_authenticated: false requires authentication failure without delivering plaintext.
These cases cover context mismatches caused by separate changes to the message ID, creation time, sender account, sender device, target account, network number, and Registry address. Envelope signature failure alone MUST NOT substitute for this authenticated decryption check.
Sender and Recipient Key Boxes
The KDF/AAD inputs, shared secrets, wrapping keys, and decryption results of the key boxes in timeline are exact protocol bytes. The implementation MUST also confirm that the original envelope's device signature is valid and that the sender key box can decrypt the same payload.
Idempotent Retries
notification.retry_cases assumes that accepted_envelope has been accepted, the result remains within its retention period, and all other call conditions hold. Execute each method in notification.retry_methods independently, keeping all other request parameters unchanged and replacing the envelope with retry_envelope. An expected_result of original_result means returning the original message's latest known delivery result; state_conflict means rejecting the conflicting request. expected_new_timeline_records and expected_new_push_triggers count the timeline records and offline push triggers added by this retry, respectively.