Internet-Draft MDA/1 November 2026
Johnson Expires 27 May 2027 [Page]
Workgroup:
Network Working Group
Internet-Draft:
draft-johnson-mda1-protocol-00
Published:
Intended Status:
Standards Track
Expires:
Author:
S. Johnson
TTI-Simplenet Software Solutions

Flat Data Artifact Format, Version 1 (MDA/1) Protocol

Abstract

This document specifies the Flat Data Artifact Format Version 1 (MDA/1), a fixed-layout, zero-copy binary container for exchanging and storing signed data artifacts in resource-constrained, intermittently connected, and offline environments. MDA/1 artifacts have one canonical encoding and a stable content identifier, can be parsed without dynamic memory allocation, and are validated by a strictly ordered pipeline whose limits are enforced from a 64-byte header. Every byte except the signature values is covered by Ed25519, ML-DSA-44, or hybrid signatures, and signers are bound to the principals they speak for. The document also defines VB01, a key-committing, length-bucketed AEAD frame for payloads at rest, and an HPKE profile, including the X-Wing post-quantum KEM, for delivering frame keys. MDA/1 is intended as a compact edge transport and storage envelope alongside HL7 FHIR.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 27 May 2027.

▲

Table of Contents

1. Introduction

1.1. Scope

This document defines MDA/1, a single flat, fixed-layout binary container for data artifacts that edge systems exchange or store: control messages (request, consent, grant, receipt, revocation, error), asset metadata, append-only log records, provenance commitments, ledger anchor receipts, snapshots, emergency profiles, break-glass audit receipts, trust bundles, and DID document envelopes. It also defines VB01, a length-hiding encrypted frame for asset payloads at rest, and the HPKE key-wrapping profile used to deliver frame keys.

The target environment is low-end mobile hardware, intermittent power and connectivity, offline verification, and parsers that fit in a few kilobytes of compiled code and run without dynamic memory allocation.

1.2. Design Goals

  • Zero-copy access: every fixed field is found by offset arithmetic on the input buffer. Every multi-byte integer is naturally aligned relative to the start of the artifact.
  • Bounded parsing: no recursion, no pointer chasing, no input-dependent allocation. All limits are checked against the 64-byte header before any other byte is interpreted.
  • One canonical encoding: for a given logical artifact, every byte that contributes to its identity is uniquely determined, and receivers reject every other encoding. An artifact therefore has exactly one ArtifactID (Section 8.3).
  • Complete authentication: a signature covers every byte of the artifact except the signature values themselves and the CRC field, including the signature metadata and the Blob section.
  • Algorithm agility: classical (Ed25519, X25519) and post-quantum or hybrid (ML-DSA-44, X-Wing) algorithms share one layout. Large post-quantum values live in variable-length sections, so fixed strides do not change.
  • Unified parsing: one container parser handles every artifact type; type-specific code reads fields at known offsets.

1.3. Non-Goals

  • MDA/1 is not a general-purpose serialization format and has no nesting, maps, or schema language.
  • MDA/1 does not define DID methods, verifiable credential formats, or online resolution protocols. It defines how keys are resolved offline from material that is itself carried in MDA/1 artifacts (Section 8.7).
  • MDA/1 does not provide transport security, confidentiality of control artifacts, or traffic-flow confidentiality. Control artifacts are signed, not encrypted; see Section 20.
  • EMERGENCY_PROFILE artifacts are deliberately readable without keys. Break-glass auditing in MDA/1 is a detective control, not a preventive one (Section 19.11).

1.4. Relationship to HL7 FHIR

MDA/1 does not replace HL7 FHIR [FHIR]. It is an offline-first binary transport and edge-storage envelope used alongside FHIR systems. Gateways convert between FHIR resources and MDA/1 artifacts at the boundary between a connected FHIR server and disconnected edge devices.

The conversion is a lossy profile, not an isomorphism. Only the elements listed below are carried. A gateway MUST reject, rather than silently truncate, a FHIR resource whose meaning depends on elements that the profile cannot carry. Examples are nested or "deny" Consent provisions, and Composition sections outside the list below. A resource reconstituted from MDA/1 MUST be marked as derived (for example, with a meta.tag) and MUST NOT be presented as the original resource.

Table 1: FHIR mapping profile
FHIR R4 resource MDA/1 artifact Elements carried
Consent CONSENT (0x02) patient, one permit provision: actor, purpose, period, data (as scopes)
Composition (IPS) EMERGENCY_PROFILE (0x20) allergies, meds, problems, contacts, advance directive
AuditEvent EMERGENCY_ACCESS_RECEIPT (0x21) agent, entity, recorded, source
Provenance PROVENANCE_COMMITMENT (0x12) target, agent, recorded
DocumentReference + ASSET_MANIFEST (0x10) identifier, type,
Binary + VB01 frame date, content

The EMERGENCY_PROFILE row follows the International Patient Summary [IPS]. Coded concepts are carried as two strings: a code and a code-system URI. Text longer than 256 bytes (for example, medication instructions) is carried in the record text span (Section 7.2).

2. Conventions and Terminology

2.1. Requirements Language

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

2.2. Terminology

Artifact:
A complete MDA/1 byte string, from the first byte of the header to the last byte of the signature value section.
Encoder:
An implementation that produces artifacts.
Receiver:
An implementation that consumes artifacts and runs the validation pipeline (Section 15).
ArtifactID:
The SHA-256 digest that identifies an artifact (Section 8.3). Every hash32 field in this document whose name ends in "Ref" holds an ArtifactID, unless its definition says otherwise.
Principal field:
The body field naming the party that must sign an artifact (Section 8.6).
Absent:
The reserved encoding meaning "no value": 0xFFFFFFFF for str_ref, {0, 0} for span, and 32 zero bytes for an OPTIONAL hash32 field.
Supported minor version:
The highest minor version a receiver implements. This document defines minor version 0.
Closed / open enumeration:
Defined in Section 13.1.

2.3. Normative Encoding Rules

Table 2: Normative encoding rules
Rule Statement
C-1 All multi-byte integers are little-endian.
C-2 Timestamps (ts) are unsigned milliseconds since the Unix epoch, UTC. Durations named *Sec are seconds. The value 0 means "unbounded" only where a field definition says so.
C-3 Reserved fields, reserved flag bits, and all padding MUST be zero on emission. Receivers MUST reject non-zero values unless Section 17 permits them.
C-4 Every section starts at an offset that is a multiple of 16 and has a length that is a multiple of 16. No bytes follow the signature value section.
C-5 Absent str_ref = 0xFFFFFFFF; absent span = {0, 0}; absent OPTIONAL hash32 or raw16 = all zero bytes.
C-6 The string table is sorted, unique, fully referenced, and well-formed UTF-8 (Section 5).
C-7 Records appear in canonical order (Section 7.1).
C-8 Signature entries and values appear in canonical order (Section 8).
C-9 Blob items appear in canonical layout (Section 6.2).
C-10 The CRC-32 is verified before any byte outside the header is interpreted (Section 15.1).
C-11 Size bounds (Section 14) are enforced from the header before any input-dependent memory allocation.
C-12 Offset and length arithmetic MUST NOT wrap: it uses at least 64-bit unsigned integers or checked arithmetic.

Rules C-3 through C-9 make the encoding canonical. For a given logical artifact, meaning a given value for every field, including identifiers, nonces, and timestamps, the bytes from offset 0 to sigValOff are uniquely determined. Encoders MUST normalize every string to Unicode Normalization Form C [UAX15] before encoding. Receivers are not required to check NFC, because doing so needs Unicode tables that a minimal parser cannot carry; Section 19.6 explains why this does not create malleability.

Signature values (Section 8.2) and VB01 frames (Section 9) may be randomized. Neither contributes to the ArtifactID, so the ArtifactID stays stable.

3. Primitive Types

Table 3: Primitive types
Name Size Definition
u8 1 Unsigned 8-bit integer
u16 2 Unsigned 16-bit integer, little-endian
u32 4 Unsigned 32-bit integer, little-endian
u64 8 Unsigned 64-bit integer, little-endian
i32 4 Two's-complement signed 32-bit, little-endian
ts 8 u64 milliseconds since Unix epoch, UTC
enum8 1 Enumerated value (Section 13)
raw16 16 Identifier or nonce: 128 bits from a CSPRNG
hash32 32 SHA-256 digest [FIPS180-4]
str_ref 4 u32 absolute offset of a string table entry, or 0xFFFFFFFF (absent)
span 8 {u32 off, u32 len}: absolute offset and length of a Blob item, or {0, 0} (absent)
bytes n Opaque octets

Every identifier and nonce field is a raw16 generated by a cryptographically secure random number generator. Encoders MUST NOT derive identifiers from counters, timestamps, or personal data. Where text is needed, an identifier is written as 32 lowercase hexadecimal characters ("canonical ID text").

4. Container Format

4.1. Section Layout

Every artifact is a sequence of seven contiguous, non-overlapping sections, in this fixed order:

0      64         recOff     sigOff     strOff   blobOff  sigValOff
+------+----------+----------+----------+--------+--------+--------+
|Header|   Body   | Records  |Signature | String |  Blob  |Sig     |
| 64 B | bodyLen  |rc * rs   | entries  | table  |        |values  |
|      |          |          | sc * 32  | strLen | blobLen|sigValLn|
+------+----------+----------+----------+--------+--------+--------+
|<-------------- ArtifactID and signature coverage ------>|
|<-------------------------- CRC-32 coverage ---------------------->|
Figure 1: Section layout

Signature values come last, so every signature covers every other section, the signature entries included (Section 8.4).

4.2. Header

Table 4: MDA/1 header (64 octets)
Off Size Field Type Notes
0 4 magic bytes ASCII "MDA1" (4D 44 41 31)
4 1 major u8 Major version; this spec = 1
5 1 minor u8 Minor version; this spec = 0
6 1 type u8 Artifact type (Section 11)
7 1 (rsv) u8 Reserved
8 2 flags u16 Header flags (Section 4.3)
10 2 strCount u16 Number of string entries
12 4 totalLen u32 Artifact size in bytes
16 4 bodyLen u32 MUST equal type body size
20 2 recCount u16 Number of records
22 2 recStride u16 Record stride, 0 if none
24 2 sigCount u16 Number of signature entries
26 2 sigStride u16 32 if sigCount > 0, else 0
28 4 strOff u32 String table offset
32 4 strLen u32 String table length
36 4 blobOff u32 Blob section offset
40 4 blobLen u32 Blob section length
44 4 sigValOff u32 Signature value offset
48 4 sigValLen u32 Signature value length
52 4 crc32 u32 CRC-32 (Section 4.5)
56 8 (rsv) bytes Reserved

4.3. Header Flags

Table 5: Header flags
Bit Name Meaning
0 FLAG_SIGNED MUST be 1 if sigCount > 0, else 0.
1..7 (non-critical) Reserved for minor-version extensions that receivers may ignore.
8..15 (critical) Reserved for extensions that change how the artifact must be processed.

FLAG_SIGNED only describes the artifact's structure. Whether an artifact must be signed is decided by its type (Section 8.6), never by this flag. In minor version 0, every bit except bit 0 MUST be zero. A receiver MUST reject an artifact that sets a critical bit it does not implement (UNKNOWN_CRITICAL_FLAG), whatever the artifact's minor version.

4.4. Section Topology

Receivers derive every section offset from lengths, using arithmetic that cannot overflow (C-12):

recOff    = 64 + bodyLen
sigOff    = recOff + recCount * recStride
strOff    = sigOff + sigCount * sigStride
blobOff   = strOff + strLen
sigValOff = blobOff + blobLen
totalLen  = sigValOff + sigValLen

The header's strOff, blobOff, sigValOff, and totalLen MUST equal these values. In addition:

  • bodyLen MUST equal the body size the Type Registry gives for the type (Section 11).
  • recStride MUST equal the registered stride if recCount > 0, and MUST be 0 if recCount = 0. For types with registered stride 0, recCount MUST be 0.
  • sigStride MUST be 32 if sigCount > 0, and MUST be 0 if sigCount = 0.
  • strLen, blobLen, and sigValLen MUST each be a multiple of 16.
  • totalLen MUST equal the number of octets received. An artifact always arrives as a discrete unit whose length the transport or storage layer knows. Receivers MUST NOT read totalLen bytes from a buffer before checking this equality.

4.5. CRC-32

