<?xml version="1.0" encoding="UTF-8"?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc strict="no"?>
<rfc category="std"
     docName="draft-ztop-secdispatch-protocol-00"
     ipr="trust200902"
     consensus="yes"
     submissionType="IETF">

  <front>
    <title abbrev="ZTOP">Zero Trust Transfer Orchestration Protocol (ZTOP)</title>

    <author initials="S." surname="Karthik" fullname="Sripad Karthik">
      <organization>Zero Trust Consortium</organization>
      <address>
        <postal>
          <country>India</country>
        </postal>
        <email>sripadkarthik@gmail.com</email>
        <uri>https://github.com/sripad2020/ztop-research/</uri>
      </address>
    </author>

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

    <area>Security</area>
    <workgroup>SECDISPATCH</workgroup>
    <keyword>zero trust</keyword>
    <keyword>file transfer</keyword>
    <keyword>cryptographic protocol</keyword>
    <keyword>application layer</keyword>
    <keyword>Ed25519</keyword>
    <keyword>Merkle tree</keyword>

    <abstract>
      <t>
        This document defines the Zero Trust Transfer Orchestration Protocol
        (ZTOP), a novel Application Layer (OSI Layer 7) protocol for
        orchestrating cryptographically authenticated, continuously attested
        peer-to-peer file transfer in Zero Trust Architectures (ZTA).
      </t>
      <t>
        ZTOP operates within a TLS 1.3 transport tunnel and introduces:
        a hardware-derived cryptographic Peer Identity using HKDF-SHA512
        and Ed25519; a 5-layer X.509 certificate chain with custom
        OID-encoded Zero Trust metadata; a continuous 16-field Heartbeat
        attestation protocol; a 100-point Adaptive Tamper Resistance Score
        across six security dimensions; a dual-signed 19-field Metadata
        Exchange Protocol preceding any payload transfer; a 380-byte
        Cryptographic Execution Manifest (CEM) permanently bound to every
        transferred file; SHA-256 binary Merkle-tree chunk integrity with
        immediate per-chunk proof validation; protocol-native static
        pre-execution behavioral analysis; and a 7-Level non-repudiation
        Signature Chain. A transfer is considered complete only when all
        seven cryptographic signatures are present and verified.
      </t>
      <t>
        A Python reference implementation is available at:
        https://github.com/sripad2020/ztop-research/
      </t>
    </abstract>
  </front>

  <middle>

    <!-- ============================================================ -->
    <section title="Introduction" anchor="intro">
      <t>
        File transfer protocols have not evolved with Zero Trust security
        principles <xref target="RFC7296"/>. Protocols such as SFTP
        <xref target="RFC4253"/> and FTP <xref target="RFC959"/>
        authenticate a user once via a static credential and subsequently
        establish an open, trusted channel. They have no awareness of
        device security posture, real-time behavioral analysis of the
        transferred content, or cryptographic non-repudiation of the
        transaction itself.
      </t>
      <t>
        Enterprises today solve this limitation by deploying five or more
        separate security products alongside a legacy file transfer
        protocol, resulting in fragmented, expensive, and operationally
        complex architectures.
      </t>
      <t>
        ZTOP defines a single, self-contained Application Layer protocol
        that natively integrates all of the following:
      </t>
      <t><list style="symbols">
        <t>Cryptographic Peer Identity derived from hardware attestation</t>
        <t>Continuous device posture evaluation and dynamic trust scoring</t>
        <t>Declarative organizational policy enforcement</t>
        <t>Pre-payload metadata negotiation with dual attestation signatures</t>
        <t>File-level Cryptographic Execution Manifests (CEM)</t>
        <t>Per-chunk Merkle tree integrity without requiring full-file arrival</t>
        <t>Protocol-native static behavioral analysis of received files</t>
        <t>A 7-Level non-repudiation signature chain</t>
        <t>Trust-preserving session resumption after transport disconnection</t>
      </list></t>
      <t>
        ZTOP does NOT replace TCP, IP, TLS, or QUIC. It operates within
        a TLS 1.3 tunnel and defines how endpoints behave before, during,
        and after a file transfer.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Conventions and Definitions" anchor="conventions">
      <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>The following terms are used in this document:</t>
      <t><list style="hanging">
        <t hangText="Peer ID:">
          A cryptographically derived, hardware-bound identifier for a ZTOP
          endpoint. Represented as Base58(SHA3-256(Ed25519PublicKey)).
        </t>
        <t hangText="Gateway:">
          A ZTOP server that enforces policy and trust evaluation on behalf
          of an organization.
        </t>
        <t hangText="Trust Score:">
          A value from 0 to 100 representing a device's computed security
          posture at a point in time.
        </t>
        <t hangText="CEM:">
          Cryptographic Execution Manifest. A 380-byte signed header
          permanently bound to every ZTOP-transferred file.
        </t>
        <t hangText="Session Certificate:">
          A short-lived (12-hour) X.509 certificate issued by the Gateway,
          binding a device's identity and trust score to an active session.
        </t>
        <t hangText="Merkle Root:">
          The root hash of a binary SHA-256 Merkle tree constructed over
          all file chunks.
        </t>
        <t hangText="Signature Chain:">
          A sequence of seven Ed25519 signatures constituting cryptographic
          non-repudiation of a complete transfer.
        </t>
        <t hangText="Heartbeat:">
          A 16-field signed packet sent every 10 seconds by the Client to
          continuously attest its identity and network context.
        </t>
        <t hangText="TRS:">
          Tamper Resistance Score. A 100-point composite score evaluated
          across six security dimensions.
        </t>
      </list></t>
    </section>

    <!-- ============================================================ -->
    <section title="Protocol Architecture" anchor="architecture">

      <section title="OSI Layer Position" anchor="osi">
        <t>
          ZTOP is an Application Layer (OSI Layer 7) protocol. It MUST
          operate within an encrypted transport tunnel. Implementations
          MUST support TLS 1.3 <xref target="RFC8446"/> as the transport.
          Implementations MAY additionally support QUIC <xref target="RFC9000"/>.
        </t>
        <figure align="center" anchor="fig-osi" title="ZTOP OSI Layer Position">
          <artwork><![CDATA[
+------------------------------------------------------------+
|  Layer 7 - APPLICATION                                     |
|  +---------------------------------------------------------+|
|  |                  ZTOP PROTOCOL                          ||
|  |  TrustEngine  PolicyEngine  CertEngine  MerkleEngine   ||
|  |  CEMEngine  HeartbeatEngine  ExecutionAnalyzer          ||
|  |  SignatureChainEngine  ReconnectManager  AuditEngine    ||
|  +---------------------------------------------------------+|
+------------------------------------------------------------+
|  Layer 6 - PRESENTATION                                    |
|  TLS 1.3 Record Layer (AES-256-GCM / ChaCha20-Poly1305)   |
+------------------------------------------------------------+
|  Layer 5 - SESSION                                         |
|  TLS Session + ZTOP Session State Machine                  |
+------------------------------------------------------------+
|  Layer 4 - TRANSPORT                                       |
|  TCP (Port 7890)                                           |
+------------------------------------------------------------+
|  Layers 1-3 - NETWORK / DATA LINK / PHYSICAL               |
|  IPv4 / IPv6 / Ethernet / Wi-Fi                            |
+------------------------------------------------------------+
          ]]></artwork>
        </figure>
      </section>

      <section title="Engine Components" anchor="engines">
        <t>
          ZTOP consists of fifteen logical engines. Each engine MUST be
          instantiated per active session on the Gateway. Table 1 lists
          all components.
        </t>
        <texttable anchor="tab-engines" title="ZTOP Engine Stack (Per-Session)">
          <ttcol>Engine</ttcol><ttcol>Responsibility</ttcol>
          <c>PeerIDEngine</c><c>Derive and validate cryptographic Peer IDs</c>
          <c>CertStore</c><c>Maintain root CA, org CAs, and device cert chains</c>
          <c>CertEngine</c><c>Issue Session and Transfer Receipt X.509 certs</c>
          <c>TrustEngine</c><c>Score device posture (0-100 points)</c>
          <c>TamperScoreEngine</c><c>Compute 100-pt Adaptive Tamper Resistance Score</c>
          <c>PolicyEngine</c><c>Evaluate six organizational transfer rules</c>
          <c>HeartbeatEngine</c><c>Validate 16-field signed attestation packets</c>
          <c>MerkleEngine</c><c>Build Merkle trees and verify per-chunk proofs</c>
          <c>CEMEngine</c><c>Deserialize and verify Cryptographic Execution Manifests</c>
          <c>MetadataEngine</c><c>Execute 9-step pre-transfer metadata validation</c>
          <c>ExecutionAnalyzer</c><c>Perform static behavioral analysis of files</c>
          <c>SignatureChainEngine</c><c>Build and verify 7-level non-repudiation chain</c>
          <c>ReconnectManager</c><c>Cache session state for trust-preserving reconnect</c>
          <c>IntegrityEngine</c><c>Compute and verify SHA-256/SHA3-512 file hashes</c>
          <c>AuditEngine</c><c>Produce sealed ECDSA-signed audit records</c>
        </texttable>
      </section>
    </section>

    <!-- ============================================================ -->
    <section title="Wire Format" anchor="wire">

      <section title="Frame Structure" anchor="frame">
        <t>
          All ZTOP messages SHALL be encoded as frames in Network Byte Order
          (Big-Endian). Every frame consists of three fixed headers, a
          variable TLV payload, raw payload data, and two mandatory footers.
        </t>
        <figure anchor="fig-frame" title="ZTOP Frame Layout (minimum 166 bytes)">
          <artwork><![CDATA[
+------------------------------------------------+
|        PROTOCOL HEADER (38 bytes, fixed)        |
+------+-------+----------+----------+------------+
|Magic |Version| MsgType  |  Flags   | Sequence # |
| "ZT" | 0x01  | (1 byte) | (2 bytes)| (4 bytes)  |
+------+-------+----------+----------+------------+
| Timestamp (8 bytes, uint64, microseconds)       |
+-------------------------------------------------+
| Session ID (16 bytes, UUID v4)                  |
+-------------------------------------------------+
| Payload Length (4 bytes, uint32)                |
+-------------------------------------------------+
|        SECURITY HEADER (48 bytes, fixed)         |
+-------------------------------------------------+
| Nonce (12 bytes, cryptographically random)      |
+-------------------------------------------------+
| Transfer ID (16 bytes, UUID v4)                 |
+-------------------+-----------+--------+--------+
|Policy Version (4) |Trust Score|Enc Suite|Rsvd(8)|
+-------------------+-----------+--------+--------+
|        ROUTING HEADER (16 bytes, fixed)          |
+-------------------------------------------------+
| Device ID Hash (8 bytes, truncated SHA-256)     |
+-----------------------+------+------+-----------+
| Org ID Hash (4, CRC32)|Prio  |Comp  |Ext Count  |
+-----------------------+------+------+-----------+
|        PAYLOAD HEADER (variable, TLV)            |
| [Type(2)|Length(2)|Value(N)] x ExtCount          |
+-------------------------------------------------+
|        RAW PAYLOAD DATA (variable)               |
+-------------------------------------------------+
|        INTEGRITY FOOTER (32 bytes)               |
| SHA-256(all preceding bytes)                    |
+-------------------------------------------------+
|        AUTH FOOTER (32 bytes)                    |
| HMAC-SHA256(session_key, body || integrity)     |
+-------------------------------------------------+
|        SIGNATURE FOOTER (96 bytes, conditional)  |
| ECDSA-P384 (present only when SIGNED flag set)  |
+-------------------------------------------------+
          ]]></artwork>
        </figure>
      </section>

      <section title="Flags Field" anchor="flags">
        <t>
          The 2-byte Flags field encodes eight independent Zero Trust
          control signals as a bitmask:
        </t>
        <texttable anchor="tab-flags" title="ZTOP Flags Field Bitmask">
          <ttcol>Value</ttcol><ttcol>Name</ttcol><ttcol>Zero Trust Role</ttcol>
          <c>0x0001</c><c>PAYLOAD_ENCRYPTED</c><c>Data frames without this MUST be rejected</c>
          <c>0x0002</c><c>PAYLOAD_COMPRESSED</c><c>Payload uses codec from Routing Header</c>
          <c>0x0004</c><c>REQUIRES_ACK</c><c>Receiver MUST acknowledge this frame</c>
          <c>0x0008</c><c>PRIORITY_BOOST</c><c>Gateway processes before standard frames</c>
          <c>0x0010</c><c>SIGNED</c><c>96-byte ECDSA-P384 footer is appended</c>
          <c>0x0020</c><c>LAST_CHUNK</c><c>Final chunk of an active transfer</c>
          <c>0x0040</c><c>RECOVERY_MODE</c><c>Frame is part of a reconnect handshake</c>
          <c>0x0080</c><c>HEARTBEAT_EXPECTED</c><c>Sender mandates Heartbeat from receiver</c>
        </texttable>
        <t>
          A receiver that observes a TRANSFER_CHUNK packet without
          PAYLOAD_ENCRYPTED set MUST reject the packet with error code
          ENCRYPTION_REQUIRED and MAY terminate the session.
        </t>
      </section>

      <section title="TLV Encoding" anchor="tlv">
        <t>
          All metadata fields are carried as Type-Length-Value (TLV) records.
          Each TLV consists of a 2-byte unsigned integer type, a 2-byte
          unsigned integer length, and a value field of that many bytes.
          All fields are Big-Endian encoded.
        </t>
        <t>
          An implementation receiving an unknown mandatory TLV type (codes
          0x0000-0x7FFF) MUST return an ERROR packet and close the session.
          An implementation receiving an unknown optional TLV type (codes
          0x8000-0xFFFF) MUST silently ignore it.
        </t>
      </section>

      <section title="Message OpCode Table" anchor="opcodes">
        <texttable anchor="tab-opcodes" title="ZTOP Message OpCodes">
          <ttcol>OpCode</ttcol><ttcol>Message Name</ttcol><ttcol>Direction</ttcol>
          <c>0x01</c><c>HELLO</c><c>Client to Server</c>
          <c>0x02</c><c>DISCOVER</c><c>Server to Client</c>
          <c>0x03</c><c>REGISTER</c><c>Client to Server</c>
          <c>0x04</c><c>IDENTITY_REQUEST</c><c>Server to Client</c>
          <c>0x05</c><c>IDENTITY_RESPONSE</c><c>Client to Server</c>
          <c>0x06</c><c>TRUST_REQUEST</c><c>Client to Server</c>
          <c>0x07</c><c>TRUST_RESPONSE</c><c>Server to Client</c>
          <c>0x08</c><c>POLICY_REQUEST</c><c>Client to Server</c>
          <c>0x09</c><c>POLICY_RESPONSE</c><c>Server to Client</c>
          <c>0x0A</c><c>CAPABILITY_NEGOTIATE</c><c>Both</c>
          <c>0x0B</c><c>SESSION_CREATE</c><c>Client to Server</c>
          <c>0x0C</c><c>SESSION_ACCEPT</c><c>Server to Client</c>
          <c>0x0E</c><c>SESSION_RECOVER</c><c>Client to Server</c>
          <c>0x0F</c><c>SESSION_CLOSE</c><c>Either</c>
          <c>0x10</c><c>HEARTBEAT</c><c>Client to Server</c>
          <c>0x20</c><c>TRANSFER_REQUEST</c><c>Client to Server</c>
          <c>0x21</c><c>TRANSFER_START</c><c>Server to Client</c>
          <c>0x22</c><c>TRANSFER_CHUNK</c><c>Client to Server</c>
          <c>0x23</c><c>TRANSFER_ACK</c><c>Server to Client</c>
          <c>0x27</c><c>TRANSFER_COMPLETE</c><c>Client to Server</c>
          <c>0x28</c><c>TRANSFER_REJECT_CHUNK</c><c>Server to Client</c>
          <c>0x33</c><c>AUDIT_COMMIT</c><c>Server to Client</c>
          <c>0xFF</c><c>ERROR</c><c>Either</c>
        </texttable>
      </section>
    </section>

    <!-- ============================================================ -->
    <section title="Session State Machine" anchor="states">
      <t>
        A ZTOP session MUST traverse the following states in order. Backward
        transitions are NOT permitted except as noted for the RECOVERING state.
        A Gateway MUST reject any message whose implied state transition is not
        permitted, and MUST respond with an ERROR packet containing code
        SESSION_STATE_INVALID.
      </t>
      <figure anchor="fig-states" title="ZTOP Session State Machine">
        <artwork><![CDATA[
 [INIT]
   | <- HELLO received, magic 0x5A54 validated
   v
 [DISCOVERY]
   | <- REGISTER received, Peer ID parsed
   v
 [REGISTERED]
   | <- Ed25519 identity challenge signed and verified
   v
 [IDENTITY_VERIFIED]
   | <- Device posture submitted, Trust Score >= threshold
   v
 [DEVICE_TRUSTED]
   | <- PolicyEngine returns permitted=True (all 6 checks)
   v
 [POLICY_APPROVED]
   | <- Session Certificate issued, capabilities negotiated
   v
 [SESSION_ACTIVE] <------------------------------------+
   | <- Transport disconnection detected              |
   v                                                  |
 [RECOVERING] -- Peer ID re-validated via HB ----------+
   | (7 retries exhausted)
   v
 [FAILED] (terminal) | [TERMINATED] (terminal)
        ]]></artwork>
      </figure>
    </section>

    <!-- ============================================================ -->
    <section title="Cryptographic Peer Identity" anchor="peerid">
      <t>
        Every ZTOP endpoint MUST derive a Peer ID using the following
        algorithm. Implementations MUST NOT use Fibonacci sequences or
        other deterministic mathematical sequences for Peer ID derivation
        or any cryptographic key generation.
      </t>
      <figure anchor="fig-peerid" title="Peer ID Derivation Algorithm">
        <artwork><![CDATA[
Input:
  device_uuid      : Hardware device UUID string
  cpu_hash         : SHA-256(CPU model string), hex
  os_hash          : SHA-256(OS version string), hex
  motherboard_hash : SHA-256(board identifier), hex
  network_sig      : Ed25519 signature over current IP:Port
  policy_version   : Active org policy version (integer)
  salt             : os.urandom(32)  [fresh each derivation]

Step 1 - Canonical Encoding (UTF-8):
  IKM_input = "uuid={device_uuid}|cpu={cpu_hash}|
               os={os_hash}|mb={motherboard_hash}|
               policy={policy_version}|netsig={netsig.hex()}"

Step 2 - SHA3-512 (Immutable Keying Material):
  ikm = SHA3-512(IKM_input)          [64 bytes]

Step 3 - HKDF-SHA512 [RFC5869]:
  seed = HKDF-SHA512(
      ikm    = ikm,
      salt   = salt,
      info   = b"ZTOP-PeerID-v1",
      length = 32
  )

Step 4 - Ed25519 Keypair [RFC8032]:
  private_key = Ed25519PrivateKey.from_private_bytes(seed)
  public_key  = private_key.public_key()
  pub_raw     = public_key.raw_bytes()       [32 bytes]

Step 5 - Peer ID Encoding:
  peer_id = "ZTOP-" || Base58(SHA3-256(pub_raw))
        ]]></artwork>
      </figure>
      <t>
        The salt MUST be stored in hardware-backed secure storage (TPM 2.0
        or TEE) and MUST NOT be transmitted over the network.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Certificate Architecture" anchor="certs">
      <t>
        ZTOP implements a five-layer X.509 <xref target="RFC5280"/>
        certificate hierarchy. All certificates use ECDSA-P384 or Ed25519.
        The five layers are: Root CA (10 years), Org CA (1 year), Device
        Certificate (30 days), Session Certificate (12 hours), and Transfer
        Receipt Certificate (1 year).
      </t>
      <t>
        Session Certificates MUST embed the following custom OID extensions:
      </t>
      <texttable anchor="tab-oids" title="ZTOP Custom X.509 OID Extensions">
        <ttcol>OID</ttcol><ttcol>Name</ttcol><ttcol>Present In</ttcol>
        <c>1.3.6.1.4.1.99999.1</c><c>ZTOP-DeviceID</c><c>Device Certificate</c>
        <c>1.3.6.1.4.1.99999.2</c><c>ZTOP-SessionID</c><c>Session Certificate</c>
        <c>1.3.6.1.4.1.99999.3</c><c>ZTOP-TrustScore</c><c>Session Certificate</c>
        <c>1.3.6.1.4.1.99999.4</c><c>ZTOP-PolicyVersion</c><c>Session Certificate</c>
        <c>1.3.6.1.4.1.99999.6</c><c>ZTOP-NetworkInfo</c><c>Session Certificate</c>
        <c>1.3.6.1.4.1.99999.7</c><c>ZTOP-PostureHash</c><c>Device Certificate</c>
        <c>1.3.6.1.4.1.99999.8</c><c>ZTOP-TransferID</c><c>Receipt Certificate</c>
        <c>1.3.6.1.4.1.99999.9</c><c>ZTOP-FileHash</c><c>Receipt Certificate</c>
      </texttable>
    </section>

    <!-- ============================================================ -->
    <section title="Trust Evaluation" anchor="trust">
      <section title="Device Posture Scoring" anchor="posture">
        <t>
          The Client MUST submit a PostureData record. The TrustEngine
          assigns weighted scores summing to a maximum of 100. The default
          threshold is 70; implementations MAY configure a higher value.
          A Gateway MUST terminate any session where the score falls
          below the configured threshold.
        </t>
        <texttable anchor="tab-trust" title="Trust Score Weights">
          <ttcol>Signal</ttcol><ttcol>Weight</ttcol><ttcol>Condition</ttcol>
          <c>EDR Active</c><c>+30</c><c>Endpoint Detection and Response running</c>
          <c>TPM Attested</c><c>+20</c><c>Hardware TPM 2.0 attestation present</c>
          <c>Firewall Active</c><c>+15</c><c>Host-based firewall enabled</c>
          <c>OS Version Current</c><c>+15</c><c>OS major version at or above 10</c>
          <c>Patch Level Fresh</c><c>+10</c><c>Last patch applied within 30 days</c>
          <c>VPN Connected</c><c>+5</c><c>Network posture includes VPN</c>
          <c>Antivirus OK</c><c>+5</c><c>AV status is OK or ACTIVE</c>
        </texttable>
      </section>

      <section title="Adaptive Tamper Resistance Score" anchor="trs">
        <t>
          The TamperScoreEngine computes a 100-point composite score across
          six security dimensions. A Gateway MUST re-evaluate this score at
          every Heartbeat interval and after every chunk transfer event.
        </t>
        <texttable anchor="tab-trs" title="Tamper Resistance Score Dimensions">
          <ttcol>Dimension</ttcol><ttcol>Max Points</ttcol><ttcol>Signals</ttcol>
          <c>Device Posture</c><c>20</c><c>OS patch, EDR, Firewall, TPM, Disk Encryption</c>
          <c>Certificate</c><c>20</c><c>Chain validity, Expiry, OCSP, Pinning</c>
          <c>Heartbeat</c><c>15</c><c>Consecutive successes, Latency quality</c>
          <c>Policy Compliance</c><c>15</c><c>Version current, org rules, DLP checked</c>
          <c>File Integrity</c><c>20</c><c>Merkle root match, chunk success, CEM sig</c>
          <c>Network Signature</c><c>10</c><c>VPN, Geo-fence, IP reputation</c>
        </texttable>
        <t>
          Trust bands and required Gateway actions:
        </t>
        <texttable anchor="tab-bands" title="Trust Bands">
          <ttcol>Score Range</ttcol><ttcol>Band</ttcol><ttcol>Required Action</ttcol>
          <c>95-100</c><c>TRUSTED</c><c>Permit full transfer</c>
          <c>80-94</c><c>LIMITED</c><c>Permit with enhanced audit logging</c>
          <c>60-79</c><c>RESTRICTED</c><c>Permit only via proxied analysis</c>
          <c>0-59</c><c>DISCONNECT</c><c>MUST terminate session immediately</c>
        </texttable>
      </section>
    </section>

    <!-- ============================================================ -->
    <section title="Heartbeat Protocol" anchor="heartbeat">
      <t>
        A Client MUST send a signed Heartbeat packet every 10 seconds
        while a session is in SESSION_ACTIVE or RECOVERING state. The
        Heartbeat packet MUST contain 16 fields including: peer_id,
        counter (monotonic), timestamp (microseconds), device_uuid,
        cert_fingerprint (SHA-256 of active session cert DER),
        current_ip, mac_hash (SHA-256 of MAC address), port,
        network_signature (Ed25519 over IP:Port), policy_version,
        session_token (SHA-256 of session_id), cpu_arch_hash,
        os_version_hash, nonce (16 random bytes), and a digital_signature
        (Ed25519 over all preceding 14 fields).
      </t>
      <t>
        A Gateway MUST validate each Heartbeat through eight sequential
        checks: nonce uniqueness, timestamp freshness (30 second tolerance),
        policy version match, IP consistency, digital signature verification,
        certificate fingerprint match, counter monotonicity, and session
        token match.
      </t>
      <t>
        Consecutive failures drive the session through the following states:
        0-2 failures = HEALTHY; 3-4 failures = WARNING; 5+ failures = SLEEP
        with backoff delays of [2, 5, 10, 30, 60, 120, 300] seconds.
        After 7 failed retry attempts, the session MUST enter FAILED state.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Cryptographic Execution Manifest" anchor="cem">
      <t>
        Every file transferred via ZTOP MUST be prepended with a 380-byte
        Cryptographic Execution Manifest (CEM). The CEM gives the file a
        permanent cryptographic identity independent of the transport channel.
      </t>
      <figure anchor="fig-cem" title="CEM Wire Format (380 bytes total)">
        <artwork><![CDATA[
Offset  Size  Field
------  ----  -------------------------------------------------
0       8     Magic: ASCII "ZTOP-CEM" (0x5A544F502D43454D)
8       16    File UUID (UUID v4 bytes)
24      32    File Hash (SHA-256 of raw file data)
56      32    Merkle Root (binary Merkle tree root hash)
88      8     Creation Timestamp (uint64, microseconds)
96      2     Version (uint16, currently 0x0001)
98      64    Sender Peer ID (null-padded UTF-8)
162     64    Receiver Peer ID (null-padded UTF-8)
226     32    Certificate Fingerprint (SHA-256 of sender cert)
258     16    Security Policy ID (null-padded UTF-8)
274     4     Execution Policy Flags (uint32 bitmask)
278     32    Allowed Receiver Hash (SHA-256(receiver_peer_id))
310     6     Reserved (zeros)
316     64    Digital Signature (Ed25519 over bytes 8 to 315)
------  ----
Total:  380 bytes
        ]]></artwork>
      </figure>
      <t>
        Execution Policy Flags: 0x0001=ALLOW_EXEC, 0x0002=SANDBOX_ONLY,
        0x0004=NO_NETWORK, 0x0008=NO_SUBPROCESS, 0x0010=IMMUTABLE,
        0x0020=AUDIT_ON_EXEC.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Chunk-Level Integrity" anchor="merkle">
      <t>
        Files are split into chunks of the negotiated chunk_size. A binary
        SHA-256 Merkle tree is constructed bottom-up. When the number of
        chunks is odd, the last leaf MUST be duplicated to form its parent.
      </t>
      <t>
        Each TRANSFER_CHUNK packet MUST include: chunk_id, sequence number,
        byte offset, length, SHA-256 chunk_hash, session_id, per-chunk nonce,
        Merkle proof (sibling hashes bottom-up), and raw chunk data.
      </t>
      <t>
        A Gateway MUST immediately verify each chunk upon receipt.
        Verification MUST include: SHA-256(received_data) equals chunk_hash;
        the Merkle proof ascent from chunk_hash reaches the pre-agreed
        Merkle Root; the sequence number is greater than the last accepted;
        and the nonce is not in the seen_nonces cache.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Pre-Execution Static Analysis" anchor="analysis">
      <t>
        After complete file reassembly and before issuing AUDIT_COMMIT,
        the Gateway MUST perform static behavioral analysis. The Gateway
        MUST NOT deliver the file to destination storage until this
        analysis completes.
      </t>
      <t>
        The analysis pipeline MUST include: Shannon entropy computation
        over the first 64 KB (entropy above 7.5 indicates packing or
        encryption, adding 20 risk points); for PE files, scanning for
        dangerous API imports including CreateProcess, VirtualAlloc,
        WriteProcessMemory, and CreateRemoteThread (each adding 8 risk
        points, maximum 50); for ELF files, scanning for dangerous syscall
        strings including execve, ptrace, and mprotect (each adding 6 risk
        points, maximum 40); for Python files, regex matching against
        dangerous import and call patterns (each adding 5 to 10 risk points,
        maximum 40).
      </t>
      <t>
        The final risk_score is min(sum, 100). A score of 60 or higher
        MUST result in MALICIOUS verdict: the file buffer MUST be wiped
        and the transfer MUST be aborted. A score of 25 or higher results
        in SUSPICIOUS verdict and MUST be logged. A score below 25 results
        in CLEAN verdict and the transfer proceeds to the Signature Chain.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="7-Level Signature Chain" anchor="sigchain">
      <t>
        A transfer is marked SYNC_COMPLETE only when seven independent
        Ed25519 signatures are present and verified. The seven levels are:
        L1 (File Hash, Sender key), L2 (Merkle Root, Sender key),
        L3 (Metadata hash, Sender key), L4 (Sender Completion Assertion,
        Sender key), L5 (Receiver Acceptance Assertion, Receiver key),
        L6 (Session Digest over L1-L5, Session key), L7 (Gateway Completion
        Seal, Gateway key).
      </t>
      <t>
        An AUDIT_COMMIT MUST NOT be issued until all seven signatures pass
        verification. Failure of any level MUST result in transfer rejection.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Trust-Preserving Reconnection" anchor="reconnect">
      <t>
        If a transport disconnection occurs during an active transfer, the
        Gateway MUST save the session state to a persistent ReconnectCache
        keyed by Session ID. Cache entries MUST expire after 3600 seconds.
      </t>
      <t>
        Upon reconnection with RECOVERY_MODE flag set, the Client presents
        its cached session_key_id. The Gateway performs a fresh Heartbeat
        challenge. If the challenge passes and a valid cache entry exists,
        the transfer resumes from the last verified chunk without repeating
        the full handshake. The retry backoff schedule MUST be [2, 5, 10,
        30, 60, 120, 300] seconds. After 7 failed attempts, a full new
        handshake is REQUIRED.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="Security Considerations" anchor="security">
      <t>
        ZTOP assumes the adversary has full network access including the
        ability to observe, inject, delay, and replay packets, but does
        NOT have access to TLS session keys or endpoints' Ed25519 private
        keys.
      </t>
      <t>
        All ZTOP packets include a 12-byte Nonce field. Receivers MUST
        maintain a nonce cache with a TTL of 300 seconds. Any packet whose
        nonce is found in the cache MUST be rejected. All packets include a
        Timestamp field. Receivers MUST reject packets with a timestamp
        deviation greater than 300 seconds from local time.
      </t>
      <t>
        The 12-hour Session Certificate TTL limits the impact of key
        compromise. In the event of Org CA key compromise, the Gateway MUST
        immediately revoke all issued certificates and MUST NOT accept new
        session connections until new CA material is provisioned.
        Implementations SHOULD implement OCSP stapling <xref target="RFC6960"/>
        for real-time revocation checking.
      </t>
      <t>
        ZTOP MUST operate within a TLS 1.3 tunnel <xref target="RFC8446"/>.
        Implementations MUST NOT support TLS versions earlier than 1.3.
      </t>
      <t>
        The current specification uses Ed25519 <xref target="RFC8032"/> and
        ECDSA-P384 for digital signatures. These algorithms are not resistant
        to quantum computing attacks. Future versions of this specification
        SHOULD incorporate NIST-standardized post-quantum algorithms
        <xref target="NIST.FIPS.204"/> <xref target="NIST.FIPS.203"/> as
        they become widely deployed.
      </t>
    </section>

    <!-- ============================================================ -->
    <section title="IANA Considerations" anchor="iana">
      <t>
        IANA is requested to assign the following port number:
      </t>
      <t><list style="hanging">
        <t hangText="Service Name:">ztop</t>
        <t hangText="Port Number:">7890</t>
        <t hangText="Transport Protocol:">TCP</t>
        <t hangText="Description:">Zero Trust Transfer Orchestration Protocol</t>
        <t hangText="Reference:">This document</t>
      </list></t>
      <t>
        IANA is requested to create a new registry "ZTOP OpCodes" with the
        initial assignments from Section 4.4. New entries require Standards
        Action <xref target="RFC8126"/>.
      </t>
      <t>
        IANA is requested to create a new registry "ZTOP TLV Types" with
        range 0x0000-0x7FFF (Standards Action) and 0x8000-0xFFFF (First
        Come First Served).
      </t>
      <t>
        IANA is requested to register the custom X.509 OIDs listed in
        Section 7. Interim assignments under 1.3.6.1.4.1.99999 SHALL be
        replaced upon formal assignment.
      </t>
    </section>

  </middle>

  <back>
    <references title="Normative References">
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author initials="S." surname="Bradner" fullname="S. Bradner"/>
          <date month="March" year="1997"/>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author initials="B." surname="Leiba" fullname="B. Leiba"/>
          <date month="May" year="2017"/>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
      </reference>
      <reference anchor="RFC8446">
        <front>
          <title>The Transport Layer Security (TLS) Protocol Version 1.3</title>
          <author initials="E." surname="Rescorla" fullname="E. Rescorla"/>
          <date month="August" year="2018"/>
        </front>
        <seriesInfo name="RFC" value="8446"/>
      </reference>
      <reference anchor="RFC8032">
        <front>
          <title>Edwards-Curve Digital Signature Algorithm (EdDSA)</title>
          <author initials="S." surname="Josefsson"/>
          <author initials="I." surname="Liusvaara"/>
          <date month="January" year="2017"/>
        </front>
        <seriesInfo name="RFC" value="8032"/>
      </reference>
      <reference anchor="RFC5869">
        <front>
          <title>HMAC-based Extract-and-Expand Key Derivation Function (HKDF)</title>
          <author initials="H." surname="Krawczyk"/>
          <author initials="P." surname="Eronen"/>
          <date month="May" year="2010"/>
        </front>
        <seriesInfo name="RFC" value="5869"/>
      </reference>
      <reference anchor="RFC5280">
        <front>
          <title>Internet X.509 Public Key Infrastructure Certificate and CRL Profile</title>
          <author initials="D." surname="Cooper"/>
          <date month="May" year="2008"/>
        </front>
        <seriesInfo name="RFC" value="5280"/>
      </reference>
      <reference anchor="RFC4122">
        <front>
          <title>A Universally Unique IDentifier (UUID) URN Namespace</title>
          <author initials="P." surname="Leach"/>
          <date month="July" year="2005"/>
        </front>
        <seriesInfo name="RFC" value="4122"/>
      </reference>
      <reference anchor="RFC2104">
        <front>
          <title>HMAC: Keyed-Hashing for Message Authentication</title>
          <author initials="H." surname="Krawczyk"/>
          <date month="February" year="1997"/>
        </front>
        <seriesInfo name="RFC" value="2104"/>
      </reference>
      <reference anchor="RFC8126">
        <front>
          <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
          <author initials="M." surname="Cotton"/>
          <date month="June" year="2017"/>
        </front>
        <seriesInfo name="RFC" value="8126"/>
      </reference>
      <reference anchor="RFC6960">
        <front>
          <title>X.509 Internet Public Key Infrastructure Online Certificate Status Protocol</title>
          <author initials="S." surname="Santesson"/>
          <date month="June" year="2013"/>
        </front>
        <seriesInfo name="RFC" value="6960"/>
      </reference>
    </references>

    <references title="Informative References">
      <reference anchor="RFC9000">
        <front>
          <title>QUIC: A UDP-Based Multiplexed and Secure Transport</title>
          <author initials="J." surname="Iyengar"/>
          <author initials="M." surname="Thomson"/>
          <date month="May" year="2021"/>
        </front>
        <seriesInfo name="RFC" value="9000"/>
      </reference>
      <reference anchor="RFC4253">
        <front>
          <title>The Secure Shell (SSH) Transport Layer Protocol</title>
          <author initials="T." surname="Ylonen"/>
          <date month="January" year="2006"/>
        </front>
        <seriesInfo name="RFC" value="4253"/>
      </reference>
      <reference anchor="RFC959">
        <front>
          <title>File Transfer Protocol</title>
          <author initials="J." surname="Postel"/>
          <date month="October" year="1985"/>
        </front>
        <seriesInfo name="RFC" value="959"/>
      </reference>
      <reference anchor="RFC7296">
        <front>
          <title>Internet Key Exchange Protocol Version 2 (IKEv2)</title>
          <author initials="C." surname="Kaufman"/>
          <date month="October" year="2014"/>
        </front>
        <seriesInfo name="RFC" value="7296"/>
      </reference>
      <reference anchor="NIST.FIPS.203">
        <front>
          <title>Module-Lattice-Based Key-Encapsulation Mechanism Standard</title>
          <author><organization>NIST</organization></author>
          <date month="August" year="2024"/>
        </front>
        <seriesInfo name="FIPS PUB" value="203"/>
      </reference>
      <reference anchor="NIST.FIPS.204">
        <front>
          <title>Module-Lattice-Based Digital Signature Standard</title>
          <author><organization>NIST</organization></author>
          <date month="August" year="2024"/>
        </front>
        <seriesInfo name="FIPS PUB" value="204"/>
      </reference>
    </references>

    <section title="Acknowledgements" anchor="ack">
      <t>
        The authors acknowledge the foundational work of the IETF TLS
        Working Group, the COSE Working Group, and the broader Zero Trust
        research community whose contributions made this work possible.
      </t>
    </section>

  </back>
</rfc>