<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     category="exp"
     docName="draft-vso-cpp-core-00"
     ipr="trust200902"
     submissionType="independent"
     xml:lang="en"
     version="3">

  <front>
    <title abbrev="CPP Core">Content Provenance Profile (CPP) Core</title>
    <seriesInfo name="Internet-Draft" value="draft-vso-cpp-core-00"/>

    <author fullname="Tokachi Kamimura" initials="T." surname="Kamimura">
      <organization>VeritasChain Co., Ltd.</organization>
      <address>
        <email>tokachi@veritaschain.org</email>
      </address>
    </author>

    <date year="2026" month="January"/>

    <area>Security</area>
    <workgroup>Independent Submission</workgroup>

    <keyword>provenance</keyword>
    <keyword>timestamp</keyword>
    <keyword>merkle tree</keyword>
    <keyword>RFC 3161</keyword>
    <keyword>media authenticity</keyword>

    <abstract>
      <t>The Content Provenance Profile (CPP) is an open specification for
      cryptographically verifiable media capture provenance. This document
      defines the core data model, hashing conventions, Merkle tree
      construction rules, RFC 3161 Time-Stamp Authority (TSA) anchoring
      protocol, and offline verification procedures for CPP.</t>

      <t>CPP enables capture devices to produce tamper-evident provenance
      records that bind media content to external timestamps via trusted
      third parties. Unlike self-attestation models, CPP requires independent
      timestamp verification through RFC 3161 TSA services, providing
      externally verifiable proof of when media was captured.</t>

      <t>This specification focuses on the interoperable core of CPP: the
      data structures, cryptographic operations, and verification algorithms
      necessary for independent third-party verification. Application-specific
      features such as depth analysis are defined as optional extensions.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="introduction">
      <name>Introduction</name>

      <section anchor="problem-statement">
        <name>Problem Statement</name>
        <t>Digital media authenticity faces several fundamental challenges:</t>
        <ul>
          <li><strong>Self-Attestation Weakness</strong>: Systems where creators
          sign their own claims provide no independent verification. A verifier
          must trust that the creator's claimed timestamp is accurate.</li>
          <li><strong>Metadata Stripping</strong>: Social media platforms and
          messaging applications routinely strip embedded metadata, breaking
          provenance chains that depend on file-level embedding.</li>
          <li><strong>Omission Attacks</strong>: Systems that prove individual
          media authenticity cannot detect when unfavorable evidence has been
          selectively deleted from a collection.</li>
          <li><strong>Terminology Confusion</strong>: Terms like "verified"
          mislead users into believing content truthfulness has been established,
          when only provenance has been recorded.</li>
        </ul>
      </section>

      <section anchor="design-goals">
        <name>Design Goals</name>
        <t>CPP addresses these challenges through the following design principles:</t>
        <ol>
          <li><strong>External Timestamp Verification</strong>: Timestamps MUST
          be anchored to independent RFC 3161 Time-Stamp Authorities, enabling
          third-party verification without trusting the capture device.</li>
          <li><strong>Omission Detection</strong>: The Completeness Invariant
          mechanism enables detection of deleted events within a collection.</li>
          <li><strong>Offline Verification</strong>: All data necessary for
          verification is included in the Evidence Pack, enabling verification
          without network access.</li>
          <li><strong>Provenance ≠ Truth</strong>: CPP proves when and by what
          device media was captured. It does NOT prove content truthfulness or
          scene authenticity.</li>
        </ol>
      </section>

      <section anchor="scope">
        <name>Scope</name>
        <t>This document specifies:</t>
        <ul>
          <li>The CPP event data model</li>
          <li>Hash computation and canonicalization rules</li>
          <li>Merkle tree construction and proof verification</li>
          <li>RFC 3161 TSA anchoring requirements</li>
          <li>Verification procedures for implementers</li>
        </ul>
        <t>This document does NOT specify:</t>
        <ul>
          <li>Application user interface requirements</li>
          <li>Network protocols for proof distribution</li>
          <li>Key management or certificate policies</li>
          <li>Content authenticity claims</li>
        </ul>
      </section>

      <section anchor="rfc6962-relationship">
        <name>Relationship to Other Specifications</name>
        <t>CPP defines its own Merkle tree construction that is NOT compatible
        with Certificate Transparency <xref target="RFC6962"/>. While inspired
        by similar principles, CPP uses different domain separation prefixes
        and padding rules optimized for media provenance use cases.
        Implementations MUST NOT assume RFC 6962 compatibility.</t>
      </section>
    </section>

    <section anchor="conventions">
      <name>Conventions and Definitions</name>
      <t>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 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and
      only when, they appear in all capitals, as shown here.</t>

      <t>Additionally, this document uses the following terms:</t>

      <dl>
        <dt>Event</dt>
        <dd>A discrete, signed record representing a provenance action
        (capture, export, deletion).</dd>

        <dt>EventHash</dt>
        <dd>A SHA-256 hash of the canonicalized event data, formatted as
        <tt>sha256:&lt;64_hex_chars&gt;</tt>.</dd>

        <dt>LeafHash</dt>
        <dd>SHA-256(0x00 || EventHash_bytes), used as input to the Merkle tree.
        The 0x00 prefix provides domain separation from internal nodes.</dd>

        <dt>MerkleRoot</dt>
        <dd>The root hash of a binary Merkle tree containing one or more
        LeafHashes.</dd>

        <dt>AnchorDigest</dt>
        <dd>The 32-byte value submitted to the TSA. Represented as a 64-character
        lowercase hexadecimal string without prefix. MUST equal the MerkleRoot
        value (after stripping the <tt>sha256:</tt> prefix).</dd>

        <dt>TreeSize</dt>
        <dd>The count of original leaves in the Merkle tree before any padding.
        An unsigned integer. MUST be &gt;= 1.</dd>

        <dt>PaddedSize</dt>
        <dd>The count of leaves after padding to a power of 2. Computed as the
        smallest power of 2 greater than or equal to TreeSize.</dd>

        <dt>Evidence Pack</dt>
        <dd>A self-contained data structure containing all information necessary
        for offline verification.</dd>

        <dt>Tombstone</dt>
        <dd>An event that records the legitimate deletion of a previous event.</dd>

        <dt>Provenance Available</dt>
        <dd>The recommended terminology for UI display, indicating capture
        provenance is recorded without implying content truth verification.</dd>

        <dt>Genesis PrevHash</dt>
        <dd>The constant value used as PrevHash for the first event in a chain:
        <tt>sha256:0000000000000000000000000000000000000000000000000000000000000000</tt>
        (64 zeros).</dd>
      </dl>
    </section>

    <section anchor="threat-model">
      <name>Threat Model</name>

      <section anchor="addressed-threats">
        <name>Addressed Threats</name>
        <table>
          <thead>
            <tr><th>Threat</th><th>Mitigation</th></tr>
          </thead>
          <tbody>
            <tr>
              <td>Timestamp forgery</td>
              <td>RFC 3161 TSA provides independent timestamp</td>
            </tr>
            <tr>
              <td>Evidence tampering</td>
              <td>EventHash binds content; Merkle proof binds to anchor</td>
            </tr>
            <tr>
              <td>Selective deletion</td>
              <td>Completeness Invariant detects missing events</td>
            </tr>
            <tr>
              <td>TSA token swapping</td>
              <td>messageImprint must match AnchorDigest</td>
            </tr>
          </tbody>
        </table>
      </section>

      <section anchor="non-threats">
        <name>Explicitly Not Addressed</name>
        <ul>
          <li>Content truthfulness (scene staging, deepfakes)</li>
          <li>Device compromise before capture</li>
          <li>Key extraction from secure hardware</li>
          <li>TSA collusion with adversary</li>
        </ul>
      </section>
    </section>

    <section anchor="data-model">
      <name>Data Model</name>

      <section anchor="events">
        <name>Events</name>
        <t>An Event is the fundamental unit of provenance in CPP. Events are
        signed records that capture discrete provenance actions.</t>

        <section anchor="event-types">
          <name>Event Types</name>
          <table>
            <thead>
              <tr><th>Type</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>INGEST</td><td>Media captured from device sensor</td></tr>
              <tr><td>SEAL</td><td>Collection sealed with Completeness Invariant</td></tr>
              <tr><td>EXPORT</td><td>Proof shared externally</td></tr>
              <tr><td>TOMBSTONE</td><td>Legitimate deletion record</td></tr>
            </tbody>
          </table>
        </section>

        <section anchor="event-structure">
          <name>Event Structure</name>
          <t>The following fields are REQUIRED for all events:</t>
          <table>
            <thead>
              <tr><th>Field</th><th>Type</th><th>Required</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>EventID</td><td>string</td><td>REQUIRED</td><td>Unique identifier (UUID)</td></tr>
              <tr><td>ChainID</td><td>string</td><td>REQUIRED</td><td>Identifier linking events in a sequence</td></tr>
              <tr><td>PrevHash</td><td>string</td><td>REQUIRED</td><td>Hash of previous event in chain</td></tr>
              <tr><td>Timestamp</td><td>string</td><td>REQUIRED</td><td>ISO 8601 timestamp with millisecond precision</td></tr>
              <tr><td>EventType</td><td>string</td><td>REQUIRED</td><td>One of: INGEST, SEAL, EXPORT, TOMBSTONE</td></tr>
              <tr><td>HashAlgo</td><td>string</td><td>REQUIRED</td><td>Always "SHA256"</td></tr>
              <tr><td>SignAlgo</td><td>string</td><td>REQUIRED</td><td>"ES256" or "Ed25519"</td></tr>
              <tr><td>EventHash</td><td>string</td><td>REQUIRED</td><td>SHA-256 hash of canonicalized event</td></tr>
              <tr><td>Signature</td><td>string</td><td>REQUIRED</td><td>Raw Base64-encoded signature (no prefix)</td></tr>
            </tbody>
          </table>
        </section>

        <section anchor="encoding-requirements">
          <name>Encoding Requirements</name>
          <t>All Base64-encoded fields (Signature, TSA.Token, public_key) MUST conform to:</t>
          <ul>
            <li><xref target="RFC4648"/> Section 4 (standard base64 alphabet, NOT base64url)</li>
            <li>No whitespace characters (no line breaks, spaces, or tabs)</li>
            <li>Padding characters (<tt>=</tt>) MUST be included when required</li>
          </ul>
          <t>PROHIBITED:</t>
          <ul>
            <li><tt>base64:MEUCIQDx...</tt> - Prefixes not allowed</li>
            <li><tt>data:application/octet-stream;base64,...</tt> - Data URIs not allowed</li>
            <li>Base64url alphabet (<tt>-</tt> and <tt>_</tt> instead of <tt>+</tt> and <tt>/</tt>)</li>
            <li>Line wrapping or embedded whitespace</li>
          </ul>
        </section>

        <section anchor="ingest-event">
          <name>INGEST Event</name>
          <t>INGEST events MUST include:</t>
          <table>
            <thead>
              <tr><th>Field</th><th>Type</th><th>Required</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>Asset.AssetHash</td><td>string</td><td>REQUIRED</td><td>SHA-256 hash of media bytes</td></tr>
              <tr><td>Asset.AssetType</td><td>string</td><td>REQUIRED</td><td>IMAGE or VIDEO</td></tr>
              <tr><td>Asset.MimeType</td><td>string</td><td>REQUIRED</td><td>MIME type of asset</td></tr>
              <tr><td>Asset.AssetID</td><td>string</td><td>OPTIONAL</td><td>Unique asset identifier</td></tr>
              <tr><td>Asset.AssetName</td><td>string</td><td>OPTIONAL</td><td>Original filename</td></tr>
              <tr><td>Asset.AssetSize</td><td>integer</td><td>OPTIONAL</td><td>File size in bytes</td></tr>
            </tbody>
          </table>
        </section>

        <section anchor="seal-event">
          <name>SEAL Event</name>
          <t>SEAL events finalize a collection and commit the Completeness Invariant.
          A SEAL event MUST include:</t>
          <table>
            <thead>
              <tr><th>Field</th><th>Type</th><th>Required</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>CollectionID</td><td>string</td><td>REQUIRED</td><td>Identifier for the sealed collection</td></tr>
              <tr><td>EventCount</td><td>integer</td><td>REQUIRED</td><td>Number of events in collection (excluding SEAL)</td></tr>
              <tr><td>CompletenessInvariant</td><td>object</td><td>REQUIRED</td><td>Completeness verification data</td></tr>
              <tr><td>MerkleRoot</td><td>string</td><td>REQUIRED</td><td>Root hash of events in collection</td></tr>
            </tbody>
          </table>

          <section anchor="completeness-invariant-object">
            <name>CompletenessInvariant Object</name>
            <table>
              <thead>
                <tr><th>Field</th><th>Type</th><th>Required</th><th>Description</th></tr>
              </thead>
              <tbody>
                <tr><td>ExpectedCount</td><td>integer</td><td>REQUIRED</td><td>Number of events that MUST be present</td></tr>
                <tr><td>HashSum</td><td>string</td><td>REQUIRED</td><td>XOR of all EventHash values (sha256: format)</td></tr>
                <tr><td>FirstTimestamp</td><td>string</td><td>REQUIRED</td><td>ISO 8601 timestamp of first event</td></tr>
                <tr><td>LastTimestamp</td><td>string</td><td>REQUIRED</td><td>ISO 8601 timestamp of last event</td></tr>
              </tbody>
            </table>
            <t>The HashSum is computed as:</t>
            <artwork><![CDATA[
HashSum = EventHash[0] XOR EventHash[1] XOR ... XOR EventHash[n-1]
]]></artwork>
            <t>Where XOR operates on the 32-byte binary values of each EventHash.</t>
          </section>

          <section anchor="seal-anchoring-pattern">
            <name>SEAL Anchoring Pattern</name>
            <t>The recommended anchoring pattern for SEAL events:</t>
            <ol>
              <li>Compute the Merkle tree over all INGEST events in the collection</li>
              <li>Create the SEAL event with MerkleRoot referencing this tree</li>
              <li>Include the SEAL event's EventHash as an additional leaf in a NEW Merkle tree</li>
              <li>Anchor this new tree (containing the SEAL event) to a TSA</li>
            </ol>
            <t>This pattern ensures the Completeness Invariant itself is bound to an
            external timestamp. The SEAL event's EventHash covers all CI fields, so
            the TSA anchor proves the CI existed at GenTime.</t>
            <t><strong>Alternative Pattern (NOT RECOMMENDED)</strong>: Including the
            SEAL event in the same Merkle tree it references creates a circular
            dependency and is prohibited.</t>
          </section>
        </section>

        <section anchor="tombstone-event">
          <name>TOMBSTONE Event</name>
          <t>TOMBSTONE events MUST additionally include:</t>
          <table>
            <thead>
              <tr><th>Field</th><th>Type</th><th>Required</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>DeletedEventId</td><td>string</td><td>REQUIRED</td><td>EventID being invalidated</td></tr>
              <tr><td>Reason</td><td>string</td><td>REQUIRED</td><td>Deletion reason code</td></tr>
              <tr><td>DeletedAt</td><td>string</td><td>REQUIRED</td><td>ISO 8601 deletion timestamp</td></tr>
            </tbody>
          </table>
        </section>
      </section>

      <section anchor="hash-chain">
        <name>Hash Chain</name>
        <t>Events form a hash chain through the PrevHash field:</t>
        <artwork><![CDATA[
Event 1: PrevHash = sha256:0000...0000 (genesis - 64 zeros)
Event 2: PrevHash = EventHash(Event 1)
Event 3: PrevHash = EventHash(Event 2)
]]></artwork>
        <t>Verification of chain integrity:</t>
        <ol>
          <li>For each event after the first, the verifier MUST compute EventHash
          of the previous event.</li>
          <li>The computed hash MUST match the current event's PrevHash field.</li>
          <li>If any mismatch is detected, verification MUST fail with status
          CHAIN_INTEGRITY_VIOLATION.</li>
        </ol>
      </section>

      <section anchor="merkle-tree-structure">
        <name>Merkle Tree Structure</name>
        <t>CPP defines its own binary Merkle tree construction optimized for media
        provenance. This construction uses domain separation prefixes to prevent
        attacks where leaf values could be confused with internal node values.</t>
        <t><strong>Important</strong>: CPP Merkle trees are NOT compatible with
        RFC 6962 (Certificate Transparency). Implementations MUST use the exact
        algorithms specified in this section.</t>

        <section anchor="domain-separation">
          <name>Domain Separation</name>
          <t>CPP uses single-byte prefixes to separate domains:</t>
          <table>
            <thead>
              <tr><th>Domain</th><th>Prefix Byte</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>Leaf</td><td>0x00</td><td>Applied to EventHash bytes</td></tr>
              <tr><td>Internal</td><td>0x01</td><td>Applied to concatenated child hashes</td></tr>
            </tbody>
          </table>
        </section>

        <section anchor="leaf-nodes">
          <name>Leaf Nodes</name>
          <artwork><![CDATA[
LeafHash = SHA256(0x00 || EventHash_bytes)
]]></artwork>
          <t>Where:</t>
          <ul>
            <li>0x00 is a single byte with value zero</li>
            <li>EventHash_bytes is the 32-byte binary representation of EventHash
            (after stripping the <tt>sha256:</tt> prefix)</li>
            <li>|| denotes byte concatenation</li>
          </ul>
          <t><strong>Rationale</strong>: The 0x00 prefix ensures leaf hashes cannot
          collide with internal node hashes, preventing second preimage attacks on
          the tree structure.</t>
        </section>

        <section anchor="internal-nodes">
          <name>Internal Nodes</name>
          <artwork><![CDATA[
InternalHash = SHA256(0x01 || Left_bytes || Right_bytes)
]]></artwork>
          <t>Where:</t>
          <ul>
            <li>0x01 is a single byte with value one</li>
            <li>Left_bytes is the 32-byte hash of the left child</li>
            <li>Right_bytes is the 32-byte hash of the right child</li>
            <li>|| denotes byte concatenation</li>
          </ul>
        </section>

        <section anchor="tree-construction">
          <name>Tree Construction</name>
          <t><strong>Step 1: Compute Leaf Hashes</strong></t>
          <t>For each event, compute LeafHash = SHA256(0x00 || EventHash_bytes).</t>

          <t><strong>Step 2: Determine Padding</strong></t>
          <t>PaddedSize is the smallest power of 2 &gt;= TreeSize:</t>
          <artwork><![CDATA[
function computePaddedSize(treeSize):
    if treeSize == 0:
        return 0  // Invalid - TreeSize MUST be >= 1
    paddedSize = 1
    while paddedSize < treeSize:
        paddedSize = paddedSize * 2
    return paddedSize
]]></artwork>

          <t><strong>Step 3: Pad Leaf Array</strong></t>
          <t>If TreeSize &lt; PaddedSize, duplicate the last leaf hash until the
          array length equals PaddedSize.</t>

          <t><strong>Step 4: Build Tree</strong></t>
          <artwork><![CDATA[
function buildTree(paddedLeaves):
    levels = [paddedLeaves]
    current = paddedLeaves
    
    while current.length > 1:
        nextLevel = []
        for i in range(0, current.length, 2):
            left = current[i]
            right = current[i + 1]
            parent = SHA256(0x01 || left || right)
            nextLevel.append(parent)
        levels.append(nextLevel)
        current = nextLevel
    
    return levels  // levels[0] = leaves, levels[-1] = [root]
]]></artwork>
        </section>

        <section anchor="merkle-proof-structure">
          <name>Merkle Proof Structure</name>
          <table>
            <thead>
              <tr><th>Field</th><th>Type</th><th>Description</th></tr>
            </thead>
            <tbody>
              <tr><td>TreeSize</td><td>integer</td><td>Original leaf count (before padding), unsigned, MUST be &gt;= 1</td></tr>
              <tr><td>LeafHashMethod</td><td>string</td><td>MUST be exactly <tt>SHA256(0x00||EventHash)</tt> (18 ASCII characters)</td></tr>
              <tr><td>LeafHash</td><td>string</td><td>Computed LeafHash for this event with sha256: prefix</td></tr>
              <tr><td>LeafIndex</td><td>integer</td><td>0-based position in tree, range [0, TreeSize-1]</td></tr>
              <tr><td>Proof</td><td>array</td><td>Sibling hashes from bottom to top, each with sha256: prefix</td></tr>
              <tr><td>Root</td><td>string</td><td>MerkleRoot with sha256: prefix</td></tr>
            </tbody>
          </table>
          <t><strong>TreeSize Constraint</strong>: An empty Merkle tree (TreeSize = 0)
          is not permitted. Verifiers MUST reject proofs where TreeSize &lt; 1.</t>
        </section>
      </section>

      <section anchor="anchor-structure">
        <name>Anchor Structure</name>
        <table>
          <thead>
            <tr><th>Field</th><th>Type</th><th>Description</th></tr>
          </thead>
          <tbody>
            <tr><td>AnchorID</td><td>string</td><td>Unique anchor identifier</td></tr>
            <tr><td>AnchorType</td><td>string</td><td>MUST be "RFC3161"</td></tr>
            <tr><td>AnchorDigest</td><td>string</td><td>MerkleRoot without prefix, 64 lowercase hex chars</td></tr>
            <tr><td>AnchorDigestAlgorithm</td><td>string</td><td>MUST be "sha-256"</td></tr>
            <tr><td>Merkle</td><td>object</td><td>Merkle proof structure</td></tr>
            <tr><td>TSA</td><td>object</td><td>TSA response data</td></tr>
          </tbody>
        </table>
      </section>
    </section>

    <section anchor="canonicalization-and-hashing">
      <name>Canonicalization and Hashing</name>

      <section anchor="json-canonicalization">
        <name>JSON Canonicalization</name>
        <t>Events MUST be canonicalized using <xref target="RFC8785"/> (JSON
        Canonicalization Scheme) before hashing.</t>
        <t>The following fields MUST be excluded from canonicalization:</t>
        <ul>
          <li>EventHash</li>
          <li>Signature</li>
        </ul>
        <t>All other fields MUST be included. Field names in the canonical event
        object use PascalCase (e.g., EventID, ChainID, PrevHash).</t>
      </section>

      <section anchor="eventhash-computation">
        <name>EventHash Computation</name>
        <artwork><![CDATA[
function computeEventHash(event):
    eventCopy = copy(event)
    delete eventCopy.EventHash
    delete eventCopy.Signature
    canonical = JCS_canonicalize(eventCopy)  // RFC 8785
    hashBytes = SHA256(canonical)
    return "sha256:" + lowercase_hex(hashBytes)
]]></artwork>
        <t>The resulting EventHash is a 71-character string: the prefix "sha256:"
        followed by 64 lowercase hexadecimal characters.</t>
      </section>

      <section anchor="leafhash-computation">
        <name>LeafHash Computation</name>
        <artwork><![CDATA[
function computeLeafHash(eventHash):
    hexStr = eventHash.substring(7)  // Remove "sha256:" prefix
    eventHashBytes = hexDecode(hexStr)  // 32 bytes
    prefixedData = [0x00] + eventHashBytes  // 33 bytes
    leafHashBytes = SHA256(prefixedData)
    return "sha256:" + lowercase_hex(leafHashBytes)
]]></artwork>
        <t>The 0x00 prefix byte provides domain separation from internal nodes.</t>
      </section>

      <section anchor="internal-node-hash-computation">
        <name>Internal Node Hash Computation</name>
        <artwork><![CDATA[
function computeInternalHash(left, right):
    leftBytes = hexDecode(left.substring(7))  // Remove prefix, decode
    rightBytes = hexDecode(right.substring(7))
    prefixedData = [0x01] + leftBytes + rightBytes  // 65 bytes
    hashBytes = SHA256(prefixedData)
    return "sha256:" + lowercase_hex(hashBytes)
]]></artwork>
        <t>The 0x01 prefix byte distinguishes internal nodes from leaves.</t>
      </section>

      <section anchor="anchordigest-computation">
        <name>AnchorDigest Computation</name>
        <t>AnchorDigest is the MerkleRoot value WITHOUT the <tt>sha256:</tt> prefix,
        represented as 64 lowercase hexadecimal characters.</t>
        <artwork><![CDATA[
function computeAnchorDigest(merkleRoot):
    return lowercase(merkleRoot.substring(7))
]]></artwork>
        <t><strong>PROHIBITED</strong>:</t>
        <ul>
          <li>SHA256(merkleRoot) - This would create double hashing</li>
          <li>SHA256(stringEncode(merkleRoot)) - This would hash the string representation</li>
          <li>Any transformation other than prefix removal</li>
          <li>Mixed case output - MUST be lowercase</li>
        </ul>
      </section>
    </section>

    <section anchor="anchoring-protocol">
      <name>Anchoring Protocol</name>

      <section anchor="tsa-request-construction">
        <name>TSA Request Construction</name>
        <t>The messageImprint in TimeStampReq MUST contain:</t>
        <ul>
          <li>hashAlgorithm: SHA-256 (OID 2.16.840.1.101.3.4.2.1)</li>
          <li>hashedMessage: AnchorDigest as 32-byte OCTET STRING</li>
        </ul>
        <artwork><![CDATA[
TimeStampReq ::= SEQUENCE {
   version         INTEGER { v1(1) },
   messageImprint  MessageImprint,
   reqPolicy       OBJECT IDENTIFIER OPTIONAL,
   nonce           INTEGER OPTIONAL,
   certReq         BOOLEAN DEFAULT FALSE,
   extensions      [0] IMPLICIT Extensions OPTIONAL
}

MessageImprint ::= SEQUENCE {
   hashAlgorithm   AlgorithmIdentifier,  -- SHA-256
   hashedMessage   OCTET STRING          -- AnchorDigest (32 bytes)
}
]]></artwork>

        <section anchor="certreq-recommendation">
          <name>certReq Recommendation</name>
          <t>Producers SHOULD set certReq to TRUE to request the TSA's signing
          certificate be included in the response. This enables:</t>
          <ul>
            <li>Offline verification without fetching certificates separately</li>
            <li>Long-term verification even if TSA infrastructure changes</li>
            <li>Self-contained Evidence Packs</li>
          </ul>
          <t>If certReq is FALSE and the TSA certificate is not included in the
          response, verifiers MUST attempt to obtain the certificate through other
          means (e.g., AIA extension, local cache) or return VALID_WARNING.</t>
        </section>
      </section>

      <section anchor="tsa-response-processing">
        <name>TSA Response Processing</name>
        <t>Upon receiving TimeStampResp, the producer:</t>
        <ol>
          <li>MUST verify the response status is granted (0) or grantedWithMods (1)</li>
          <li>MUST extract the TimeStampToken from the response</li>
          <li>MUST store the complete DER-encoded TimeStampToken</li>
          <li>MUST extract and store the messageImprint from TSTInfo</li>
          <li>MUST extract and store GenTime from TSTInfo</li>
        </ol>
      </section>

      <section anchor="single-leaf-tree-rules">
        <name>Single-Leaf Tree Rules</name>
        <t>When TreeSize equals 1, the following invariants MUST hold:</t>
        <ul>
          <li>LeafIndex MUST equal 0</li>
          <li>Proof MUST be an empty array</li>
          <li>Root MUST equal LeafHash</li>
          <li>LeafHash MUST equal SHA256(0x00 || EventHash_bytes)</li>
        </ul>
        <t>If any of these conditions fail, verification MUST return INVALID.</t>
      </section>

      <section anchor="multi-leaf-tree-rules">
        <name>Multi-Leaf Tree Rules</name>
        <t>For TreeSize greater than 1:</t>
        <ul>
          <li>LeafIndex MUST be in range [0, TreeSize-1]</li>
          <li>PaddedSize = smallest power of 2 &gt;= TreeSize</li>
          <li>Proof length MUST NOT exceed log2(PaddedSize)</li>
          <li>Sibling hashes are ordered from bottom (leaf level) to top (root level)</li>
          <li>Index parity determines pairing order: even=left, odd=right</li>
          <li>All internal nodes use SHA256(0x01 || left || right)</li>
        </ul>
      </section>
    </section>

    <section anchor="verification-procedures">
      <name>Verification Procedures</name>

      <section anchor="verification-result-codes">
        <name>Verification Result Codes</name>
        <table>
          <thead>
            <tr><th>Code</th><th>Meaning</th></tr>
          </thead>
          <tbody>
            <tr><td>VALID</td><td>All checks passed, including TSA signature verification</td></tr>
            <tr><td>VALID_WARNING</td><td>Cryptographic checks passed, but TSA certificate chain could not be fully validated</td></tr>
            <tr><td>INVALID</td><td>Cryptographic verification failed</td></tr>
            <tr><td>CHAIN_INTEGRITY_VIOLATION</td><td>Hash chain is broken</td></tr>
            <tr><td>COMPLETENESS_VIOLATION</td><td>Completeness Invariant mismatch</td></tr>
          </tbody>
        </table>
        <t><strong>Note</strong>: VALID_WARNING indicates the proof is cryptographically
        sound but the TSA's identity could not be independently verified. Applications
        SHOULD display this distinction to users.</t>
      </section>

      <section anchor="event-verification">
        <name>Event Verification</name>
        <artwork><![CDATA[
function verifyEvent(event, publicKey):
    // Step 1: Recompute EventHash
    computedHash = computeEventHash(event)
    if computedHash != event.EventHash:
        return INVALID("EventHash mismatch")
    
    // Step 2: Verify signature
    hashBytes = hexDecode(event.EventHash.substring(7))
    sigBytes = base64Decode(event.Signature)
    if not verifySignature(publicKey, hashBytes, sigBytes):
        return INVALID("Signature verification failed")
    
    return VALID
]]></artwork>
      </section>

      <section anchor="merkle-proof-verification">
        <name>Merkle Proof Verification</name>
        <artwork><![CDATA[
function verifyMerkleProof(eventHash, leafIndex, proof, 
                           expectedRoot, treeSize):
    // Step 1: Validate inputs
    if treeSize < 1:
        return INVALID("TreeSize must be >= 1")
    if leafIndex < 0 or leafIndex >= treeSize:
        return INVALID("LeafIndex out of range")
    
    paddedSize = computePaddedSize(treeSize)
    maxProofLength = log2(paddedSize)
    if proof.length > maxProofLength:
        return INVALID("Proof too long")
    
    // Step 2: Compute leaf hash with domain separation
    currentHash = computeLeafHash(eventHash)  // SHA256(0x00 || bytes)
    
    // Step 3: Handle single-leaf case
    if treeSize == 1:
        if leafIndex != 0:
            return INVALID("LeafIndex must be 0 for single-leaf")
        if proof.length != 0:
            return INVALID("Proof must be empty for single-leaf")
        if lowercase(currentHash) != lowercase(expectedRoot):
            return INVALID("Root != LeafHash for single-leaf")
        return VALID
    
    // Step 4: Traverse proof from bottom to top
    index = leafIndex
    for siblingHash in proof:
        if index % 2 == 0:
            // Current is left child
            currentHash = computeInternalHash(currentHash, siblingHash)
        else:
            // Current is right child
            currentHash = computeInternalHash(siblingHash, currentHash)
        index = floor(index / 2)
    
    // Step 5: Compare with expected root (case-insensitive)
    if lowercase(currentHash) != lowercase(expectedRoot):
        return INVALID("Computed root != expected root")
    
    return VALID
]]></artwork>
      </section>

      <section anchor="tsa-verification">
        <name>TSA Verification</name>
        <t>TSA verification ensures the timestamp token was legitimately issued by
        a Time-Stamp Authority and binds the correct digest.</t>
        <artwork><![CDATA[
function verifyTSAAnchor(eventHash, anchor):
    // Step 1: Verify Merkle structure
    merkle = anchor.Merkle
    result = verifyMerkleProof(
        eventHash,
        merkle.LeafIndex,
        merkle.Proof,
        merkle.Root,
        merkle.TreeSize
    )
    if result != VALID:
        return result
    
    // Step 2: Verify LeafHashMethod
    if merkle.LeafHashMethod != "SHA256(0x00||EventHash)":
        return INVALID("Unsupported LeafHashMethod")
    
    // Step 3: Verify AnchorDigest == MerkleRoot
    expectedDigest = lowercase(merkle.Root.substring(7))
    if lowercase(anchor.AnchorDigest) != expectedDigest:
        return INVALID("AnchorDigest != MerkleRoot")
    
    // Step 4: Parse TSA Token (RFC 5652 ContentInfo)
    tsaToken = base64Decode(anchor.TSA.Token)
    contentInfo = parseContentInfo(tsaToken)  // RFC 5652
    signedData = parseSignedData(contentInfo.content)
    tstInfo = parseTSTInfo(signedData.encapContentInfo.eContent)
    
    // Step 5: Verify hash algorithm is SHA-256
    if tstInfo.messageImprint.hashAlgorithm != SHA256_OID:
        return INVALID("Unsupported TSA hash algorithm")
    
    // Step 6: Verify messageImprint == AnchorDigest (MUST)
    tstImprint = lowercase_hex(tstInfo.messageImprint.hashedMessage)
    if tstImprint != lowercase(anchor.AnchorDigest):
        return INVALID("TSA messageImprint != AnchorDigest")
    
    // Step 7: Verify CMS signature over TSTInfo (MUST per RFC 5652)
    signerInfo = signedData.signerInfos[0]
    signatureValid = verifyCMSSignature(
        signedData.encapContentInfo.eContent,
        signerInfo.signature,
        signerInfo.signatureAlgorithm,
        extractSignerCert(signedData.certificates, signerInfo.sid)
    )
    if not signatureValid:
        return INVALID("TSA signature verification failed")
    
    // Step 8: Verify certificate chain (SHOULD)
    certValid = verifyCertificateChain(
        signedData.certificates,
        signerInfo.sid,
        trustAnchors
    )
    
    if certValid:
        return VALID(genTime = tstInfo.genTime)
    else:
        return VALID_WARNING(
            genTime = tstInfo.genTime,
            warning = "TSA certificate chain could not be verified"
        )
]]></artwork>

        <section anchor="cms-signature-verification-requirements">
          <name>CMS Signature Verification Requirements</name>
          <t>Per <xref target="RFC5652"/>, verifiers MUST:</t>
          <ol>
            <li>Parse the TimeStampToken as a ContentInfo structure</li>
            <li>Extract the SignedData from the content field</li>
            <li>Locate the SignerInfo corresponding to the TSA</li>
            <li>Verify the signature over the encapsulated TSTInfo</li>
            <li>Verify the signer's certificate was valid at signing time</li>
          </ol>
          <t>Verifiers SHOULD:</t>
          <ol>
            <li>Build and validate the certificate chain to a trust anchor</li>
            <li>Verify the TSA certificate contains the id-kp-timeStamping extended key usage</li>
            <li>Check for certificate revocation</li>
          </ol>
        </section>
      </section>

      <section anchor="chain-integrity-verification">
        <name>Chain Integrity Verification</name>
        <artwork><![CDATA[
GENESIS_PREV_HASH = "sha256:00000000000000000000000000000000" +
                    "00000000000000000000000000000000"

function verifyChainIntegrity(events):
    if events.length == 0:
        return VALID
    
    // First event must have Genesis PrevHash (64 zeros)
    if events[0].PrevHash != GENESIS_PREV_HASH:
        return CHAIN_INTEGRITY_VIOLATION("Invalid genesis PrevHash")
    
    for i in range(1, events.length):
        expectedPrevHash = events[i-1].EventHash
        if events[i].PrevHash != expectedPrevHash:
            return CHAIN_INTEGRITY_VIOLATION(
                "Break at event " + i + 
                ": expected " + expectedPrevHash +
                ", found " + events[i].PrevHash)
    
    return VALID
]]></artwork>
      </section>

      <section anchor="completeness-invariant-verification">
        <name>Completeness Invariant Verification</name>
        <t>The Completeness Invariant is verified against a SEAL event. The SEAL
        event MUST be anchored to a TSA to provide external timestamp binding
        for the entire collection.</t>
        <artwork><![CDATA[
function verifyCompleteness(events, sealEvent):
    ci = sealEvent.CompletenessInvariant
    
    // Step 1: Verify count matches
    if events.length != ci.ExpectedCount:
        return COMPLETENESS_VIOLATION(
            "Count mismatch: expected " + ci.ExpectedCount + 
            ", found " + events.length)
    
    // Step 2: Compute XOR hash sum
    computed = bytes(32)  // Initialize to all zeros
    for event in events:
        eventHashBytes = hexDecode(event.EventHash.substring(7))
        computed = XOR(computed, eventHashBytes)
    
    // Step 3: Compare with sealed value
    expectedHashSum = hexDecode(ci.HashSum.substring(7))
    if computed != expectedHashSum:
        return COMPLETENESS_VIOLATION(
            "Hash sum mismatch - events may be missing or added")
    
    // Step 4: Verify timestamp bounds
    for event in events:
        if event.Timestamp < ci.FirstTimestamp:
            return COMPLETENESS_VIOLATION(
                "Event timestamp before collection start")
        if event.Timestamp > ci.LastTimestamp:
            return COMPLETENESS_VIOLATION(
                "Event timestamp after collection end")
    
    return VALID
]]></artwork>

        <section anchor="attack-detection">
          <name>Attack Detection</name>
          <table>
            <thead>
              <tr><th>Attack</th><th>Detection</th></tr>
            </thead>
            <tbody>
              <tr><td>Delete event</td><td>Hash sum mismatch and/or count mismatch</td></tr>
              <tr><td>Add fake event</td><td>Count mismatch and/or hash sum mismatch</td></tr>
              <tr><td>Reorder events</td><td>Chain integrity violation (PrevHash mismatch)</td></tr>
              <tr><td>Modify event</td><td>EventHash mismatch in chain</td></tr>
            </tbody>
          </table>
        </section>
      </section>
    </section>

    <section anchor="privacy-considerations">
      <name>Privacy Considerations</name>

      <section anchor="location-data">
        <name>Location Data</name>
        <t>Location collection SHOULD be disabled by default. When enabled,
        implementations SHOULD:</t>
        <ul>
          <li>Clearly indicate when location is being recorded</li>
          <li>Allow users to delete location from individual events</li>
          <li>Consider privacy implications of location precision</li>
        </ul>
      </section>

      <section anchor="biometric-data">
        <name>Biometric Data</name>
        <t>Implementations MUST NOT store raw biometric data (fingerprints,
        face images). Human presence verification, if implemented, SHOULD:</t>
        <ul>
          <li>Process biometrics locally on-device</li>
          <li>Store only verification results (boolean flags)</li>
          <li>Never transmit biometric data to external services</li>
        </ul>
      </section>

      <section anchor="tombstone-privacy">
        <name>Tombstone Privacy</name>
        <t>When events are deleted via TOMBSTONE:</t>
        <ul>
          <li>Original event content is removed</li>
          <li>TOMBSTONE preserves chain integrity</li>
          <li>Reason codes allow selective disclosure</li>
        </ul>
      </section>

      <section anchor="shareable-vs-forensic-proofs">
        <name>Shareable vs Forensic Proofs</name>
        <t>Evidence Packs may be created with different privacy levels:</t>
        <table>
          <thead>
            <tr><th>Level</th><th>Includes</th><th>Use Case</th></tr>
          </thead>
          <tbody>
            <tr><td>Shareable</td><td>Timestamp, device info, asset hash</td><td>Social sharing</td></tr>
            <tr><td>Forensic</td><td>All metadata including location</td><td>Legal proceedings</td></tr>
          </tbody>
        </table>
      </section>
    </section>

    <section anchor="security-considerations">
      <name>Security Considerations</name>

      <section anchor="hash-algorithm-agility">
        <name>Hash Algorithm Agility</name>
        <t>This specification mandates SHA-256 for all hash computations. Future
        versions MAY define additional algorithms via the HashAlgo field.
        Verifiers MUST reject unknown hash algorithms.</t>
      </section>

      <section anchor="signature-algorithm-requirements">
        <name>Signature Algorithm Requirements</name>
        <t>Implementations MUST support ES256 (ECDSA with P-256 and SHA-256) for
        mobile device compatibility. Ed25519 MAY be supported for non-mobile
        implementations.</t>
        <t>Private keys SHOULD be stored in hardware security modules (Secure
        Enclave, StrongBox, TPM) where available.</t>
      </section>

      <section anchor="tsa-trust">
        <name>TSA Trust</name>
        <t>Security of timestamp proofs depends on TSA trustworthiness.
        Implementations:</t>
        <ul>
          <li>MUST verify the CMS signature in the TimeStampToken per
          <xref target="RFC5652"/></li>
          <li>SHOULD validate the certificate chain to a configured trust anchor</li>
          <li>SHOULD use TSAs with published certificate policies</li>
          <li>MAY support multiple TSA services for redundancy</li>
        </ul>
        <t>If certificate chain validation fails but CMS signature verification
        succeeds, the result SHOULD be VALID_WARNING rather than INVALID, as the
        timestamp binding is cryptographically sound even if the TSA's identity
        cannot be fully verified.</t>
      </section>

      <section anchor="merkle-tree-security">
        <name>Merkle Tree Security</name>

        <section anchor="domain-separation-security">
          <name>Domain Separation</name>
          <t>The 0x00/0x01 prefix bytes ensure:</t>
          <ul>
            <li>Leaf hashes cannot equal internal node hashes for any input</li>
            <li>An attacker cannot construct a valid proof by substituting internal
            nodes for leaves</li>
            <li>The tree structure is unambiguous given a root hash</li>
          </ul>
          <t>This construction differs from Certificate Transparency
          <xref target="RFC6962"/> which uses a similar but incompatible scheme.</t>
        </section>

        <section anchor="padding-security">
          <name>Padding Security</name>
          <t>Duplicating the last leaf for padding:</t>
          <ul>
            <li>Is deterministic (no randomness)</li>
            <li>Produces the same tree for the same inputs</li>
            <li>Does not leak information about padding count (TreeSize is
            explicitly stored)</li>
          </ul>
        </section>
      </section>

      <section anchor="clock-accuracy">
        <name>Clock Accuracy</name>
        <t>Device timestamps (Timestamp field) are self-attested and may be
        inaccurate. The authoritative timestamp is GenTime from the TSA response.</t>
        <t>Implementations SHOULD warn users when device time differs significantly
        from TSA GenTime (e.g., more than 5 minutes).</t>
      </section>

      <section anchor="deletion-detection-limitations">
        <name>Deletion Detection Limitations</name>
        <t>The Completeness Invariant detects deletions within a sealed collection.
        It does NOT detect:</t>
        <ul>
          <li>Events never created (adversary captured but never recorded)</li>
          <li>Events in other collections</li>
          <li>Deletions before sealing</li>
        </ul>

        <section anchor="xor-hash-sum-limitations">
          <name>XOR Hash Sum Limitations</name>
          <t>The Completeness Invariant uses XOR for omission detection, NOT for
          cryptographic commitment. Important limitations:</t>
          <ul>
            <li><strong>Collision by design</strong>: XOR is commutative and
            self-inverse. An attacker who can forge TWO events with EventHashes
            that XOR to zero can delete both without detection.</li>
            <li><strong>Not a commitment scheme</strong>: Unlike Merkle roots, the
            XOR hash sum does not cryptographically bind to a specific set of events.</li>
            <li><strong>Complementary mechanism</strong>: The CI is designed to work
            WITH the Merkle tree anchor, not replace it. The TSA-anchored Merkle
            root provides the cryptographic commitment; the CI provides additional
            omission detection for collections.</li>
          </ul>
          <t><strong>Threat model</strong>: The CI protects against accidental
          deletion or deletion by parties who cannot forge events (e.g., device
          owners deleting their own legitimately-captured evidence). It does NOT
          protect against adversaries who control event creation.</t>
        </section>
      </section>

      <section anchor="canonicalization-attacks">
        <name>Canonicalization Attacks</name>
        <t>JSON canonicalization per <xref target="RFC8785"/> prevents ordering
        and whitespace attacks. However, implementations MUST ensure:</t>
        <ul>
          <li>Field names exactly match the specification (PascalCase for events)</li>
          <li>No additional fields are introduced before hashing</li>
          <li>Unicode normalization is handled consistently</li>
        </ul>
      </section>
    </section>

    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>

    <section anchor="implementation-experience">
      <name>Implementation Experience</name>

      <section anchor="verasnap">
        <name>VeraSnap (Non-Normative)</name>
        <t>VeraSnap is a consumer iOS application implementing CPP. It demonstrates:</t>
        <ul>
          <li>Secure Enclave key storage with ES256 signatures</li>
          <li>RFC 3161 TSA integration with multiple providers</li>
          <li>Merkle tree construction per this specification</li>
          <li>Offline proof verification</li>
        </ul>
        <t>Implementation validated that:</t>
        <ul>
          <li>Single-leaf Merkle proofs verify correctly</li>
          <li>TSA messageImprint extraction works across TSA providers</li>
          <li>Evidence Packs enable verification without network access</li>
        </ul>
        <t>Deployment experience informed the explicit specification of:</t>
        <ul>
          <li>AnchorDigest computation (avoiding double-hashing)</li>
          <li>Single-leaf tree invariants</li>
          <li>LeafHashMethod field for algorithm agility</li>
        </ul>
      </section>
    </section>
  </middle>

  <back>
    <references>
      <name>References</name>

      <references>
        <name>Normative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3161.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4648.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5652.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8785.xml"/>
      </references>

      <references>
        <name>Informative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6962.xml"/>

        <reference anchor="C2PA" target="https://c2pa.org/specifications/">
          <front>
            <title>C2PA Specification</title>
            <author>
              <organization>Coalition for Content Provenance and Authenticity</organization>
            </author>
            <date year="2024"/>
          </front>
        </reference>
      </references>
    </references>

    <section anchor="json-examples">
      <name>JSON Examples</name>

      <section anchor="canonical-event-normative">
        <name>Canonical Event (Normative)</name>
        <t>The canonical event structure uses PascalCase field names. This is
        the structure that MUST be used for EventHash computation.</t>
        <artwork type="json"><![CDATA[
{
  "EventID": "550e8400-e29b-41d4-a716-446655440001",
  "ChainID": "urn:uuid:550e8400-e29b-41d4-a716-446655440000",
  "PrevHash": "sha256:00000000000000000000000000000000000000000000000000000000000000",
  "Timestamp": "2026-01-27T10:30:00.000Z",
  "EventType": "INGEST",
  "HashAlgo": "SHA256",
  "SignAlgo": "ES256",
  "Asset": {
    "AssetID": "asset-001",
    "AssetType": "IMAGE",
    "AssetHash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "AssetName": "IMG_0001.HEIC",
    "MimeType": "image/heic"
  },
  "EventHash": "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
  "Signature": "MEUCIQDKsRwMv..."
}
]]></artwork>
      </section>

      <section anchor="seal-event-normative">
        <name>SEAL Event (Normative)</name>
        <artwork type="json"><![CDATA[
{
  "EventID": "550e8400-e29b-41d4-a716-446655440010",
  "ChainID": "urn:uuid:550e8400-e29b-41d4-a716-446655440000",
  "PrevHash": "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
  "Timestamp": "2026-01-27T18:00:00.000Z",
  "EventType": "SEAL",
  "HashAlgo": "SHA256",
  "SignAlgo": "ES256",
  "CollectionID": "collection-2026-01-27",
  "EventCount": 5,
  "CompletenessInvariant": {
    "ExpectedCount": 5,
    "HashSum": "sha256:1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890",
    "FirstTimestamp": "2026-01-27T10:30:00.000Z",
    "LastTimestamp": "2026-01-27T17:45:00.000Z"
  },
  "MerkleRoot": "sha256:03938e2c8f758e6cae443d499b41c899c373eb0c0198bae61796a069f2b05904",
  "EventHash": "sha256:abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab",
  "Signature": "MEYCIQCx..."
}
]]></artwork>
      </section>

      <section anchor="anchor-structure-normative">
        <name>Anchor Structure (Normative)</name>
        <artwork type="json"><![CDATA[
{
  "Anchor": {
    "AnchorID": "anchor-001",
    "AnchorType": "RFC3161",
    "AnchorDigest": "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
    "AnchorDigestAlgorithm": "sha-256",
    "Merkle": {
      "TreeSize": 1,
      "LeafHashMethod": "SHA256(0x00||EventHash)",
      "LeafHash": "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
      "LeafIndex": 0,
      "Proof": [],
      "Root": "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"
    },
    "TSA": {
      "Token": "MIIEzAYJKoZIhvcNAQcCoIIEvTCCBLkCAQMx...",
      "MessageImprint": {
        "HashAlgorithm": "sha-256",
        "HashedMessage": "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"
      },
      "GenTime": "2026-01-27T10:31:00.000Z",
      "Service": "https://freetsa.org/tsr"
    }
  }
}
]]></artwork>
      </section>

      <section anchor="evidence-pack-non-normative">
        <name>Evidence Pack (Non-Normative)</name>
        <t>The Evidence Pack is a distribution format. Field names use snake_case
        for compatibility with common JSON conventions in web APIs. This format
        is non-normative; implementations MAY use alternative formats.</t>
        <artwork type="json"><![CDATA[
{
  "proof_version": "1.3",
  "proof_type": "CPP_INGEST_PROOF",
  "proof_id": "proof-001",
  "event": {
    "event_id": "550e8400-e29b-41d4-a716-446655440001",
    "event_type": "INGEST",
    "timestamp": "2026-01-27T10:30:00.000Z",
    "asset_hash": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "asset_type": "IMAGE"
  },
  "event_hash": "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
  "signature": {
    "algo": "ES256",
    "value": "MEUCIQDKsRwMv..."
  },
  "public_key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...",
  "timestamp_proof": {
    "type": "RFC3161",
    "anchor_digest": "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
    "digest_algorithm": "sha-256",
    "merkle": {
      "tree_size": 1,
      "leaf_hash_method": "SHA256(0x00||EventHash)",
      "leaf_index": 0,
      "proof": [],
      "root": "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"
    },
    "tsa": {
      "token": "MIIEzAYJKoZIhvcNAQcCoIIEvTCCBLkCAQMx...",
      "message_imprint": "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
      "gen_time": "2026-01-27T10:31:00.000Z",
      "service": "https://freetsa.org/tsr"
    }
  }
}
]]></artwork>
        <t><strong>Note</strong>: When verifying an Evidence Pack, implementations
        MUST reconstruct the canonical event structure (PascalCase) from the
        evidence pack fields before computing EventHash.</t>
      </section>
    </section>

    <section anchor="test-vectors">
      <name>Test Vectors</name>
      <t>All test vectors in this section use the domain-separated hash
      construction defined in this specification.</t>

      <section anchor="test-vector-1">
        <name>Test Vector 1: Single-Leaf Tree</name>
        <t><strong>Input:</strong></t>
        <artwork><![CDATA[
EventHash = "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730"
]]></artwork>
        <t><strong>Computation:</strong></t>
        <artwork><![CDATA[
EventHash_bytes = 0x7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730

LeafHash = SHA256(0x00 || EventHash_bytes)
         = SHA256(0x007d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730)
         = sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929

For TreeSize=1:
  Root = LeafHash = sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929
  LeafIndex = 0
  Proof = []
  AnchorDigest = 719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929
]]></artwork>
        <t><strong>Expected Anchor:</strong></t>
        <artwork type="json"><![CDATA[
{
  "Merkle": {
    "TreeSize": 1,
    "LeafHashMethod": "SHA256(0x00||EventHash)",
    "LeafHash": "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
    "LeafIndex": 0,
    "Proof": [],
    "Root": "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"
  },
  "AnchorDigest": "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"
}
]]></artwork>
        <t><strong>Verification:</strong></t>
        <artwork><![CDATA[
verifyMerkleProof(
    "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
    0, [], 
    "sha256:719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929",
    1
) = VALID
]]></artwork>
      </section>

      <section anchor="test-vector-2">
        <name>Test Vector 2: Two-Leaf Tree</name>
        <t><strong>Input:</strong></t>
        <artwork><![CDATA[
EventHash[0] = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
EventHash[1] = "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
]]></artwork>
        <t><strong>Computation:</strong></t>
        <artwork><![CDATA[
L0 = SHA256(0x00 || 0xaa...aa)
   = sha256:e0bb82791bae3c50bd9c20fa4ccdcb8064a56e5c12bc69b07e6712ac9b4429e6

L1 = SHA256(0x00 || 0xbb...bb)
   = sha256:4f16119d36ccd0da91102f57692d73934fd0ad2494280df88449accedbbfb7ea

Root = SHA256(0x01 || L0_bytes || L1_bytes)
     = SHA256(0x01 || 0xe0bb82...e6 || 0x4f1611...ea)
     = sha256:03938e2c8f758e6cae443d499b41c899c373eb0c0198bae61796a069f2b05904

TreeSize = 2
PaddedSize = 2 (no padding needed)

For index 0: Proof = ["sha256:4f16119d36ccd0da91102f57692d73934fd0ad2494280df88449accedbbfb7ea"]
For index 1: Proof = ["sha256:e0bb82791bae3c50bd9c20fa4ccdcb8064a56e5c12bc69b07e6712ac9b4429e6"]
]]></artwork>
        <t><strong>Verification of Index 0:</strong></t>
        <artwork><![CDATA[
1. currentHash = SHA256(0x00 || EventHash[0]_bytes)
              = sha256:e0bb82791bae3c50bd9c20fa4ccdcb8064a56e5c12bc69b07e6712ac9b4429e6

2. index = 0, which is EVEN -> current is LEFT child

3. siblingHash = sha256:4f16119d36ccd0da91102f57692d73934fd0ad2494280df88449accedbbfb7ea

4. currentHash = SHA256(0x01 || currentHash_bytes || siblingHash_bytes)
              = sha256:03938e2c8f758e6cae443d499b41c899c373eb0c0198bae61796a069f2b05904

5. Compare with expected Root: MATCH

Result: VALID
]]></artwork>
      </section>

      <section anchor="test-vector-3">
        <name>Test Vector 3: TSA messageImprint Verification</name>
        <t><strong>Input:</strong></t>
        <artwork><![CDATA[
AnchorDigest = "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"

TSA Token TSTInfo contains:
  messageImprint.hashAlgorithm = 2.16.840.1.101.3.4.2.1 (SHA-256)
  messageImprint.hashedMessage = 0x719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929
]]></artwork>
        <t><strong>Verification:</strong></t>
        <artwork><![CDATA[
1. Extract messageImprint.hashedMessage from TSTInfo
   hashedMessage = 0x719f871f...1e929

2. Convert to lowercase hex string
   tstImprint = "719f871f1018a17ebe199d4f0db27e3a4929f8ab3e46f5c0d30054f4b331e929"

3. Compare with AnchorDigest (case-insensitive)
   tstImprint == lowercase(AnchorDigest) ?
   "719f871f...1e929" == "719f871f...1e929" ? YES

Result: VALID
]]></artwork>
      </section>
    </section>

    <section anchor="acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>The authors thank:</t>
      <ul>
        <li>The VeritasChain Standards Organization (VSO) for developing the CPP
        specification series</li>
        <li>The implementers of VeraSnap for validation feedback that improved
        this specification</li>
        <li>Early reviewers who identified the domain separation and Completeness
        Invariant modeling issues</li>
      </ul>
    </section>
  </back>
</rfc>