crc32 is CRC-32/ISO-HDLC [ISO13239]: polynomial 0x04C11DB7, reflected, initial value and final XOR 0xFFFFFFFF (the CRC used by zlib). It is computed over [0, totalLen) with the crc32 field treated as four zero bytes. It is written last.

The CRC only detects accidental corruption cheaply, before more expensive work. It offers no protection against deliberate modification (Section 19.2).

5. String Table

5.1. Entry Format

The string table holds exactly strCount entries, followed by zero padding up to strLen. Each entry is:

u16 len || len octets of UTF-8 || 0x00 if len is odd

Every entry therefore starts at an even offset. The padding after the last entry MUST be zero and shorter than 16 octets.

5.2. Ordering and Uniqueness

Entries MUST be in strictly ascending order of their UTF-8 octets, compared as unsigned bytes. A proper prefix sorts before any longer string that starts with it, as with memcmp() followed by a length comparison. Strict order also means duplicates are forbidden.

Because entries are sorted, entry offsets increase in the same order as entry contents. Within one artifact, comparing two present str_ref values as unsigned integers gives the same result as comparing the strings they point to. The absent value 0xFFFFFFFF sorts after every present value. Section 7.1 relies on this.

5.3. Content Rules

  • len MUST be in the range 1..256. Empty strings are forbidden; an absent value uses str_ref 0xFFFFFFFF.
  • The octets MUST be well-formed UTF-8 [RFC3629]: no overlong forms, no surrogates, nothing above U+10FFFF. They MUST NOT contain U+0000.
  • Every entry MUST be referenced by at least one str_ref somewhere in the artifact: body, records, or signature entries. Orphan entries are forbidden.
  • Text longer than 256 octets is not a string. It is carried in the Blob section through a text span (Section 7.2), or in a type-specific span.

5.4. String References

A present str_ref MUST equal the absolute offset of the len field of one of the strCount entries. Receivers check this against the set of entry start offsets found while walking the table in step B1 (Section 15.2).

6. Blob Section and Spans

6.1. Spans

A present span {off, len} names the octets [off, off + len) inside the Blob section. len MUST be at least 1, so {0, 0} is the only way to encode absence. Spans MUST NOT overlap. Two span fields MUST NOT reference the same octets, even when the content is identical.

6.2. Canonical Blob Layout

Blob items are laid out in "span order". Body span fields come first, in increasing field offset. Record span fields follow, in record order, and within a record in increasing field offset. The first present span starts at blobOff. Each later present span starts at the smallest multiple of 16 that is at or past the end of the previous item. The bytes between items MUST be zero. blobLen MUST equal the end of the last item rounded up to a multiple of 16, or 0 if there are no items.

This rule leaves no unreferenced or ambiguous octets in the Blob section. A receiver checks it in one pass with no allocation (Section 15.2, step B5).

Signature values are not blob items. They have their own section (Section 8.2).

7. Record Tables

A record table holds recCount fixed-stride records. MDA/1 defines three record layouts: the Generic Record (stride 48, Section 7.2), the Trust Record (stride 96, Section 12.14), and the Proof Record (stride 32, Section 12.10). The Type Registry (Section 11) gives each type's layout.

7.1. Canonical Record Order

Except in ANCHOR_RECEIPT (Section 12.10), records MUST appear in strictly ascending order under this comparison. Duplicate records are therefore forbidden.

  1. Fields are compared one at a time in the order the record layout lists them. Reserved fields are skipped.
  2. Integer and enumerated fields compare numerically. ts fields are integers.
  3. str_ref fields compare by the octets they reference (Section 5.2), and absent sorts after every present value. Within one artifact this is the same as comparing the u32 values numerically.
  4. span fields compare by the octets they reference, with the same prefix rule, and absent sorts after every present value.
  5. hash32 and raw16 fields compare as unsigned byte strings.

This order depends only on logical values, never on where strings or blob items happen to sit. The same set of records therefore sorts identically in every artifact that carries it.

The order is compared field by field, not byte by byte over the record, because little-endian integers and absolute offsets do not sort correctly as raw bytes.

7.2. Generic Record (RS 48)

Table 6: Generic record (48 octets)
Off Size Field Type Notes
0 1 reckind enum8 Record kind, closed
1 1 subkind enum8 Per-kind subtype
2 2 flags u16 Reserved in minor 0
4 4 field1 str_ref Primary string
8 4 field2 str_ref Secondary string
12 4 field3 str_ref Tertiary string
16 8 ts1 ts Start / primary time
24 8 ts2 ts End / secondary time
32 4 num u32 Numeric value
36 4 (rsv) u32 Reserved
40 8 text span Long UTF-8 text in Blob

flags MUST be zero in minor version 0. The text span holds UTF-8 text of 1 to 65536 octets that does not fit in a string; it follows Section 5.3, except for the length limit and the reference rule. Record kinds that do not use text MUST set it absent. A record field that a kind does not use MUST be zero or absent.

7.3. Generic Record Kinds

Table 7: Generic record kinds
kind Meaning field1 field2 field3 subkind
0x01 Allergy substance reaction code severity
0x02 Medication name dose frequency route
0x03 Condition name code codeSystem status
0x04 Contact name relation phone priority
0x05 Scope assetId assetType category versOp
0x06 Tag tag (absent) (absent) 0
  • Allergy (0x01): field3 is an OPTIONAL coded substance in token form, "system|code". ts1 is the onset time, or 0 if unknown. text holds OPTIONAL notes. subkind is a severity value (Section 13.23).
  • Medication (0x02): ts1 and ts2 bound the medication period, where 0 means unbounded. text holds OPTIONAL full instructions. subkind is a route value (Section 13.23).
  • Condition (0x03): field2 and field3 together carry the coded concept, a code and the URI of its code system. ts1 is the onset time. subkind is a clinical status value (Section 13.23).
  • Contact (0x04): field3 is an E.164 telephone number. subkind is the contact priority: 1 is highest, and 0 means unspecified.
  • Scope (0x05): see Section 7.4.
  • Tag (0x06): field1 is a tag string. Every other field is zero or absent.

Section 13.22 lists which record kinds each type allows. A record kind the type does not allow MUST be rejected (UNKNOWN_ENUM).

7.4. Scope Records and Matching

A Scope record describes a set of assets. field1, when present, is the canonical ID text (Section 3) of one ASSET_MANIFEST assetId. field2, when present, is the name of a contentType value (Section 13.11), such as "lab". field3, when present, is a category that MUST equal the tag of one of the asset's Tag records. ts1 and ts2 bound the asset's capturedAt; 0 means unbounded and both bounds are inclusive. subkind is versionOp (Section 13.21), and num holds the version operand.

An asset with ASSET_MANIFEST m matches a Scope record s when every one of the following holds:

  • s.field1 is absent, or it equals the canonical ID text of m.assetId.
  • s.field2 is absent, or it equals the name of m.contentType.
  • s.field3 is absent, or m has a Tag record whose field1 equals s.field3.
  • s.ts1 = 0 or s.ts1 <= m.capturedAt, and s.ts2 = 0 or m.capturedAt <= s.ts2.
  • versionOp is satisfied. Under 0x01 (exact), m.version = num. Under 0x02 (at-least), m.version >= num. Under 0x03 (latest), num MUST be 0, and m is the highest version of its assetId that the evaluator holds.

A set of Scope records matches an asset if any one of them matches.

7.5. ScopeDigest

ScopeDigest commits to a set of Scope records in a form that does not depend on where strings sit in the artifact, so it can be compared across artifacts:

ScopeDigest = SHA-256( "MDA1SCP\0" || u32 n ||
                       for each Scope record in canonical order:
                         u8 subkind || S(field1) || S(field2) ||
                         S(field3) || u64 ts1 || u64 ts2 || u32 num )

S(x) = u16 len || octets   (len = 0 when x is absent)

All integers are little-endian, and n is the number of Scope records. Appendix A.2 gives a test vector.

8. Signatures and Artifact Identity

8.1. Signature Entry

Table 8: Signature entry (32 octets)
Off Size Field Type Notes
0 4 signerDID str_ref Signer DID
4 1 alg enum8 Algorithm (13.2), closed
5 1 purpose enum8 Purpose (13.3), closed
6 2 (rsv) u16 Reserved
8 8 signedAt ts Signing time
16 4 keyRef str_ref Verification method id
20 4 valOff u32 Absolute offset of value
24 4 valLen u32 Value length (8.2)
28 4 (rsv) u32 Reserved

Signature entries MUST appear in strictly ascending order of (purpose, octets of the signerDID string). Two entries therefore never share the same purpose and signer. signerDID MUST be present.

keyRef is a DID URL fragment, including the leading "#", that identifies the verification method within the signer's DID document. It MAY be absent only when the signer is a did:key DID; the key is then the one encoded in the DID itself (Section 8.7).

8.2. Signature Values

Table 9: Signature value sizes
alg Algorithm valLen Value
0x01 Ed25519 [RFC8032] 64 Ed25519 signature
0x02 ML-DSA-44 [FIPS204] 2420 ML-DSA signature
0x03 Ed25519 + ML-DSA-44 (hybrid) 2484 Ed25519 signature

|, |, | || ML-DSA sig.

valLen MUST equal the size in the table for the entry's alg. Values sit in the signature value section in signature-entry order. The first starts at sigValOff, and each later one starts at the next multiple of 16 after the end of the previous value. valOff MUST equal that computed position. The padding between values and after the last value MUST be zero, and sigValLen MUST equal the padded total.

8.3. ArtifactID

ArtifactID = SHA-256( A[0 .. sigValOff) )

A is the artifact with octets [52, 56), the crc32 field, set to zero. The ArtifactID covers every section except the signature values. That includes the header (and with it every length), the signature entries (signer, algorithm, purpose, signedAt, key reference, and value placement), and the Blob section.

Every hash32 field defined as an ArtifactID MUST hold exactly this value. Section 15 rejects every non-canonical encoding, and the signature values are excluded, so two artifacts with the same ArtifactID are the same logical artifact.

8.4. Signing Procedure

  1. The encoder builds the complete artifact with every field final, the signature value section filled with zeros, and crc32 set to zero. Every signer and its signature entry must be known at this point (Section 8.8).
  2. It computes the ArtifactID.
  3. It forms TBS = "MDA1SIG\0" || ArtifactID, 40 octets. The 8-octet domain tag is 4D 44 41 31 53 49 47 00.
  4. Each signer signs TBS:

    • Ed25519: the signature over TBS from Ed25519 as defined in [RFC8032], Section 5.1.6 (pure Ed25519, no prehash, no context).
    • ML-DSA-44: ML-DSA.Sign(sk, TBS, ctx) as defined in Algorithm 2 of [FIPS204], with ctx = "MDA1" (4 octets). Either the hedged or the deterministic variant MAY be used.
    • Hybrid: the Ed25519 signature over TBS, followed by the ML-DSA-44 signature over TBS. Both MUST verify. alg is part of the ArtifactID, so removing one component changes TBS and is detected (Section 19.5).
  5. The encoder writes each value at its valOff.
  6. It computes the CRC-32 (Section 4.5) and writes it last.

8.5. Verification Procedure

For each signature entry, the receiver resolves the verification key (Section 8.7) and verifies the value over TBS with the algorithm the entry names. Ed25519 verification MUST be strict: reject S >= L, reject non-canonical encodings of R and A, reject small-order A, and use the cofactorless equation [S]B = R + [k]A. A receiver MUST reject the artifact if any signature entry fails to verify, including entries that are not required (Section 8.6).

8.6. Signature Requirements and Signer Binding

The type decides whether an artifact must be signed, never FLAG_SIGNED. Each type has a required purpose and a principal field. A conforming artifact of a "MUST"-signed type has at least one signature entry with the required purpose whose signerDID equals the principal field's string. An artifact may also carry counter-signatures (purpose 0x02) from other DIDs, up to the overall limit of four signatures.

