{
  "$schema": "frequency-native-transport-vectors/2",
  "transportVersion": 2,
  "acceptedVersions": [
    1,
    2
  ],
  "generator": "server/load-generator/src/nativeVectors.ts — npm run vectors:emit -w @frequency/load-generator",
  "description": "Known-answer vectors for native transport WIRE VERSION 2: audio sealed once under a per-talkspurt content key K_s, and K_s wrapped per carrying channel in FLAG_CONTENT_KEY key packets (packages/shared/src/nativeTransport.ts, NATIVE_TRANSPORT_WIRE_V2). Header layout, AAD, nonce and senderMac are v1's unchanged; read native-transport-v1.json first. All byte strings are lowercase hex, sequences are decimal strings. Every packet comes from the reference client's own seal(); nothing is hand-computed. The keys are test material with no secrecy value.",
  "constants": {
    "wireVersion2": 2,
    "flagContentKey": 32,
    "byte0": {
      "v2Audio": 2,
      "v2KeyPacket": 34
    },
    "payloadTypeContentKey": 2,
    "contentKeyPayload": {
      "TYPE_OFFSET": 0,
      "STREAM_ID_OFFSET": 1,
      "TIMESTAMP_OFFSET": 5,
      "CONTENT_KEY_ID_OFFSET": 9,
      "KEY_OFFSET": 13,
      "LENGTH": 45
    },
    "contentKeyGeneration": "contentKeyId & 0xff, carried in the v2 audio header's keyEpoch byte (offset 9)",
    "contentKeyCadence": {
      "FIRST_FRAMES": 5,
      "REPEAT_MS": 200
    },
    "streamSelection": "a v2 audio datagram's stream is (header connectionId, header channelId = the stream's home); after opening, the payload streamId MUST equal the streamId of the key packet that delivered the key"
  },
  "keys": {
    "channelA": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
    "channelB": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f",
    "share": "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f",
    "senderMac": "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f",
    "senderMacAlt": "a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf",
    "contentKey1": "c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf",
    "contentKey2": "e0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"
  },
  "positive": [
    {
      "name": "v2-key-packet-home",
      "kind": "keyPacket",
      "note": "The talkspurt's key wrapped under its HOME channel key (HOME_CHANNEL_WRAP_REQUIRED). The bridge holds the home key and no other, so this is how every browser, the HLS stream and the speaking badge hear a v2 sender. Byte 0 is 0x22 (FLAG_CONTENT_KEY | version 2); header channelId and keyEpoch are the WRAPPING channel's, exactly as v1 audio has them. Payload is 45 bytes: type 2, streamId, timestamp, contentKeyId 0x00000101, then K_s. 96 bytes on the wire.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 3,
        "sequence": "7000",
        "voiceLevel": 0,
        "channelKey": "channelA",
        "senderMacKey": "senderMac",
        "payload": "020000004d0000bb8000000101c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf",
        "versionFlags": 34,
        "key": "channelA"
      },
      "expected": {
        "packet": "22010203040000000703000000000000001b58dd411a0d12f8cbb331257a10ec0205730c101d7f4c18f5e0180bfc70615590da0daabdbe5cc5d2c9bcda13e7da7a2ae8f63911cd9834cdb43a7b420bd283acbb12c99207f75272500beca96c2e",
        "packetLength": 96,
        "aad": "22010203040000000703000000000000001b58",
        "nonce": "010203040000000000001b58",
        "senderMac": "dd411a0d12f8cbb331257a10ec020573",
        "ciphertext": "0c101d7f4c18f5e0180bfc70615590da0daabdbe5cc5d2c9bcda13e7da7a2ae8f63911cd9834cdb43a7b420bd2",
        "tag": "83acbb12c99207f75272500beca96c2e",
        "contentKey": {
          "streamId": 77,
          "contentKeyId": 257,
          "generation": 1,
          "key": "contentKey1"
        },
        "forwardedTo": "channel"
      }
    },
    {
      "name": "v2-key-packet-relay",
      "kind": "keyPacket",
      "note": "The SAME K_s wrapped under the relay channel's key. A listener matched on channel 9 receives this one and not the home one: authorization is v1's, because the key rides the route the audio used to.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 9,
        "keyEpoch": 3,
        "sequence": "7001",
        "voiceLevel": 0,
        "channelKey": "channelB",
        "senderMacKey": "senderMac",
        "payload": "020000004d0000bb8000000101c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf",
        "versionFlags": 34,
        "key": "channelB"
      },
      "expected": {
        "packet": "22010203040000000903000000000000001b5998331740bdd7d3e3e8c68609ff007dcf316ffa97afb232e5d323414566836b6460469db0b4de74ea5e3afda4eb13c760ddca63676494f49144d553fd27a33427ccdfcf283aa2bc6b3d7b853db9",
        "packetLength": 96,
        "aad": "22010203040000000903000000000000001b59",
        "nonce": "010203040000000000001b59",
        "senderMac": "98331740bdd7d3e3e8c68609ff007dcf",
        "ciphertext": "316ffa97afb232e5d323414566836b6460469db0b4de74ea5e3afda4eb13c760ddca63676494f49144d553fd27",
        "tag": "a33427ccdfcf283aa2bc6b3d7b853db9",
        "contentKey": {
          "streamId": 77,
          "contentKeyId": 257,
          "generation": 1,
          "key": "contentKey1"
        },
        "forwardedTo": "channel"
      }
    },
    {
      "name": "v2-audio",
      "kind": "audio",
      "note": "One frame, sealed ONCE under K_s whatever the carrying set. Byte 0 is 0x02 (version 2, no flags). Header channelId 7 is the stream's HOME, a routing anchor: a relay-only listener never holds channel 7's key and does not need it. Byte 9 is 0x01, the content-key generation (contentKeyId 0x00000101 & 0xff). The node forwards it to the sender's UNION. A receiver selects the key by (connectionId, home, generation) and then checks that the opened streamId (77) is the one the key packet named. Sequence 7002: audio and key packets share one sequence space, one per datagram.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 1,
        "sequence": "7002",
        "voiceLevel": 96,
        "channelKey": null,
        "senderMacKey": "senderMac",
        "payload": "000000004d0000bb80557493b2d1f00f2e4d6c8baac9e80726456483a2c1e0ff1e3d5c7b9ab9d8f71635547392b1d0ef0e",
        "versionFlags": 2,
        "key": "contentKey1"
      },
      "expected": {
        "packet": "02010203040000000701600000000000001b5ab819bd38729a1343bb2b04e7f7f9a961cb82bce8bd8003479e69c5d658de3db8621faa0aa1be4e277858c3fe96ddc8f2b254f286c2e154e75766aa9f8066099911d9c81f27ffee8589d07a9d41dcc78d87",
        "packetLength": 100,
        "aad": "02010203040000000701600000000000001b5a",
        "nonce": "010203040000000000001b5a",
        "senderMac": "b819bd38729a1343bb2b04e7f7f9a961",
        "ciphertext": "cb82bce8bd8003479e69c5d658de3db8621faa0aa1be4e277858c3fe96ddc8f2b254f286c2e154e75766aa9f8066099911",
        "tag": "d9c81f27ffee8589d07a9d41dcc78d87",
        "contentKey": null,
        "forwardedTo": "union"
      }
    },
    {
      "name": "v2-key-packet-rotated",
      "kind": "keyPacket",
      "note": "A ROTATION mid-talkspurt (relay-set shrink, a new stream, or a channel-key epoch change): a new contentKeyId (0x00000102, generation 2) and a new K_s, here re-wrapped to the home channel only because the relay was dropped. The receiver keeps generation 1 alongside it, the two-live rule channel epochs already use.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 3,
        "sequence": "7003",
        "voiceLevel": 0,
        "channelKey": "channelA",
        "senderMacKey": "senderMac",
        "payload": "020000004d0000bb8000000102e0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
        "versionFlags": 34,
        "key": "channelA"
      },
      "expected": {
        "packet": "22010203040000000703000000000000001b5ba5b08abf590bed12bd652b7676a0750eb7bd7057ca993a829619a59feea14ba603d7421037145b9788dd119b141df182ab851b823e0c318a109c090ae8b9ed90f2235d7e18bc6c4663f70aa2bc",
        "packetLength": 96,
        "aad": "22010203040000000703000000000000001b5b",
        "nonce": "010203040000000000001b5b",
        "senderMac": "a5b08abf590bed12bd652b7676a0750e",
        "ciphertext": "b7bd7057ca993a829619a59feea14ba603d7421037145b9788dd119b141df182ab851b823e0c318a109c090ae8",
        "tag": "b9ed90f2235d7e18bc6c4663f70aa2bc",
        "contentKey": {
          "streamId": 77,
          "contentKeyId": 258,
          "generation": 2,
          "key": "contentKey2"
        },
        "forwardedTo": "channel"
      }
    },
    {
      "name": "v2-audio-rotated",
      "kind": "audio",
      "note": "The next frame under generation 2. Byte 9 is 0x02.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 2,
        "sequence": "7004",
        "voiceLevel": 96,
        "channelKey": null,
        "senderMacKey": "senderMac",
        "payload": "000000004d0000bb80557493b2d1f00f2e4d6c8baac9e80726456483a2c1e0ff1e3d5c7b9ab9d8f71635547392b1d0ef0e",
        "versionFlags": 2,
        "key": "contentKey2"
      },
      "expected": {
        "packet": "02010203040000000702600000000000001b5cb3d78732e3d41da9a12666c9fbb727deb7c1373c4dbd612ab0e05b4857487a3123c4981dfbeb8909853aafdc9fd01c2b2a0927a84620d244b141119974e1f58bf18b6916582bff4d49f95cf01af361b9b0",
        "packetLength": 100,
        "aad": "02010203040000000702600000000000001b5c",
        "nonce": "010203040000000000001b5c",
        "senderMac": "b3d78732e3d41da9a12666c9fbb727de",
        "ciphertext": "b7c1373c4dbd612ab0e05b4857487a3123c4981dfbeb8909853aafdc9fd01c2b2a0927a84620d244b141119974e1f58bf1",
        "tag": "8b6916582bff4d49f95cf01af361b9b0",
        "contentKey": null,
        "forwardedTo": "union"
      }
    },
    {
      "name": "v2-audio-previous-generation-in-flight",
      "kind": "audio",
      "note": "A generation-1 frame that left the sender before the rotation and arrives after the generation-2 key packet. Byte 9 (0x01) is why it still opens: without a cleartext generation a receiver holding two keys would have to guess, and this frame would be a GCM failure indistinguishable from a forgery.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 1,
        "sequence": "7005",
        "voiceLevel": 64,
        "channelKey": null,
        "senderMacKey": "senderMac",
        "payload": "000000004d0000bb806685a4c3e201203f5e7d9cbbdaf91837567594b3d2f1102f4e6d8cabcae90827466584a3c2e1001f",
        "versionFlags": 2,
        "key": "contentKey1"
      },
      "expected": {
        "packet": "02010203040000000701400000000000001b5dabe1af36bd8526e350b6eb4a5b11e33e2402d02e4c8a47b4a0fec5ef00eeec6cf5316a08271a899d3e8a09976b4a74b34a1c17f8dd329ce9feb8782846b63587ac9b1024c8659ab69f340b03cf25f48a62",
        "packetLength": 100,
        "aad": "02010203040000000701400000000000001b5d",
        "nonce": "010203040000000000001b5d",
        "senderMac": "abe1af36bd8526e350b6eb4a5b11e33e",
        "ciphertext": "2402d02e4c8a47b4a0fec5ef00eeec6cf5316a08271a899d3e8a09976b4a74b34a1c17f8dd329ce9feb8782846b63587ac",
        "tag": "9b1024c8659ab69f340b03cf25f48a62",
        "contentKey": null,
        "forwardedTo": "union"
      }
    },
    {
      "name": "v2-key-packet-generation-is-low-byte",
      "kind": "keyPacket",
      "note": "contentKeyId 0xAABBCCFF: the generation is its LOW byte, 0xFF. A reader that takes the first byte of the big-endian u32 gets 0xAA and never finds the key. (Wrapped under the home key with contentKey2's bytes; the pairing below is what matters.)",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 3,
        "sequence": "7006",
        "voiceLevel": 0,
        "channelKey": "channelA",
        "senderMacKey": "senderMac",
        "payload": "020000004d0000bb80aabbccffe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
        "versionFlags": 34,
        "key": "channelA"
      },
      "expected": {
        "packet": "22010203040000000703000000000000001b5e98b3d61a5568182f677561372a394bd6f03cd2ecc463f4a3c3b13f0e43ca45ed026b8ee356341ee4a285d7d6f2ceaaa6aea6f8a494f7db3c4cf6417a2f20e22df5f033648f4e9b0f81f7aee272",
        "packetLength": 96,
        "aad": "22010203040000000703000000000000001b5e",
        "nonce": "010203040000000000001b5e",
        "senderMac": "98b3d61a5568182f677561372a394bd6",
        "ciphertext": "f03cd2ecc463f4a3c3b13f0e43ca45ed026b8ee356341ee4a285d7d6f2ceaaa6aea6f8a494f7db3c4cf6417a2f",
        "tag": "20e22df5f033648f4e9b0f81f7aee272",
        "contentKey": {
          "streamId": 77,
          "contentKeyId": 2864434431,
          "generation": 255,
          "key": "contentKey2"
        },
        "forwardedTo": "channel"
      }
    },
    {
      "name": "v2-audio-generation-ff",
      "kind": "audio",
      "note": "Audio under that key: byte 9 is 0xFF.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 255,
        "sequence": "7007",
        "voiceLevel": 96,
        "channelKey": null,
        "senderMacKey": "senderMac",
        "payload": "000000004d0000bb80557493b2d1f00f2e4d6c8baac9e80726456483a2c1e0ff1e3d5c7b9ab9d8f71635547392b1d0ef0e",
        "versionFlags": 2,
        "key": "contentKey2"
      },
      "expected": {
        "packet": "020102030400000007ff600000000000001b5fa8f69e7a036e4ec47ff6e7eacb4d40b03ada4bfbcd6f9936f2c203e977cc1623e4032a533b9c50b345ac94dba3acc3c9adc413beabd51192e8eb6c1cf9508b60436b95a301d49f6bb84cac5f58fd8e22a1",
        "packetLength": 100,
        "aad": "020102030400000007ff600000000000001b5f",
        "nonce": "010203040000000000001b5f",
        "senderMac": "a8f69e7a036e4ec47ff6e7eacb4d40b0",
        "ciphertext": "3ada4bfbcd6f9936f2c203e977cc1623e4032a533b9c50b345ac94dba3acc3c9adc413beabd51192e8eb6c1cf9508b6043",
        "tag": "6b95a301d49f6bb84cac5f58fd8e22a1",
        "contentKey": null,
        "forwardedTo": "union"
      }
    },
    {
      "name": "v1-audio-still-accepted",
      "kind": "v1Audio",
      "note": "native-transport-v1.json's audio-typical, byte for byte. A node that accepts version 2 accepts version 1 too, for as long as any v1 client exists; a v2 sender may also fall back to v1 whenever authOk.native.wireVersions does not list 2.",
      "input": {
        "connectionId": 16909060,
        "channelNativeId": 7,
        "keyEpoch": 3,
        "sequence": "1234",
        "voiceLevel": 96,
        "channelKey": "channelA",
        "senderMacKey": "senderMac",
        "payload": "000000002a000003c0557493b2d1f00f2e4d6c8baac9e80726456483a2c1e0ff1e3d5c7b9ab9d8f71635547392b1d0ef0e",
        "versionFlags": 1,
        "key": "channelA"
      },
      "expected": {
        "packet": "010102030400000007036000000000000004d2de1226f1fb0af1c389f7f26d8ae5764ad12e1b3a7927ab91b282375f247e5ba13a1a3399f33a325facb86a4bcfd9f58f98a93737265c1bf4d543bf6020a13d1b0370472c2580e2e0da09cfd307c295e3b0",
        "packetLength": 100,
        "aad": "010102030400000007036000000000000004d2",
        "nonce": "0102030400000000000004d2",
        "senderMac": "de1226f1fb0af1c389f7f26d8ae5764a",
        "ciphertext": "d12e1b3a7927ab91b282375f247e5ba13a1a3399f33a325facb86a4bcfd9f58f98a93737265c1bf4d543bf6020a13d1b03",
        "tag": "70472c2580e2e0da09cfd307c295e3b0",
        "contentKey": null,
        "forwardedTo": "channel"
      }
    }
  ],
  "negative": [
    {
      "name": "neg-v2-content-key-with-control",
      "note": "FLAG_CONTENT_KEY | FLAG_CONTROL on version 2 (0x32), MAC valid. Control packets stay version 1, and FLAG_CONTROL is not defined on version 2. Dropped on shape.",
      "packet": "32010203040000000703000000000000001b5855765c2635c3a2b82f402dee520aa1fb0c101d7f4c18f5e0180bfc70615590da0daabdbe5cc5d2c9bcda13e7da7a2ae8f63911cd9834cdb43a7b420bd283acbb12c99207f75272500beca96c2e",
      "senderMacKey": "senderMac",
      "expected": {
        "nodeAccepts": false,
        "receiverKey": "channelA",
        "opens": false,
        "rejectedBy": "shape"
      }
    },
    {
      "name": "neg-version-3",
      "note": "Version 3, MAC valid. Not a version this platform speaks; dropped on shape, so a future version is refused rather than misparsed.",
      "packet": "03010203040000000701600000000000001b5a519ac95ac0e9a5d30acd51981c192329cb82bce8bd8003479e69c5d658de3db8621faa0aa1be4e277858c3fe96ddc8f2b254f286c2e154e75766aa9f8066099911d9c81f27ffee8589d07a9d41dcc78d87",
      "senderMacKey": "senderMac",
      "expected": {
        "nodeAccepts": false,
        "receiverKey": "contentKey1",
        "opens": false,
        "rejectedBy": "shape"
      }
    },
    {
      "name": "neg-v2-on-share-id",
      "note": "A v2 audio datagram whose header channelId is SHARE_CHANNEL_ID, MAC valid. Screen share stays version 1 (its forward set is a share's viewers, and a v2 union would hand it to the voice listeners), so the node drops it on shape.",
      "packet": "0201020304ffffffff01600000000000001b5a82dbb60612b3e2536ef30864e9d0f637cb82bce8bd8003479e69c5d658de3db8621faa0aa1be4e277858c3fe96ddc8f2b254f286c2e154e75766aa9f8066099911d9c81f27ffee8589d07a9d41dcc78d87",
      "senderMacKey": "senderMac",
      "expected": {
        "nodeAccepts": false,
        "receiverKey": "contentKey1",
        "opens": false,
        "rejectedBy": "shape"
      }
    },
    {
      "name": "neg-v2-audio-under-the-channel-key",
      "note": "v2-audio, untouched, opened with the HOME CHANNEL key. The node accepts and forwards it (it cannot read either key's envelope), and it does not open: v2 audio is sealed under K_s. This is the receiver that ignores the flag and the version and keeps doing v1.",
      "packet": "02010203040000000701600000000000001b5ab819bd38729a1343bb2b04e7f7f9a961cb82bce8bd8003479e69c5d658de3db8621faa0aa1be4e277858c3fe96ddc8f2b254f286c2e154e75766aa9f8066099911d9c81f27ffee8589d07a9d41dcc78d87",
      "senderMacKey": "senderMac",
      "expected": {
        "nodeAccepts": true,
        "receiverKey": "channelA",
        "opens": false,
        "rejectedBy": "payloadAead"
      }
    },
    {
      "name": "neg-key-packet-flag-stripped",
      "note": "v2-key-packet-home with FLAG_CONTENT_KEY cleared and the MAC recomputed, so the node now reads it as v2 AUDIO and forwards it to the union. It opens under nothing: byte 0 is inside the AAD, so the channel key no longer opens it either. This is why the flag is authenticated rather than advisory: flipping it cannot steer a receiver to a key that works.",
      "packet": "02010203040000000703000000000000001b580f2f965b5c8e19a50defd5ed90134c620c101d7f4c18f5e0180bfc70615590da0daabdbe5cc5d2c9bcda13e7da7a2ae8f63911cd9834cdb43a7b420bd283acbb12c99207f75272500beca96c2e",
      "senderMacKey": "senderMac",
      "expected": {
        "nodeAccepts": true,
        "receiverKey": "channelA",
        "opens": false,
        "rejectedBy": "payloadAead"
      }
    }
  ]
}