Table 10: Signature requirements per type
Type Signed Required purpose Signer MUST be (principal)
REQUEST MUST author requesterDID
CONSENT MUST author patientDID
GRANT MUST author grantorDID
RECEIPT MUST author receiverDID
REVOKE MUST revocation revokerDID
ERROR MAY author reporterDID
ASSET_MANIFEST MUST author ownerDID
METALOG_RECORD MAY author log owner (12.8)
PROVENANCE_COMMITMENT MUST author originatorDID
ANCHOR_RECEIPT MUST anchor-service key authorized in TRUST_BUNDLE
SNAPSHOT_MANIFEST MUST author ownerDID
EMERGENCY_PROFILE MUST author issuerDID
EMERGENCY_ACCESS_RECEIPT MUST responder responderDID
TRUST_BUNDLE MUST bundle-issuer issuerDID
DID_DOCUMENT MUST author see 12.15
  • Allowed purposes: an entry's purpose MUST be either the type's required purpose or counter-signature (0x02). No other purpose may appear.
  • Counter-signatures: a counter-signer's DID MUST differ from the principal's. A counter-signature is an endorsement of the content. It does not give the counter-signer any authority defined by this document.
  • Stripping: an artifact of a MUST-signed type that lacks a valid required signature is rejected (MISSING_SIGNATURE or SIGNER_NOT_AUTHORIZED). Removing signatures and clearing FLAG_SIGNED therefore never yields an acceptable artifact.
  • Optional signatures: if an ERROR or METALOG_RECORD carries any signature, the rules above apply to it in full.

8.7. Key Resolution

Verifying a signature requires a public key bound to (signerDID, keyRef, alg). Receivers resolve keys offline, from these sources only:

  1. did:key [DIDKEY]. The receiver decodes the multibase/multicodec value. Ed25519 (multicodec 0xed) support is REQUIRED. Other key types MAY be supported once multicodec code points for them are registered. If keyRef is present, it MUST equal "#" followed by the method-specific identifier.
  2. TRUST_BUNDLE issuer records (Section 12.14) from a bundle chain that the receiver has verified. Such a record binds a DID, a keyRef, an alg, a public key, a validity interval, and a bitmask of the purposes the key may be used for.
  3. DID_DOCUMENT envelopes (Section 12.15) that the receiver has verified. A verification method qualifies only if it appears in the document's "assertionMethod" relationship (for signing) or "keyAgreement" relationship (for HPKE, Section 10.2), and is encoded as a Multikey with publicKeyMultibase.

When a key comes from a TRUST_BUNDLE, the receiver MUST also check that signedAt falls within the issuer record's validity interval, that the record's purpose bitmask includes the entry's purpose, and that no revocation record in the most recent verified bundle names the key (Section 16.4). A failure is reported as KEY_UNRESOLVED, SIGNER_NOT_AUTHORIZED, or REVOKED.

Table 11: Signature public key encodings
alg Public key encoding Key length
0x01 Ed25519 public key [RFC8032] 32
0x02 ML-DSA-44 public key [FIPS204] 1312

0x03 | Ed25519 key || ML-DSA-44 key, | 1344.

A receiver MAY require hybrid or post-quantum signatures for some types or principals. If an artifact meets every structural rule but not that policy, the receiver reports UNSUPPORTED_ALGORITHM.

8.8. Co-Signing and Later Endorsement

Every signature covers every signature entry, so all signers of one artifact must agree on the complete artifact, the signedAt of each entry included, before anyone signs. A coordinator assembles the unsigned artifact, sends it to each signer, and collects the values.

To endorse an artifact that has already been issued, a party issues a separate PROVENANCE_COMMITMENT (Section 12.9) whose artifactRef is the target's ArtifactID. Appending a signature to an artifact that has already been issued changes its ArtifactID, and is therefore not an endorsement of it.

9. At-Rest Encrypted Blob Frame (VB01)

A VB01 frame stores one encrypted asset payload. A frame is a stand-alone file, or the payload of a METALOG_RECORD. It is not an MDA/1 artifact and has its own magic number.

9.1. Frame Layout

Table 12: VB01 frame header (64 octets)
Off Size Field Type Notes
0 4 magic bytes ASCII "VB01"
4 1 ver u8 Frame version = 1
5 1 aead enum8 (13.25), closed
6 1 bucketExp u8 8..21
7 1 flags u8 Reserved, zero
8 12 nonce bytes Random AEAD nonce
20 12 (rsv) bytes Reserved, zero
32 32 keyCommit hash32 Key commitment

The header is followed by the AEAD ciphertext, including its 16-octet tag, which runs to the end of the frame. The frame's total size MUST be exactly 2^bucketExp octets, with 8 <= bucketExp <= 21. The frame size, and nothing else, reveals the bucket.

9.2. Key Derivation and Key Commitment

Each asset version has a fresh 32-octet Data Encryption Key (DEK) from a CSPRNG. The nonce is 12 octets from a CSPRNG. Frame keys come from HKDF-SHA256 [RFC5869]:

PRK       = HKDF-Extract(salt = nonce, IKM = DEK)
K_enc     = HKDF-Expand(PRK, "MDA1 VB01 enc", 32)
keyCommit = HKDF-Expand(PRK, "MDA1 VB01 commit", 32)

The encryption key is AES-256-GCM [SP800-38D] under K_enc, with the header nonce, and with AAD equal to the 64-octet header exactly as written, keyCommit included. A receiver MUST recompute keyCommit from its DEK and compare it, in constant time, with the header before decrypting (KEY_COMMITMENT_MISMATCH). AES-GCM alone does not commit to its key; the keyCommit check makes the frame key-committing, which defeats key-partitioning and "invisible salamander" attacks when one DEK is wrapped for several recipients.

The per-frame key derivation means that reusing a DEK across frames is safe as long as nonces differ. A DEK MUST NOT be used for more than 2^32 frames.

9.3. Plaintext Framing

plaintext = u32 plaintextLen || payload || zero padding
|plaintext| = 2^bucketExp - 64 - 16

plaintextLen MUST NOT exceed 2^bucketExp - 84. The padding MUST be zero; a receiver MUST check this after decryption. The true length exists only inside the ciphertext. No artifact defined in this document carries it in the clear.

9.4. Size Buckets

An encoder MUST pick a bucketExp large enough to hold the payload. It MAY pick a larger one to hide the length better. How a deployment chooses buckets is policy; picking the smallest bucket that fits is RECOMMENDED unless the deployment has a stronger policy. Bucketing hides lengths only to within a factor of two (Section 20.3).

9.5. Storage Naming

A frame's blobHash is SHA-256 over the entire frame. Implementations that store frames as files SHOULD name each file with the lowercase hexadecimal blobHash and use two levels of directory fan-out taken from the first two octets: "ab/cd/abcd...". Before decrypting, a receiver MUST check that a retrieved frame's SHA-256 equals the blobHash it expects.

10. Key Wrapping for GRANT (HPKE)

A GRANT gives one recipient the DEK of one asset version, wrapped with HPKE [RFC9180] in single-shot mode.

10.1. Suites and Modes

Table 13: HPKE suites
Suite KEM / KDF / AEAD enc Modes pk len
0x01 DHKEM(X25519, HKDF-SHA256) / HKDF-SHA256 / AES-256-GCM (RFC 9180 ids 0x0020/0x0001/0x0002) 32 base, auth 32
0x02 X-Wing [XWING] (X25519 + ML-KEM-768) / HKDF-SHA256 /AES-256-GCM 1120 base only 1216

hpkeMode uses the RFC 9180 mode values: 0x00 for base and 0x02 for auth. Suite 0x02 MUST use mode 0x00. ML-KEM [FIPS203] has no authenticated encapsulation, so a combination of auth mode with suite 0x02 is invalid and rejected (SEMANTIC_VIOLATION). In every mode, the GRANT signature (Section 8.6) is what authenticates the sender. Auth mode only adds a binding between the KEM shared secret and the grantor's key-agreement key.

10.2. Recipient and Sender Keys

granteeKeyRef MUST be present. It names a keyAgreement verification method of granteeDID, resolved as in Section 8.7 from a DID_DOCUMENT or a TRUST_BUNDLE issuer record whose subkind is the matching KEM key type (Section 12.14). In auth mode, grantorKeyRef MUST be present and names a keyAgreement method of grantorDID. In base mode it MUST be absent. Encoders MUST NOT derive key-agreement keys from signing keys.

10.3. Encapsulation and AAD

The encoder assembles the complete GRANT with wrappedDek set to zero, the HPKE enc already in place in the Blob section at encSpan, and crc32 set to zero. Because enc is an output of encapsulation, the encoder first runs SetupBaseS or SetupAuthS to obtain enc and the context, places enc, and then computes:

info = "MDA1 GRANT v1"
aad  = SHA-256( "MDA1GAD\0" || G[0 .. sigValOff) )
wrappedDek = Seal(ctx, aad, DEK)            ; 32 + 16 = 48 octets

G is the artifact with crc32 and wrappedDek zeroed. The AAD thus authenticates the whole GRANT, strings and blob included, except the wrapped key itself. encSpan.len MUST equal the suite's enc length. Signing (Section 8.4) happens after wrappedDek is written.

10.4. Decryption

A recipient MUST complete validation phases A through D (Section 15) on the GRANT, and on the CONSENT and ASSET_MANIFEST it references, before decapsulating. It then runs SetupBaseR or SetupAuthR with enc and the same info, opens wrappedDek with the same aad (DECRYPTION_FAILED on failure), checks the frame's blobHash against the ASSET_MANIFEST, verifies keyCommit, and decrypts the frame.

11. Type Registry

Table 14: Type registry
Code Artifact Body Stride Record Class
0x00 (reserved, invalid) - - - -
0x01 REQUEST 128 48 Generic control
0x02 CONSENT 192 48 Generic control
0x03 GRANT 256 0 - control
0x04 RECEIPT 144 0 - control
0x05 REVOKE 128 0 - control
0x06 ERROR 96 0 - control
0x10 ASSET_MANIFEST 192 48 Generic card
0x11 METALOG_RECORD 112 0 - bundle
0x12 PROVENANCE_COMMITMENT 192 0 - card
0x13 ANCHOR_RECEIPT 160 32 Proof bundle
0x14 SNAPSHOT_MANIFEST 128 0 - bundle
0x20 EMERGENCY_PROFILE 208 48 Generic card
0x21 EMERGENCY_ACCESS_RECEIPT 160 0 - card
0x30 TRUST_BUNDLE 128 96 Trust bundle
0x31 DID_DOCUMENT 128 0 - card
0x80-0xBF Experimental Use any any opaque bundle
0xC0-0xFF Private Use any any opaque bundle

Code points not listed (0x07-0x0F, 0x15-0x1F, 0x22-0x2F, 0x32-0x7F) are unassigned. Receivers MUST reject them (UNKNOWN_TYPE). For experimental and private types, "any" means bodyLen is any multiple of 16 and recStride is any non-zero multiple of 16 when recCount > 0. Section 15.6 gives the processing rules for them. VB01 frames are not MDA/1 artifacts and have no type code.

Experimental codes MUST NOT appear in production deployments. Private codes MUST NOT appear in artifacts exchanged outside the organization that assigned them.

12. Artifact Definitions

Body field offsets are relative to the start of the body, which is absolute offset 64. Each subsection lists the semantic rules that step D2 of the pipeline enforces (Section 15.4). Where a rule needs another artifact (a "dependency") that the receiver does not hold, the receiver MUST NOT treat the artifact as authorizing anything (DEPENDENCY_MISSING). It MAY store the artifact and evaluate it again once the dependency arrives.

12.1. REQUEST (0x01)

Table 15: REQUEST body (128 octets)
Off Size Field Type Notes
0 16 requestId raw16 Request identifier
16 16 sessionId raw16 Session identifier
32 16 nonce raw16 Replay nonce
48 8 issuedAt ts Issuance time
56 8 expiresAt ts Expiry time
64 4 requesterDID str_ref Requester (signer)
68 4 purpose str_ref Purpose of use
72 2 requestedActions u16 Bitmask (13.4)
74 2 (rsv) u16 Reserved
76 4 (rsv) u32 Reserved
80 32 requesterVCHash hash32 Requester VC digest
112 16 (rsv) bytes Reserved
  • recCount >= 1. Every record is a Scope record (reckind 0x05).
  • issuedAt < expiresAt, and expiresAt - issuedAt <= 30 days.
  • requestedActions MUST be non-zero, and its undefined bits MUST be zero.
  • requesterVCHash is the SHA-256 of the octets of the requester's verifiable credential [VC] exactly as presented (for example, the compact serialization of a VC-JWT), or zero if no credential is presented. Validating the credential is outside the scope of this document. If a credential is presented, its digest MUST match.
  • recCount >= 1. Every record is a Scope record. scopeDigest MUST equal the ScopeDigest (Section 7.5) of the records.
  • patientDID and granteeDID MUST be present. delegateDID is OPTIONAL. When present, it names a party that may issue GRANTs under this CONSENT on the patient's behalf.
  • validFrom < validUntil. maxGrantTtlSec >= 1.
  • allowedActions MUST include read (bit 0). Its undefined bits MUST be zero.
  • consentVersion >= 1. supersedesRef is zero if and only if consentVersion = 1. Otherwise it is the ArtifactID of the CONSENT with the same consentId and patientDID and version consentVersion - 1. A receiver holding that earlier version MUST check this link. Among the versions it holds, the highest valid one is in force.
  • requestRef, when non-zero, is the ArtifactID of the REQUEST that led to this CONSENT.

12.3. GRANT (0x03)

Table 17: GRANT body (256 octets)
Off Size Field Type Notes
0 16 grantId raw16 Grant identifier
16 16 sessionId raw16 Session identifier
32 16 nonce raw16 Replay nonce
48 8 issuedAt ts Issuance time
56 8 expiresAt ts Expiry time
64 8 grantSeq u64 Per-pair sequence
72 4 granteeDID str_ref Recipient
76 4 grantorDID str_ref Grantor (signer)
80 4 purpose str_ref Purpose of use
84 2 assetVersion u16 Asset version
86 1 hpkeMode enum8 RFC 9180 mode, closed
87 1 hpkeSuite enum8 Suite (13.6), closed
88 16 assetId raw16 Asset identifier
104 32 consentRef hash32 CONSENT ArtifactID
136 32 manifestRef hash32 ASSET_MANIFEST ArtifactID
168 8 encSpan span HPKE enc in Blob
176 48 wrappedDek bytes HPKE ciphertext of DEK
224 4 granteeKeyRef str_ref Recipient key id
228 4 grantorKeyRef str_ref Sender key id (auth)
232 24 (rsv) bytes Reserved

Given the referenced CONSENT c and ASSET_MANIFEST m, every one of the following MUST hold. c and m are dependencies.

  • c and m have both passed validation and are not revoked.
  • grantorDID equals c.patientDID, or equals c.delegateDID when that field is present.
  • granteeDID equals c.granteeDID, and purpose equals c.purpose.
  • c.validFrom <= issuedAt, expiresAt <= c.validUntil, issuedAt < expiresAt, and expiresAt - issuedAt <= c.maxGrantTtlSec * 1000.
  • assetId and assetVersion equal m.assetId and m.version, and m matches c's Scope records (Section 7.4).
  • hpkeMode, hpkeSuite, encSpan, granteeKeyRef, and grantorKeyRef follow Section 10.

grantSeq orders the GRANTs between one grantor and one grantee. When two valid GRANTs from the same pair cover the same assetId, the one with the higher grantSeq takes precedence.

12.4. RECEIPT (0x04)

Table 18: RECEIPT body (144 octets)
Off Size Field Type Notes
0 16 receiptId raw16 Receipt identifier
16 16 sessionId raw16 Session identifier
32 16 nonce raw16 Replay nonce
48 8 receivedAt ts Delivery time
56 4 receiverDID str_ref Receiver (signer)
60 1 channel enum8 Channel (13.7), open
61 1 outcome enum8 Outcome (13.8), open
62 2 (rsv) u16 Reserved
64 32 grantRef hash32 GRANT ArtifactID
96 32 assetRef hash32 SHA-256 of VB01 file
128 16 (rsv) bytes Reserved
  • grantRef is the ArtifactID of the GRANT being acknowledged (a dependency). receiverDID MUST equal that GRANT's granteeDID.
  • assetRef is the blobHash of the frame received, or zero when outcome is rejected (0x03) or deferred (0x04).

12.5. REVOKE (0x05)

Table 19: REVOKE body (128 octets)
Off Size Field Type Notes
0 16 revokeId raw16 Revocation identifier
16 16 nonce raw16 Replay nonce
32 8 revokedAt ts Time of revocation
40 8 effectiveAt ts Effective time
48 4 revokerDID str_ref Revoker (signer)
52 4 reasonText str_ref Explanation
56 1 targetKind enum8 Kind (13.9), closed
57 1 reasonCode enum8 Reason (13.10), open
58 6 (rsv) bytes Reserved
64 32 targetRef hash32 Target ArtifactID/key
96 32 (rsv) bytes Reserved

targetRef is the ArtifactID of the target artifact. For targetKind key (0x07) it is instead the SHA-256 of the public key encoding (Section 8.7). The revoker must hold authority over the target:

Table 20: Revocation authority
targetKind revokerDID MUST equal
consent (0x01) the CONSENT's patientDID
grant (0x02) the GRANT's grantorDID, or the patientDID of the CONSENT it references
emergency profile the profile's patientDID or issuerDID
(0x03)
DID document (0x04) the document's targetDID
asset manifest (0x05) the manifest's ownerDID
provenance (0x08) the commitment's originatorDID
trust bundle (0x06), not revocable by REVOKE; use TRUST_BUNDLE
key (0x07) revocation records (Section 12.14), unless revokerDID is the key's own DID
  • effectiveAt MAY be earlier than revokedAt, which makes the revocation retroactive (for example, for a lost device). From effectiveAt on, the target is invalid. Artifacts that depend on the target and were signed at or after effectiveAt are invalid too.
  • A revocation is final. Nothing un-revokes a target; a new artifact replaces it. Checking authority needs the target, so the target is a dependency. A receiver that does not hold the target MUST still keep the REVOKE and apply it if the target arrives later.

12.6. ERROR (0x06)

Table 21: ERROR body (96 octets)
Off Size Field Type Notes
0 16 errorId raw16 Error identifier
16 16 sessionId raw16 Session, or 0
32 32 relatesTo hash32 SHA-256 of input octets
64 8 occurredAt ts Detection time
72 2 errorCode u16 Code (13.24), open
74 1 failedStep u8 Pipeline step (15)
75 1 (rsv) u8 Reserved
76 4 detailOffset u32 Byte offset or ~0
80 4 message str_ref Human-readable text
84 4 reporterDID str_ref Reporter
88 8 (rsv) bytes Reserved
  • relatesTo is SHA-256 over the raw octets received. It is not an ArtifactID, because the input may not parse. failedStep encodes the pipeline step (Section 15) as phase * 16 + step, where A = 1, B = 2, C = 3, and D = 4; step B3, for example, is 0x23. detailOffset is the octet offset where the failure was detected, or 0xFFFFFFFF if none applies.
  • message MUST NOT contain personal or health data.
  • An ERROR MUST NOT be sent in response to an ERROR. A receiver MUST NOT change any authorization or stored state on the strength of an unsigned ERROR. It may only display the error, log it, or retry.

12.7. ASSET_MANIFEST (0x10)

Table 22: ASSET_MANIFEST body (192 octets)
Off Size Field Type Notes
0 16 assetId raw16 Asset identifier
16 2 version u16 Starts at 1
18 1 contentType enum8 Type (13.11), open
19 1 bucketExp u8 VB01 bucket exponent
20 4 (rsv) u32 Reserved
24 8 capturedAt ts Acquisition time
32 4 ownerDID str_ref Owner (signer)
36 4 title str_ref Title, OPTIONAL
40 4 source str_ref Origin hint, OPTIONAL
44 4 (rsv) u32 Reserved
48 32 blobHash hash32 SHA-256 of VB01 file
80 32 priorVersionRef hash32 Prior ArtifactID or 0
112 32 provenanceRef hash32 PROVENANCE ArtifactID/0
144 48 (rsv) bytes Reserved
  • Records, if any, are Tag records (reckind 0x06).
  • blobHash is SHA-256 over the asset's VB01 frame. bucketExp MUST equal the frame's bucketExp.
  • version >= 1. priorVersionRef is zero if and only if version = 1.
  • The manifest is signed but not encrypted. title, source, Tag records, and contentType are visible to anyone who holds it. For sensitive assets, encoders SHOULD leave title and source absent, SHOULD use contentType undisclosed (0x00), and SHOULD put descriptive metadata inside the encrypted payload (Section 20.2). The manifest deliberately carries no plaintext length and no plaintext hash.

12.8. METALOG_RECORD (0x11)

Table 23: METALOG_RECORD body (112 octets)
Off Size Field Type Notes
0 8 seq u64 Sequence, genesis = 0
8 2 recordType u16 Payload type code or 0
10 2 flags u16 Reserved in minor 0
12 4 payloadLen u32 MUST equal span len
16 32 prevHash hash32 Previous recordHash
48 32 payloadHash hash32 SHA-256 of payload
80 8 payloadSpan span VB01 frame in Blob
88 8 loggedAt ts Append time
96 16 (rsv) bytes Reserved

The payload is one VB01 frame at payloadSpan, so payloadLen = payloadSpan.len = 2^bucketExp. payloadHash = SHA-256(payload). recordType is the type code of the MDA/1 artifact encrypted in the payload, or 0 if the payload is opaque. The record's chain hash is:

recordHash = SHA-256( "MDA1LOG\0" || prevHash || u64 seq ||
                      u16 recordType || u16 flags ||
                      u32 payloadLen || u64 loggedAt || payloadHash )

The genesis record has seq = 0 and a prevHash of 32 zero octets. Each later record has seq = previous seq + 1 and prevHash = previous recordHash. The chain commits to ciphertext, so anyone can audit it without keys. Integrity is relative to a trusted chain head: one from a verified SNAPSHOT_MANIFEST, or from a final ANCHOR_RECEIPT with valueKind chain-head. A METALOG_RECORD MAY be signed by the log owner, whom deployment policy identifies.

12.9. PROVENANCE_COMMITMENT (0x12)

Table 24: PROVENANCE_COMMITMENT body (192 octets)
Off Size Field Type Notes
0 16 commitmentId raw16 Commitment identifier
16 8 createdAt ts Creation time
24 1 targetType u8 Target type code
25 1 issuerKind enum8 Kind (13.12), open
26 2 (rsv) u16 Reserved
28 4 originatorDID str_ref Originator (signer)
32 4 subjectDID str_ref Subject, OPTIONAL
36 4 displayHint str_ref Display hint, OPTIONAL
40 4 (rsv) u32 Reserved
44 4 (rsv) u32 Reserved
48 32 artifactRef hash32 Target ArtifactID
80 32 originatorVCHash hash32 Originator VC digest
112 32 priorVersionRef hash32 Prior ArtifactID or 0
144 32 consentRef hash32 CONSENT ArtifactID or 0
176 16 (rsv) bytes Reserved
  • artifactRef MUST be non-zero, and targetType MUST be the type code of the artifact it references. A receiver that holds the target MUST check targetType. Provenance for asset content references the content's ASSET_MANIFEST.
  • A PROVENANCE_COMMITMENT also serves as a later, detached endorsement of an artifact (Section 8.8).

12.10. ANCHOR_RECEIPT (0x13)

Table 25: ANCHOR_RECEIPT body (160 octets)
Off Size Field Type Notes
0 16 anchorId raw16 Anchor identifier
16 8 anchoredAt ts Anchoring time
24 1 backend enum8 Ledger (13.13), open
25 1 status enum8 Status (13.14), closed
26 1 valueKind enum8 Kind (13.15), closed
27 1 (rsv) u8 Reserved
28 4 checkpointRef str_ref Log/checkpoint label
32 8 leafIndex u64 RFC 9162 leaf index
40 8 treeSize u64 RFC 9162 tree size
48 32 anchoredValue hash32 Value committed as leaf
80 32 rootHash hash32 RFC 9162 root hash
112 8 txRef span Ledger tx reference
120 8 blockRef span Ledger block reference
128 8 evidenceSpan span Backend evidence
136 24 (rsv) bytes Reserved
Table 26: Proof record (RS 32) (32 octets)
Off Size Field Type Notes
0 32 node hash32 Audit path node

The anchored leaf is the RFC 9162 [RFC9162] Merkle leaf over anchoredValue, the 32-octet value itself:

leafHash = SHA-256( 0x00 || anchoredValue )

Proof records form the RFC 9162 inclusion proof (audit path), in path order from the leaf toward the root. They are exempt from Section 7.1 sorting and may repeat. If status is final (0x02), these MUST hold:

  • leafIndex < treeSize.
  • recCount equals the audit path length for (leafIndex, treeSize).
  • Running the verification algorithm of [RFC9162], Section 2.1.3.2, with leafHash, leafIndex, treeSize, and the proof yields rootHash.

If status is pending (0x01) or failed (0x03), leafIndex, treeSize, and rootHash MUST be zero and recCount MUST be 0. Only a final receipt provides any assurance.

txRef and blockRef, when present, hold ASCII identifiers chosen by the backend (for example, a hexadecimal transaction hash). evidenceSpan holds the backend's evidence. For backend RFC 3161 TSA (0x05) it is REQUIRED and holds a DER-encoded TimeStampToken [RFC3161] whose messageImprint is SHA-256 over rootHash. All three are covered by the signature. The anchor-service signer MUST be authorized for purpose anchor-service by a TRUST_BUNDLE issuer record.

12.11. SNAPSHOT_MANIFEST (0x14)

Table 27: SNAPSHOT_MANIFEST body (128 octets)
Off Size Field Type Notes
0 16 snapshotId raw16 Snapshot identifier
16 8 createdAt ts Snapshot time
24 8 watermarkSeq u64 Highest included seq
32 32 chainHead hash32 recordHash at watermark
64 32 indexHash hash32 Index state digest
96 4 logRecordCount u32 Records retained
100 2 segmentCount u16 Segment file count
102 2 (rsv) u16 Reserved
104 4 ownerDID str_ref Log owner (signer)
108 20 (rsv) bytes Reserved
  • chainHead is the recordHash (Section 12.8) of the record whose seq is watermarkSeq.
  • logRecordCount <= watermarkSeq + 1, since records before a pruning point need not be kept.
  • indexHash is an implementation-defined digest of the local index state. It has meaning only to the implementation that produced it and MUST NOT be used for interoperable decisions.

12.12. EMERGENCY_PROFILE (0x20)

Table 28: EMERGENCY_PROFILE body (208 octets)
Off Size Field Type Notes
0 16 profileId raw16 Profile identifier
16 2 profileVersion u16 Starts at 1
18 1 bloodType enum8 (13.16), open
19 1 issuerKind enum8 (13.12), open
20 1 resuscitation enum8 (13.17), open
21 1 organDonor enum8 (13.18), open
22 2 (rsv) u16 Reserved
24 8 validFrom ts Validity start
32 8 validUntil ts Validity end
40 4 patientDID str_ref Patient
44 4 issuerDID str_ref Issuer (signer)
48 4 displayName str_ref Patient name
52 4 preferredLanguage str_ref BCP 47 tag
56 4 clinicianName str_ref OPTIONAL
60 4 clinicianInstitution str_ref OPTIONAL
64 32 issuerVCHash hash32 Issuer VC digest
96 32 directiveRef hash32 Directive manifest or 0
128 32 anchorReceiptRef hash32 ANCHOR ArtifactID or 0
160 32 priorVersionRef hash32 Prior ArtifactID or 0
192 16 (rsv) bytes Reserved
  • Records are Allergy, Medication, Condition, or Contact records (Section 7.3).
  • patientDID, issuerDID, and displayName MUST be present. When issuerKind is patient (0x01), issuerDID MUST equal patientDID.
  • preferredLanguage, when present, is a BCP 47 language tag [RFC5646].
  • directiveRef, when non-zero, is the ArtifactID of an ASSET_MANIFEST with contentType directive (0x07).
  • profileVersion and priorVersionRef follow the versioning rule in Section 12.7.
  • For safety, a receiver MUST display an unknown value of an open enumeration (bloodType, resuscitation, organDonor, record subkinds) as "unrecognized value". It MUST NOT map such a value to a default or to "unknown".
  • An expired or not-yet-valid profile MAY be displayed in an emergency, but only with a prominent indication of its status (Section 16.2).

A profile is deliberately readable by anyone who holds it. Deployments that need to control who can read it MUST carry the profile content as an encrypted asset (ASSET_MANIFEST plus VB01) with GRANTs, and MUST NOT rely on EMERGENCY_PROFILE for confidentiality.

12.13. EMERGENCY_ACCESS_RECEIPT (0x21)

Table 29: EMERGENCY_ACCESS_RECEIPT body (160 octets)
Off Size Field Type Notes
0 16 receiptId raw16 Receipt identifier
16 16 profileId raw16 Accessed profile id
32 8 accessedAt ts Access time
40 4 responderDID str_ref Responder (signer)
44 4 responderRole str_ref Role, OPTIONAL
48 32 profileRef hash32 Profile ArtifactID
80 32 responderVCHash hash32 Responder VC digest
112 1 channel enum8 (13.7), open
113 1 profileCheck enum8 (13.19), open
114 1 positionSource enum8 (13.20), open
115 1 (rsv) u8 Reserved
116 4 lat i32 Latitude, 1e-7 degree
120 4 lon i32 Longitude, 1e-7 degree
124 2 accuracyM u16 Accuracy, metres
126 2 (rsv) u16 Reserved
128 16 nonce raw16 Replay nonce
144 16 (rsv) bytes Reserved
  • profileRef MUST be the ArtifactID of the profile accessed, and profileId MUST equal that profile's profileId.
  • When positionSource is none (0x00), lat, lon, and accuracyM MUST be zero. Otherwise -900000000 <= lat <= 900000000 and -1800000000 <= lon <= 1800000000.
  • profileCheck records what the responder's device concluded about the profile. The responder asserts it; it is not independent evidence.

A receipt is responder-signed evidence of access, collected after the fact (Section 19.11). The position comes from the responder's device and is not attested.

12.14. TRUST_BUNDLE (0x30)

Table 30: TRUST_BUNDLE body (128 octets)
Off Size Field Type Notes
0 16 bundleId raw16 Bundle identifier
16 8 issuedAt ts Issuance time
24 8 expiresAt ts Expiry time
32 4 bundleVersion u32 Starts at 1
36 4 issuerDID str_ref Bundle issuer (signer)
40 2 issuerCount u16 Issuer records
42 2 revocationCount u16 Revocation records
44 2 checkpointCount u16 Checkpoint records
46 2 minAppVersion u16 Minimum app version
48 32 prevBundleRef hash32 Prior ArtifactID or 0
80 48 (rsv) bytes Reserved
Table 31: Trust record (RS 96) (96 octets)
Off Size Field Type Notes
0 1 reckind enum8 0x01/0x02/0x03, closed
1 1 subkind enum8 Per-kind subtype
2 2 flags u16 Reserved in minor 0
4 4 field1 str_ref Primary string
8 4 field2 str_ref Secondary string
12 4 field3 str_ref Tertiary string
16 8 ts1 ts Valid from / revoked at
24 8 ts2 ts Valid until
32 4 num u32 Mask / reason / height
36 4 (rsv) u32 Reserved
40 32 hashVal hash32 Key hash or ArtifactID
72 8 keySpan span Raw public key in Blob
80 16 (rsv) bytes Reserved

The canonical record order sorts on reckind first, so the records fall into groups by kind. issuerCount, revocationCount, and checkpointCount MUST equal the number of records of kind 0x01, 0x02, and 0x03, and their sum, computed without overflow, MUST equal recCount (COUNT_MISMATCH).

Issuer record (0x01):

  • subkind is the key algorithm (Section 13.22). The values 0x01-0x03 are the signature algorithms of Section 13.2; 0x10 is an X25519 key-agreement key and 0x11 an X-Wing key-agreement key.
  • field1 is the DID (REQUIRED), field2 the keyRef (REQUIRED unless field1 is a did:key), and field3 an OPTIONAL display label.
  • ts1 and ts2 are the key's validity interval. ts2 = 0 means the key is valid until the bundle expires.
  • num is the bitmask of permitted signature purposes, with bit (p - 1) for purpose p. It MUST be 0 for key-agreement keys.
  • keySpan holds the raw public key, whose length depends on the algorithm (Sections 8.7 and 10.1). hashVal = SHA-256 of that key.

Revocation record (0x02):

  • subkind is a targetKind (Section 13.9). hashVal is the revoked ArtifactID, or the revoked key's hash for targetKind key.
  • ts1 is the time the revocation takes effect. num is a reasonCode. field1 is OPTIONAL and names the affected DID. keySpan is absent.

Checkpoint record (0x03):

  • subkind is a backend (Section 13.13). hashVal is a root hash or chain head that the bundle issuer has verified.
  • ts1 is the checkpoint time and num the block height, modulo 2^32. field1 is a log or ledger label; field2 is an OPTIONAL transaction identifier.

Bundle rules:

  • bundleVersion >= 1. prevBundleRef is zero if and only if bundleVersion = 1. Otherwise it is the ArtifactID of the bundle with version bundleVersion - 1.
  • issuedAt < expiresAt.
  • The bundle-issuer signer MUST be either a root key pinned in the receiver's configuration (provisioned out of band) or a key with purpose bundle-issuer in the previous verified bundle. This is how bundle-issuer keys rotate.
  • A receiver MUST NOT accept a bundle whose bundleVersion is lower than or equal to the latest it has verified, unless it is the same bundle (Section 16.4).

12.15. DID_DOCUMENT (0x31)

Table 32: DID_DOCUMENT body (128 octets)
Off Size Field Type Notes
0 16 documentId raw16 Envelope identifier
16 8 updatedAt ts Update time
24 4 version u32 Starts at 1
28 4 targetDID str_ref DID described
32 32 documentHash hash32 SHA-256 of JSON bytes
64 8 jsonSpan span DID document JSON
72 8 (rsv) bytes Reserved
80 32 prevVersionRef hash32 Prior ArtifactID or 0
112 16 (rsv) bytes Reserved
  • jsonSpan MUST be present. It holds the W3C DID document [DID-CORE] as uncompressed UTF-8 JSON, which MUST be no longer than 49152 octets. Its "id" member MUST equal targetDID. documentHash = SHA-256 of those octets.
  • version 1: the document MUST be signed (author) by a key that is already resolvable for targetDID through a did:key or TRUST_BUNDLE source (Section 8.7). A DID document cannot vouch for itself.
  • version n > 1: prevVersionRef MUST be the ArtifactID of version n - 1, and the signing key MUST be an assertionMethod key of version n - 1. This is how keys rotate.
  • updatedAt MUST be greater than the updatedAt of version n - 1.

13. Enumerations

13.1. Policy for Unknown Values

Every enumeration is either closed or open:

  • Closed: a value changes how an artifact must be processed or what it authorizes. A receiver MUST reject an artifact that contains an unknown closed value (UNKNOWN_ENUM, or UNSUPPORTED_ALGORITHM for sigAlg).
  • Open: a value is informational. A receiver MUST accept unknown open values, keep them unchanged, and report them to the application as "unrecognized". It MUST NOT substitute a default.

Values not listed below are unassigned. Bitmask fields (Section 13.4) are closed: in minor version 0, undefined bits MUST be zero.

13.2. sigAlg (closed)

  • 0x01 = Ed25519; 0x02 = ML-DSA-44; 0x03 = Ed25519 + ML-DSA-44 hybrid (Section 8.2).

13.3. sigPurpose (closed)

  • 0x01 = author; 0x02 = counter-signature; 0x03 = responder; 0x04 = anchor-service; 0x05 = revocation; 0x06 = bundle-issuer.

13.4. actions (closed bitmask)

  • Bit 0 (0x0001) = read: decrypt and view.
  • Bit 1 (0x0002) = export: persist or transmit the plaintext outside the MDA/1 store.

13.5. hpkeMode (closed)

  • 0x00 = base; 0x02 = auth. These are the RFC 9180 values (Section 10.1).

13.6. hpkeSuite (closed)

  • 0x01 = DHKEM(X25519, HKDF-SHA256) / HKDF-SHA256 / AES-256-GCM.
  • 0x02 = X-Wing / HKDF-SHA256 / AES-256-GCM.

13.7. channel (open)

  • 0x00 = unspecified; 0x01 = QR code; 0x02 = NFC; 0x03 = BLE; 0x04 = Wi-Fi Direct; 0x05 = relay server; 0x06 = web reader; 0x07 = removable media.

13.8. outcome (open)

  • 0x01 = delivered; 0x02 = decrypted; 0x03 = rejected; 0x04 = deferred.

13.9. targetKind (closed)

  • 0x01 = consent; 0x02 = grant; 0x03 = emergency profile; 0x04 = DID document; 0x05 = asset manifest; 0x06 = trust bundle; 0x07 = key; 0x08 = provenance commitment.

13.10. reasonCode (open)

  • 0x01 = patient request; 0x02 = superseded; 0x03 = credential revoked; 0x04 = device lost; 0x05 = clinical correction; 0x06 = expiry; 0x07 = key compromise.

13.11. contentType (open)

The name in quotes is the string that Scope records use (Section 7.4).

  • 0x00 = "undisclosed"; 0x01 = "lab"; 0x02 = "prescription"; 0x03 = "summary"; 0x04 = "immunization"; 0x05 = "imaging-thumb"; 0x06 = "vitals"; 0x07 = "directive"; 0x08 = "provenance"; 0xFF = "other".

13.12. issuerKind (open)

  • 0x01 = patient; 0x02 = clinician; 0x03 = institution.

13.13. backend (open)

  • 0x01 = Hedera HCS; 0x02 = IOTA; 0x03 = Hyperledger Fabric; 0x04 = Ethereum L2; 0x05 = RFC 3161 TSA.

13.14. anchorStatus (closed)

  • 0x01 = pending; 0x02 = final; 0x03 = failed.

13.15. valueKind (closed)

  • 0x01 = METALOG chain head (a recordHash); 0x02 = ArtifactID.

13.16. bloodType (open)

  • 0x00 = unknown; 0x01 = A+; 0x02 = A-; 0x03 = B+; 0x04 = B-; 0x05 = AB+; 0x06 = AB-; 0x07 = O+; 0x08 = O-.

13.17. resuscitation (open)

  • 0x00 = unknown; 0x01 = full resuscitation; 0x02 = limited; 0x03 = do not resuscitate.

13.18. organDonor (open)

  • 0x00 = unknown; 0x01 = yes; 0x02 = no.

13.19. profileCheck (open)

  • 0x01 = verified; 0x02 = verified, anchor finality pending; 0x03 = unverified; 0x04 = expired; 0x05 = revoked; 0x06 = tampered.

13.20. positionSource (open)

  • 0x00 = none; 0x01 = GNSS; 0x02 = network; 0x03 = manual entry.

13.21. versionOp (closed)

  • 0x01 = exact; 0x02 = at least; 0x03 = latest.

13.22. Record Kinds and Key Algorithms (closed)

Table 33: Permitted record kinds
Type Permitted reckind values
REQUEST, CONSENT 0x05 Scope
ASSET_MANIFEST 0x06 Tag
EMERGENCY_PROFILE 0x01 Allergy, 0x02 Medication, 0x03 Condition, 0x04 Contact
TRUST_BUNDLE 0x01 Issuer, 0x02 Revocation, 0x03 Checkpoint

Record kind values are scoped to the record layout. Generic records and Trust records use separate namespaces.

The subkind of a Trust issuer record is a key algorithm: 0x01, 0x02, 0x03 (Section 13.2), 0x10 = X25519 (32-octet key), or 0x11 = X-Wing (1216-octet key). A Trust revocation record's subkind is a targetKind (Section 13.9), which is closed. A Trust checkpoint record's subkind is a backend (Section 13.13), which is open.

13.23. Generic Record Subkinds (open)

  • Allergy severity: 0x00 = unknown; 0x01 = mild; 0x02 = moderate; 0x03 = severe; 0x04 = life-threatening.
  • Medication route: 0x00 = unknown; 0x01 = oral; 0x02 = intravenous; 0x03 = intramuscular; 0x04 = subcutaneous; 0x05 = topical; 0x06 = inhaled; 0x07 = other.
  • Condition status: 0x00 = unknown; 0x01 = active; 0x02 = recurrence; 0x03 = remission; 0x04 = resolved; 0x05 = inactive.
  • Contact priority: an integer. 0 means unspecified and 1 is the highest priority.
  • Scope (0x05): the subkind is versionOp (Section 13.21), which is closed. Tag (0x06): the subkind MUST be 0.

13.24. errorCode (open)

Table 34: Error codes
Code Name
0x0001 INVALID_CRC32
0x0002 UNKNOWN_VERSION
0x0003 BOUNDS_EXCEEDED
0x0004 OFFSET_MISMATCH
0x0005 STRING_TABLE_INVALID
0x0006 INVALID_SIGNATURE
0x0007 EXPIRED
0x0008 COUNT_MISMATCH
0x0009 UNSUPPORTED_ALGORITHM
0x000A BAD_MAGIC
0x000B LENGTH_MISMATCH
0x000C UNKNOWN_TYPE
0x000D UNKNOWN_CRITICAL_FLAG
0x000E NON_CANONICAL
0x000F INVALID_REFERENCE
0x0010 UNKNOWN_ENUM
0x0011 MISSING_SIGNATURE
0x0012 SIGNER_NOT_AUTHORIZED
0x0013 KEY_UNRESOLVED
0x0014 REVOKED
0x0015 NOT_YET_VALID
0x0016 REPLAY
0x0017 SEMANTIC_VIOLATION
0x0018 DEPENDENCY_MISSING
0x0019 DECRYPTION_FAILED
0x001A KEY_COMMITMENT_MISMATCH

13.25. VB01 aead (closed)

  • 0x01 = AES-256-GCM with the key derivation of Section 9.2.

14. Size Bounds

Receivers MUST enforce these limits using only header fields (step A4), before any input-dependent allocation:

Table 35: Size bounds
Limit control card bundle
totalLen (maximum) 8 KiB 64 KiB 4 MiB
recCount (maximum) 64 512 16384

All classes: sigCount <= 4, strLen <= 65536, strCount <= 16384, blobLen <= 3 MiB, sigValLen <= 9984, string len <= 256, text span len <= 65536, DID JSON <= 49152.

"KiB" is 1024 octets and "MiB" is 1048576 octets. Every bound is inclusive. Control-class bounds leave room for post-quantum material: a GRANT with suite 0x02 and one hybrid signature takes about 4.1 KiB. The bundle class covers METALOG_RECORDs that carry the largest VB01 frame (2 MiB).

15. Validation Pipeline

A conforming receiver MUST run these steps in order and stop at the first failure, reporting the error code given. No body, record, string, or blob value may reach the application unless every step has passed, except as Section 16.2 permits for emergency profiles. The phases are arranged so that phase A reads only the 64-octet header and the CRC, and phases A and B together need only fixed-size scratch memory (Appendix B).

15.1. Phase A: Framing

A1.
Input length >= 64 (BOUNDS_EXCEEDED). magic = "MDA1" (BAD_MAGIC). major = 1 (UNKNOWN_VERSION).
A2.
totalLen = input length (LENGTH_MISMATCH). totalLen <= 4 MiB and totalLen mod 16 = 0 (BOUNDS_EXCEEDED).
A3.
type is registered, or lies in the Experimental or Private Use range (UNKNOWN_TYPE). Determine the class (Section 11). A production receiver MUST reject Experimental types unless its configuration explicitly allows them.
A4.
Class and global bounds (Section 14) on totalLen, recCount, sigCount, strCount, strLen, blobLen, and sigValLen (BOUNDS_EXCEEDED).
A5.
No unknown critical flag bit (UNKNOWN_CRITICAL_FLAG). FLAG_SIGNED = (sigCount > 0), and header reserved fields and non-critical flag bits are zero unless Section 17 permits otherwise (NON_CANONICAL).
A6.
Topology (Section 4.4), with 64-bit arithmetic: bodyLen, recStride, sigStride, and recCount = 0 for stride-0 types (COUNT_MISMATCH); every offset equality, every length multiple, and totalLen = sigValOff + sigValLen (OFFSET_MISMATCH).
A7.
The CRC-32 matches (INVALID_CRC32).

15.2. Phase B: Structure

B1.
Walk the string table: exactly strCount entries, each lying entirely within the table, 1 <= len <= 256, well-formed UTF-8 with no U+0000, a zero pad byte after odd lengths, strictly ascending order, and fewer than 16 zero octets at the end (STRING_TABLE_INVALID or NON_CANONICAL). Record the set of entry starts.
B2.
Records: reckind is permitted for the type, and record subkinds that are closed are known (UNKNOWN_ENUM); reserved fields and flags are zero, and unused fields are zero or absent (NON_CANONICAL); records are in canonical order, except Proof records (NON_CANONICAL). For TRUST_BUNDLE, check the per-kind counts (COUNT_MISMATCH).
B3.
Signature entries: alg is known (UNSUPPORTED_ALGORITHM); purpose is known (UNKNOWN_ENUM) and permitted for the type (SIGNER_NOT_AUTHORIZED); signerDID is present (INVALID_REFERENCE); reserved fields are zero, valLen matches alg, valOff is at its canonical position, value padding is zero, and entries are strictly ordered (NON_CANONICAL).
B4.
Every str_ref in the body, records, and signature entries is absent or one of the entry starts from B1 (INVALID_REFERENCE). Every entry is referenced at least once (NON_CANONICAL).
B5.
Every present span follows the canonical blob layout of Section 6.2 and stays within the Blob section, and gap and tail octets are zero (INVALID_REFERENCE or NON_CANONICAL).
B6.
Body: reserved fields are zero (NON_CANONICAL); closed enumerations and bitmasks are valid (UNKNOWN_ENUM or NON_CANONICAL); every field the type marks as required is present (SEMANTIC_VIOLATION).

15.3. Phase C: Cryptographic

C1.
Compute the ArtifactID (Section 8.3).
C2.
If the type MUST be signed, an entry with the required purpose is present (MISSING_SIGNATURE).
C3.
Resolve every signature entry's key (Section 8.7), checking validity, purpose permission, revocation, and the local algorithm policy (KEY_UNRESOLVED, SIGNER_NOT_AUTHORIZED, REVOKED, UNSUPPORTED_ALGORITHM).
C4.
Verify every signature (INVALID_SIGNATURE).
C5.
Signer binding: an entry with the required purpose has signerDID equal to the principal field (Section 8.6), and counter-signers differ from the principal (SIGNER_NOT_AUTHORIZED). ANCHOR_RECEIPT has no principal field; its anchor-service signer is bound through the TRUST_BUNDLE purpose permission checked in C3. A signed METALOG_RECORD is bound to the log owner by deployment policy.

15.4. Phase D: Semantic

D1.
Time windows (Section 16.2) (NOT_YET_VALID, EXPIRED).
D2.
The type-specific rules of Section 12 (SEMANTIC_VIOLATION).
D3.
Dependencies and revocation: referenced artifacts are present and valid where Section 12 requires them, and the artifact itself has not been revoked (DEPENDENCY_MISSING, REVOKED).
D4.
Replay (Section 16.3) (REPLAY).

15.5. Error Reporting

A receiver that sends an error back to the originator does so with an ERROR artifact (Section 12.6), filling in errorCode, failedStep, and detailOffset. Receivers MAY coarsen what they report, for example sending only "rejected", so as not to give an attacker an oracle (Section 19.10).

15.6. Experimental and Private Types

For an experimental or private type, steps A1-A7, B1, B3, C1, and C4 apply. A receiver cannot locate the str_ref and span fields in an opaque body, so B4 is limited to signerDID and keyRef, and the rule against orphan entries and step B5 are skipped. A receiver that does not implement the type MUST NOT expose body fields to the application. It MUST preserve the octets exactly if it stores or forwards the artifact. A receiver that does implement the type applies its full rules.

16. Time, Freshness, and Replay

16.1. Clock Model

An offline device's clock may be wrong. A receiver keeps a trusted time floor F: the highest issuedAt of any TRUST_BUNDLE it has verified, and the highest anchoredAt of any final ANCHOR_RECEIPT it has verified. It uses now = max(device clock, F). Timestamps from other signers never raise F. The skew allowance is a policy parameter: 5 minutes by default, and at most 24 hours. Receivers MUST reject any signedAt later than now + skew (NOT_YET_VALID).

16.2. Validity Windows

An interval [start, end] is satisfied if start <= now + skew and either end = 0 (where the field permits that) or now - skew <= end. The intervals are: issuedAt..expiresAt for REQUEST, GRANT, and TRUST_BUNDLE; validFrom..validUntil for CONSENT and EMERGENCY_PROFILE; and, for keys from a TRUST_BUNDLE, the issuer record's ts1..ts2.

An EMERGENCY_PROFILE that fails D1 MAY still be shown to a responder, with profileCheck expired (0x04) and a prominent warning. It MUST NOT be presented as current, and it MUST NOT be used for any authorization decision.

16.3. Replay Protection

REQUEST, GRANT, RECEIPT, REVOKE, and EMERGENCY_ACCESS_RECEIPT carry a nonce. A receiver MUST remember (type, principal, nonce, ArtifactID) for every artifact of these types it accepts. For REQUEST and GRANT it keeps the entry until expiresAt + skew; for the other types, for at least 30 days. Receiving the same nonce again with the same ArtifactID is an idempotent redelivery: no new action is taken, and no error is raised. Receiving the same nonce with a different ArtifactID MUST be rejected (REPLAY). raw16 nonces make an accidental collision negligible.

16.4. Revocation Freshness

Offline receivers learn of revocations only from REVOKE artifacts and TRUST_BUNDLE revocation records they have received. A receiver MUST NOT resolve keys from a TRUST_BUNDLE that has expired (expiresAt + skew < now). Deployment policy MAY allow a "stale" mode for break-glass display only. In that mode the stale status MUST be shown, and the artifacts accepted MUST NOT authorize decryption or export. Bundles are accepted only in increasing bundleVersion order along the prevBundleRef chain, so a stale bundle cannot be replayed to resurrect a revoked key.

17. Versioning and Extensibility

18. Conformance

18.1. Encoders

An encoder conforms if every artifact it emits:

  • E1: satisfies every rule in Sections 4 to 12 and every bound in Section 14;
  • E2: uses NFC for every string and a CSPRNG for every raw16, DEK, and nonce;
  • E3: re-encodes to the same octets in [0, sigValOff) when decoded and encoded again;
  • E4: reproduces the vectors of Appendix A exactly.

18.2. Receivers

A receiver conforms if it:

  • R1: implements every step of Section 15 in order, with the error codes given;
  • R2: never reads outside [0, input length) and never allocates memory in proportion to the input before step A4 completes;
  • R3: accepts the vectors of Appendix A and rejects their negative variants (Appendix A.4);
  • R4: preserves unknown open-enumeration values and unknown experimental or private artifacts octet for octet;
  • R5: survives at least 10^6 mutated artifacts derived from the Appendix A vectors, run under memory-safety instrumentation, without a crash, a hang, an out-of-bounds access, or a false acceptance of an artifact that fails any rule;
  • R6: implements Ed25519 signing and verification and suite 0x01. Implementing ML-DSA-44, the hybrid algorithm, and suite 0x02 is RECOMMENDED.

19. Security Considerations

19.1. Parser Safety

Every limit is checked from header fields before anything is allocated (A4). The topology is checked with arithmetic that cannot wrap (A6). totalLen must equal the octets actually received (A2), so no step can read past the input. Each of phases A and B is one linear pass. Strings and spans are checked against bitmaps of fixed size (Appendix B), and there is no recursion. Taken together, a malformed artifact costs at most O(totalLen) work and a constant amount of memory.

19.2. CRC Is Not Integrity

The CRC-32 only screens out accidental corruption cheaply. An attacker can recompute it at will. All protection against deliberate modification comes from the signatures (Section 8). Types that MAY be unsigned (ERROR, METALOG_RECORD) have no integrity protection beyond what Sections 12.6 and 12.8 provide.

19.3. Signature Coverage and Stripping

A signature covers the ArtifactID, and the ArtifactID covers every octet except the signature values and the CRC field. Signature metadata (purpose, algorithm, signedAt, key reference, and value placement), the string table, and the Blob section are therefore all authenticated. Each type has its own requirement for which signatures must be present (Section 8.6), so removing signatures and clearing FLAG_SIGNED produces an artifact that is rejected. Appendix A.4 includes vectors for both attacks.

19.4. Signer Binding and Key Resolution

A valid signature proves nothing unless the signer is entitled to make the statement. Section 8.6 binds each type's required signature to its principal field, and Section 12 binds authority across artifacts: who may grant under a consent, and who may revoke what. Key resolution is offline, and it comes from sources the receiver has authenticated: self-certifying did:key identifiers, a chain of trust bundles rooted in pinned keys, and DID documents bootstrapped from those. A DID document cannot vouch for itself (Section 12.15). How the root keys are provisioned is the deployment's main trust decision.

19.5. Post-Quantum and Hybrid Signatures

A hybrid signature (alg 0x03) is valid only if both components verify. Each component signs the same TBS, and the TBS commits to alg through the ArtifactID. Rewriting alg to remove the post-quantum component therefore invalidates the signature. Receivers can require hybrid signatures as a matter of policy (Section 8.7). ML-DSA-44 targets NIST security category 2, while ML-KEM-768 in X-Wing targets category 3. Deployments that need category 3 signatures need an ML-DSA-65 code point, which a future document can define.

19.6. Canonical Encoding and Identity

Receivers reject every non-canonical encoding. That covers non-zero reserved or padding octets, unsorted or orphaned strings, misordered records, signature entries or blob items, and trailing octets. An artifact therefore has exactly one ArtifactID, and references between artifacts cannot be broken by re-encoding. Strict Ed25519 verification (Section 8.5) makes signature values non-malleable, and in any case signature values are not part of the ArtifactID. NFC is enforced only on the encoder side. A non-NFC string encodes differently, so it gives a different ArtifactID, and it carries the signer's signature over exactly those octets. It is a different signed statement, not a malleable version of an existing one. Applications that compare strings across artifacts SHOULD apply NFC when they compare.

19.7. Key Wrapping and Content Encryption

The HPKE AAD (Section 10.3) authenticates the whole GRANT. VB01 derives a separate key for each frame and carries a key commitment, which makes AES-GCM key-committing and defeats partitioning-oracle attacks. It also tolerates DEK reuse across frames. DEKs and nonces MUST come from a CSPRNG. Auth mode is not defined for the post-quantum suite. Sender authentication always comes from the GRANT signature, so a recipient MUST NOT decapsulate before the GRANT has passed phases A through D.

19.8. Identifiers, Nonces, and Replay

Every identifier and nonce is 128 random bits, so accidental collisions are negligible; shorter values, such as 32 bits, would collide after about 2^16 values. Section 16.3 defines replay caching; idempotent redelivery is distinguished from replay by the ArtifactID.

19.9. Time and Revocation

Offline clocks can be wrong, and revocation information reaches offline devices late. The trusted time floor (Section 16.1) keeps a device from being rolled back to before trust material it has already seen. Monotonic bundle versions keep a revoked key from coming back. Neither mechanism can reveal a revocation the device has not yet received. Deployments SHOULD keep TRUST_BUNDLE lifetimes short, matched to how often their devices synchronize.

19.10. Denial of Service and Oracles

Verifying signatures is the most expensive step. It happens only after every structural check has passed, and at most four signatures are verified per artifact. Post-quantum verification costs more than Ed25519 but stays well within mobile-class budgets. Detailed error codes are useful for debugging, but they can act as a validation oracle. Receivers facing untrusted peers MAY report only a generic rejection (Section 15.5).

19.11. Break-Glass Access

EMERGENCY_PROFILE is readable without keys by design, because an unconscious patient cannot authorize access. EMERGENCY_ACCESS_RECEIPT is responder-signed evidence collected after the fact. It deters and attributes misuse; it does not prevent it. Nothing in this document can force a responder to issue a receipt. Its position comes from the responder's device, which can spoof it, and its profileCheck is the responder's own assertion. Deployments that need preventive control MUST encrypt the profile content (Section 12.12).

19.12. Ledger Anchoring

An ANCHOR_RECEIPT is only as trustworthy as its anchor-service key and the receiver's ability to verify the inclusion proof. Receivers MUST verify the RFC 9162 proof against rootHash, and MUST obtain rootHash or a later checkpoint independently, from a TRUST_BUNDLE checkpoint record, before relying on finality. Pending and failed receipts provide no assurance.

19.13. Side Channels

Comparisons of key commitments, MACs, and HPKE outputs MUST run in constant time. Implementations of Ed25519, ML-DSA, and X-Wing SHOULD resist timing and fault attacks. The hedged ML-DSA variant is RECOMMENDED where fault injection is a concern.

20. Privacy Considerations

20.1. Plaintext Artifacts

Control artifacts, manifests, provenance commitments, and emergency profiles are signed but not encrypted. They can reveal DIDs, display names, purposes of use, and the existence of relationships. Encoders SHOULD leave out every OPTIONAL field that is not needed. Transports SHOULD provide confidentiality where it is available.

20.2. Asset Metadata

ASSET_MANIFEST deliberately leaves out the plaintext length and the plaintext hash. A plaintext hash would let anyone holding a manifest confirm a guess at low-entropy documents. contentType, title, source, and tags are visible to anyone holding the manifest, and Section 12.7 recommends minimizing them.

20.3. Limits of Length Hiding

VB01 hides lengths to within a power of two. An observer can still see the bucket size, how many frames exist and when, the access pattern, and the METALOG recordType of each entry. Deployments needing more than that should pad to larger buckets, add cover frames, and set recordType to 0.

20.4. Identifier Correlation

DIDs and raw16 identifiers can link activity across contexts. Patients SHOULD use a separate DID for each relationship (pairwise DIDs) where the DID method supports it. Identifiers MUST be random (Section 3).

20.5. Location Data

EMERGENCY_ACCESS_RECEIPT can carry precise coordinates of a patient's location. Encoders SHOULD reduce precision to what accountability needs, and SHOULD set positionSource none when no position is required.

21. IANA Considerations

21.1. Media Types

IANA is requested to register two media types in the "Media Types" registry [RFC6838].

Type name:
application
Subtype name:
mda1-artifact
Required parameters:
N/A
Optional parameters:
N/A
Encoding considerations:
binary
Security considerations:
See Section 19 of this document.
Interoperability considerations:
See Section 18 of this document.
Published specification:
This document
Applications that use this media type:
Offline health data exchange and storage.
Fragment identifier considerations:
N/A
Additional information:

Magic number(s): 4D 44 41 31 at offset 0

File extension(s): .mda1

Macintosh file type code(s): N/A

Person and email address to contact for further information:
Septimus Johnson <septimus.johnson@simplenet-solutions.de>
Intended usage:
COMMON
Restrictions on usage:
None
Author:
Septimus Johnson
Change controller:
IETF

The second registration, application/mda1-vb01, uses the same template, except: Subtype name: mda1-vb01; Magic number(s): 56 42 30 31 at offset 0; File extension(s): .vb01; Security considerations: Section 9, Section 19.7, and Section 20.3 of this document.

21.2. MDA/1 Registries

IANA is requested to create a "Flat Data Artifact Format (MDA/1)" registry group with the following registries, using the policies of [RFC8126]. Their initial contents are the values in Sections 4.3, 11, and 13.

Table 36: MDA/1 registries
Registry Registration policy
Artifact Types 0x01-0x7F Specification Required; 0x80-0xBF Experimental Use; 0xC0-0xFF Private Use; 0x00 reserved
Header Flags Standards Action
Signature Algorithms Specification Required
Signature Purposes Standards Action
Key Algorithms (13.22) Specification Required
HPKE Suites Specification Required
Record Kinds Specification Required (per layout)
Closed enumerations Specification Required
Open enumerations Expert Review
Error Codes Expert Review
VB01 AEAD Identifiers Specification Required

Designated experts SHOULD check that a new closed value comes with complete processing rules, and that a new artifact type meets the container rules and the alignment and canonicalization requirements of this document.

22. References

22.1. Normative References

[DID-CORE]
Sporny, M., Longley, D., Sabadello, M., Reed, D., Steele, O., and C. Allen, "Decentralized Identifiers (DIDs) v1.0", W3C, W3C REC did-core, , <https://www.w3.org/TR/did-core/>.
[DIDKEY]
Longley, D., Zagidulin, D., and M. Sporny, "The did:key Method", W3C Credentials Community Group, <https://w3c-ccg.github.io/did-method-key/>.
[FIPS180-4]
NIST, "Secure Hash Standard (SHS)", FIPS PUB 180-4, DOI 10.6028/NIST.FIPS.180-4, , <https://doi.org/10.6028/NIST.FIPS.180-4>.
[FIPS203]
NIST, "Module-Lattice-Based Key-Encapsulation Mechanism Standard", FIPS PUB 203, DOI 10.6028/NIST.FIPS.203, , <https://doi.org/10.6028/NIST.FIPS.203>.
[FIPS204]
NIST, "Module-Lattice-Based Digital Signature Standard", FIPS PUB 204, DOI 10.6028/NIST.FIPS.204, , <https://doi.org/10.6028/NIST.FIPS.204>.
[ISO13239]
ISO/IEC, "Information technology - Telecommunications and information exchange between systems - High-level data link control (HDLC) procedures", ISO/IEC 13239:2002, .
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119, DOI 10.17487/RFC2119, BCP 14, , <https://www.rfc-editor.org/info/rfc2119>.
[RFC3161]
Adams, C., Cain, P., Pinkas, D., and R. Zuccherato, "Internet X.509 Public Key Infrastructure Time-Stamp Protocol (TSP)", RFC 3161, DOI 10.17487/RFC3161, , <https://www.rfc-editor.org/info/rfc3161>.
[RFC3629]
Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 3629, DOI 10.17487/RFC3629, STD 63, , <https://www.rfc-editor.org/info/rfc3629>.
[RFC5646]
Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying Languages", RFC 5646, DOI 10.17487/RFC5646, BCP 47, , <https://www.rfc-editor.org/info/rfc5646>.
[RFC5869]
Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand Key Derivation Function (HKDF)", RFC 5869, DOI 10.17487/RFC5869, , <https://www.rfc-editor.org/info/rfc5869>.
[RFC6838]
Freed, N., Klensin, J., and T. Hansen, "Media Type Specifications and Registration Procedures", RFC 6838, DOI 10.17487/RFC6838, BCP 13, , <https://www.rfc-editor.org/info/rfc6838>.
[RFC8032]
Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital Signature Algorithm (EdDSA)", RFC 8032, DOI 10.17487/RFC8032, , <https://www.rfc-editor.org/info/rfc8032>.
[RFC8126]
Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", RFC 8126, DOI 10.17487/RFC8126, BCP 26, , <https://www.rfc-editor.org/info/rfc8126>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", RFC 8174, DOI 10.17487/RFC8174, BCP 14, , <https://www.rfc-editor.org/info/rfc8174>.
[RFC9162]
Laurie, B., Messeri, E., and R. Stradling, "Certificate Transparency Version 2.0", RFC 9162, DOI 10.17487/RFC9162, , <https://www.rfc-editor.org/info/rfc9162>.
[RFC9180]
Barnes, R., Bhargavan, K., Lipp, B., and C. Wood, "Hybrid Public Key Encryption", RFC 9180, DOI 10.17487/RFC9180, , <https://www.rfc-editor.org/info/rfc9180>.
[SP800-38D]
Dworkin, M., "Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC", NIST SP 800-38D, DOI 10.6028/NIST.SP.800-38D, , <https://doi.org/10.6028/NIST.SP.800-38D>.
[UAX15]
Unicode Consortium, "Unicode Normalization Forms", Unicode Standard Annex 15, <https://www.unicode.org/reports/tr15/>.
[XWING]
Connolly, D., Schwabe, P., and B. Westerbaan, "X-Wing: general-purpose hybrid post-quantum KEM", Work in Progress, Internet-Draft, draft-connolly-cfrg-xwing-kem, <https://datatracker.ietf.org/doc/draft-connolly-cfrg-xwing-kem/>.

22.2. Informative References

[FHIR]
HL7, "Fast Healthcare Interoperability Resources (FHIR) Release 4", <https://hl7.org/fhir/R4/>.
[IPS]
HL7, "International Patient Summary Implementation Guide", <https://hl7.org/fhir/uv/ips/>.
[VC]
Sporny, M., "Verifiable Credentials Data Model v2.0", W3C, <https://www.w3.org/TR/vc-data-model-2.0/>.

Appendix A. Test Vectors

All values are hexadecimal unless noted otherwise. The vectors were produced by an independent reference encoder, and the reference validator accepts them.

A.1. Keys and Identifiers

The signing key is [RFC8032], Section 7.1 TEST 1:

secret seed: 9d61b19deffd5a60ba844af492ec2cc4
             4449c5697b326919703bac031cae7f60
public key:  d75a980182b10ab7d54bfed3c964073a
             0ee172f3daa62325af021a68f707511a
did:key:     did:key:z6MktwupdmLXVVqTzCw4i46r4uGyosGXRnR3XjN4Zq7oMMsw
T0 = 1795305600000 (2026-11-22T00:00:00Z, decimal)
requestId = 000102...0f; sessionId = 101112...1f;
nonce     = 202122...2f

A.2. ScopeDigest

The single Scope record is subkind = 0x03 (latest), field1 absent, field2 = "lab", field3 = "hematology", and ts1 = ts2 = num = 0:

ScopeDigest = 6071d110d4bc57295cdef4589f6aa9ae
              a523bebf913546720c534acc392a5a10

A.3. Signed REQUEST

A REQUEST with that Scope record and one Ed25519 author signature. requesterDID is the did:key above, purpose = "treatment", requestedActions = 0x0001 (read), issuedAt = T0, expiresAt = T0 + 86400000, signedAt = T0, and keyRef absent.

totalLen  = 432   bodyLen   = 128   recCount  = 1
recStride = 48    sigCount  = 1     sigStride = 32
strCount  = 4     strOff    = 272   strLen    = 96
blobOff   = 368   blobLen   = 0     sigValOff = 368
sigValLen = 64
strings (in table order): the did:key (56 octets), "hematology",
"lab", "treatment"
0000: 4d 44 41 31 01 00 01 00 01 00 04 00 b0 01 00 00
0010: 80 00 00 00 01 00 30 00 01 00 20 00 10 01 00 00
0020: 60 00 00 00 70 01 00 00 00 00 00 00 70 01 00 00
0030: 40 00 00 00 37 87 dc 29 00 00 00 00 00 00 00 00
0040: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
0050: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
0060: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
0070: 00 74 8d 00 a2 01 00 00 00 d0 b3 05 a2 01 00 00
0080: 10 01 00 00 5c 01 00 00 01 00 00 00 00 00 00 00
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00c0: 05 03 00 00 ff ff ff ff 56 01 00 00 4a 01 00 00
00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00f0: 10 01 00 00 01 01 00 00 00 74 8d 00 a2 01 00 00
0100: ff ff ff ff 70 01 00 00 40 00 00 00 00 00 00 00
0110: 38 00 64 69 64 3a 6b 65 79 3a 7a 36 4d 6b 74 77
0120: 75 70 64 6d 4c 58 56 56 71 54 7a 43 77 34 69 34
0130: 36 72 34 75 47 79 6f 73 47 58 52 6e 52 33 58 6a
0140: 4e 34 5a 71 37 6f 4d 4d 73 77 0a 00 68 65 6d 61
0150: 74 6f 6c 6f 67 79 03 00 6c 61 62 00 09 00 74 72
0160: 65 61 74 6d 65 6e 74 00 00 00 00 00 00 00 00 00
0170: fd 97 2d c0 67 17 fd 1d 98 5a 03 c4 84 8a 3b 96
0180: ac 82 2b e0 da ac d0 89 d1 5a 60 18 c8 7d 07 61
0190: b7 7d 73 3a 63 89 ec 8f b7 c2 7b b2 42 64 ee 6d
01a0: 63 0d 2f 14 0f 5d 1b b4 66 7d df 1a 95 77 a2 09
ArtifactID = 1b62d25af0d87deeed4ca1a6880f21b5
             07a55fe9c1a3dc036fb8f28bd7ca5c00
TBS        = 4d44413153494700 || ArtifactID
Signature  = fd972dc06717fd1d985a03c4848a3b96
             ac822be0daacd089d15a6018c87d0761
             b77d733a6389ec8fb7c27bb24264ee6d
             630d2f140f5d1bb4667ddf1a9577a209
crc32      = 0x29dc8737

A.4. Negative Variants

Each variant below is derived from A.3. Where noted, the CRC is recomputed after the change. A conforming receiver MUST reject every one, with the code shown.

Table 37: Negative test variants
Variant Expected rejection
16 zero octets appended LENGTH_MISMATCH
last 16 octets removed LENGTH_MISMATCH
totalLen field + 16 LENGTH_MISMATCH
type = 0x07 (CRC recomputed) UNKNOWN_TYPE
FLAG_SIGNED cleared (CRC recomputed) NON_CANONICAL
re-encoded with no signature MISSING_SIGNATURE
purpose author -> counter-signature (CRC) MISSING_SIGNATURE
signedAt + 1 (CRC recomputed) INVALID_SIGNATURE
same content signed by another did:key SIGNER_NOT_AUTHORIZED
any single-bit flip rejected (INVALID_CRC32 or earlier)
any single-octet change outside crc32, rejected (no octet
CRC recomputed is malleable)

A.5. VB01 Frame

The frame uses bucketExp = 8 (a 256-octet frame). The plaintext is the ASCII string "MDA1 VB01 test vector" followed by a line feed (22 octets).

DEK       = 404142434445464748494a4b4c4d4e4f
            505152535455565758595a5b5c5d5e5f
nonce     = a0a1a2a3a4a5a6a7a8a9aaab
K_enc     = 1ac919a7a01e269cb7c65f8bc6c9f561
            8ac8f44822e54e41cacbcbb814b1fb49
keyCommit = 37c974687a922fb022000b241931a04d
            1a4a01070bb0bfb7f3d7bec38ced9e5b
0000: 56 42 30 31 01 01 08 00 a0 a1 a2 a3 a4 a5 a6 a7
0010: a8 a9 aa ab 00 00 00 00 00 00 00 00 00 00 00 00
0020: 37 c9 74 68 7a 92 2f b0 22 00 0b 24 19 31 a0 4d
0030: 1a 4a 01 07 0b b0 bf b7 f3 d7 be c3 8c ed 9e 5b
0040: af 50 19 d5 e1 d3 aa b0 49 08 87 46 02 eb ed bb
0050: 7d 48 8f b8 b9 45 7e 55 cd 1c 87 1b f1 83 5f 9f
0060: f0 2c 07 95 fc 57 1d b2 72 32 9f 88 90 07 e7 42
0070: 6f 90 98 d6 42 7a 8a 37 66 d0 d9 18 32 50 66 01
0080: bc 4d 5b b9 c4 56 65 2e bd 1e 79 a6 c9 4e 9c f7
0090: f9 29 66 a4 29 7a 0e b0 4e 6f 88 10 90 a1 6a 39
00a0: f9 12 b7 65 40 56 63 61 8e 59 3e 7a b9 92 73 50
00b0: 37 2b ec ce c0 91 f1 94 71 88 5a 10 89 51 5f ec
00c0: 09 71 dc 67 98 6a a8 64 48 e6 e8 d7 ea ba 1b 22
00d0: 61 d4 40 4e c3 3e fc ce d3 4c ad 48 57 cc 82 9f
00e0: a7 6e ff 4f fc 3e 9b ce d4 c5 1c 8b 2e 2d 44 dd
00f0: a7 35 ec 09 d3 ae 28 7b 17 13 9f 70 62 d8 7b f0
blobHash  = 54fbe6ae5ad5b159689bb3defbd11de0
            2027d81d3471ddf8d2926c6be5eb980d

Opening the frame with any other DEK MUST fail at the keyCommit check (KEY_COMMITMENT_MISMATCH) before AES-GCM is run.

Appendix B. Implementation Guidance for C and C++ (Informative)

A topology check for phase A could look like this:

<CODE BEGINS>
static inline uint32_t ld32(const uint8_t *p) {
    uint32_t v; memcpy(&v, p, 4); return le32toh(v);
}
static inline uint16_t ld16(const uint8_t *p) {
    uint16_t v; memcpy(&v, p, 2); return le16toh(v);
}

mda_err mda_frame(const uint8_t *b, size_t n, const mda_type **t)
{
    if (n < 64)                       return MDA_BOUNDS_EXCEEDED;
    if (memcmp(b, "MDA1", 4) != 0)    return MDA_BAD_MAGIC;
    if (b[4] != 1)                    return MDA_UNKNOWN_VERSION;
    uint64_t total = ld32(b + 12);
    if (total != n)                   return MDA_LENGTH_MISMATCH;
    if (total > (4u << 20) || (total & 15))
                                      return MDA_BOUNDS_EXCEEDED;
    if (!(*t = mda_type_lookup(b[6]))) return MDA_UNKNOWN_TYPE;
    /* A4, A5 omitted for brevity */
    uint64_t body = ld32(b + 16);
    uint64_t rc = ld16(b + 20), rs = ld16(b + 22);
    uint64_t sc = ld16(b + 24), ss = ld16(b + 26);
    if (body != (*t)->body_len ||
        rs != (rc ? (*t)->stride : 0) || ss != (sc ? 32 : 0) ||
        (rc && (*t)->stride == 0))    return MDA_COUNT_MISMATCH;
    uint64_t str = 64 + body + rc * rs + sc * ss;
    uint64_t sl = ld32(b + 32), bl = ld32(b + 40);
    uint64_t vl = ld32(b + 48);
    if (ld32(b + 28) != str || ld32(b + 36) != str + sl ||
        ld32(b + 44) != str + sl + bl ||
        ((sl | bl | vl) & 15) || str + sl + bl + vl != total)
                                      return MDA_OFFSET_MISMATCH;
    return mda_crc_ok(b, n) ? MDA_OK : MDA_INVALID_CRC32;
}

<CODE ENDS>

Author's Address

Septimus Johnson
TTI-Simplenet Software Solutions