feat(versioning): snapshot corpus per spec version
A frozen spec is only meaningful if it's paired with the corpus that was current at release time — otherwise a v0.1.0 reader follows "see corpus/payloads/ack/" and lands on a file whose test vectors may have changed since v0.1.0 was cut. Three changes: 1. `cut-version` now copies BOTH src/ AND corpus/ into the snapshot directory. A release is the pair, not just the text. 2. The corpus URL rewriting in cut-version now retargets /tree/main/corpus -> /tree/main/versions/<v>/corpus (and the blob variant). This lets the link resolve on GitHub from main alone — no git tag required, since the frozen copy is a real path under main. Downgrades the "tag is REQUIRED" message from last commit back to "optionally tag the commit". 3. The frozen corpus's spec_ref fields get rewritten too: from `src/04-payload-ack.md` to `versions/<v>/04-payload-ack.md`, so a reader following a test vector lands on the spec text the vector was paired with at release time. versions/v0.1.0/ regenerated from scratch via `just cut-version v0.1.0` to pick up the corpus snapshot + the new sed patterns. The release is now self-consistent: v0.1.0 spec links go to v0.1.0 corpus, which links back to v0.1.0 spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
71 files changed
+5924
-28
No files matched your search
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "AES-128-ECB Block Padding",
|
||||
"spec_ref": "versions/v0.1.0/14-crypto.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Tests AES-128-ECB zero-padding for partial blocks. MeshCore pads the final block with zeros before encryption.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "aes-pad-001",
|
||||
"description": "5-byte plaintext 'Hello' padded to 16 bytes with zeros",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "D9FD218D50A4409143A7243D6D913502"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 D9FD218D50A4409143A7243D6D913502",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "48656C6C6F"
|
||||
},
|
||||
"notes": "Padded input: 48656C6C6F 0000000000000000000000. Output: 1 block."
|
||||
},
|
||||
{
|
||||
"id": "aes-pad-002",
|
||||
"description": "15-byte plaintext padded with 1 zero byte",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "BF70C038D511F2A8B528E06691C6D42D"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 BF70C038D511F2A8B528E06691C6D42D",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "000102030405060708090A0B0C0D0E"
|
||||
},
|
||||
"notes": "15 bytes padded with 1 zero: 000102...0E00. Output: 1 block."
|
||||
},
|
||||
{
|
||||
"id": "aes-pad-003",
|
||||
"description": "16-byte plaintext: no padding needed",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "0A940BB5416EF045F1C39458C653EA5A"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 0A940BB5416EF045F1C39458C653EA5A",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "000102030405060708090A0B0C0D0E0F"
|
||||
},
|
||||
"notes": "Exact block boundary: no padding. Output: 1 block."
|
||||
},
|
||||
{
|
||||
"id": "aes-pad-004",
|
||||
"description": "17-byte plaintext: 2 blocks, second padded with 15 zeros",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "0A940BB5416EF045F1C39458C653EA5A299F7C29A3E13AE7F64ECBA062FC7560"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 0A940BB5416EF045F1C39458C653EA5A299F7C29A3E13AE7F64ECBA062FC7560",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "000102030405060708090A0B0C0D0E0F10"
|
||||
},
|
||||
"notes": "Block 1: 000102...0F (no pad). Block 2: 10 + 15 zeros. Output: 2 blocks = 32 bytes."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "AES-128-ECB Encryption",
|
||||
"spec_ref": "versions/v0.1.0/14-crypto.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Standalone AES-128-ECB encryption test vectors. Key is the first 16 bytes of the shared secret. These vectors test the raw encryption operation without MAC.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "aes-001",
|
||||
"description": "AES-128-ECB: key=00..0F, plaintext=all zeros",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "C6A13B37878F5B826F4F8162A1C8D879"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 C6A13B37878F5B826F4F8162A1C8D879",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "00000000000000000000000000000000"
|
||||
},
|
||||
"notes": "AES-128-ECB(key=00..0F, pt=00×16) = C6A13B37878F5B826F4F8162A1C8D879. Wrapped in RAW_CUSTOM for schema compliance."
|
||||
},
|
||||
{
|
||||
"id": "aes-002",
|
||||
"description": "AES-128-ECB: key=00..0F, plaintext=all FF",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "3C441F32CE07822364D7A2990E50BB13"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 3C441F32CE07822364D7A2990E50BB13",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "aes-003",
|
||||
"description": "AES-128-ECB: key=00..0F, plaintext=00..0F (sequential)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "0A940BB5416EF045F1C39458C653EA5A"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 0A940BB5416EF045F1C39458C653EA5A",
|
||||
"crypto_context": {
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "000102030405060708090A0B0C0D0E0F"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "aes-004",
|
||||
"description": "AES-128-ECB: key=all FF, plaintext=all zeros",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "A1F6258C877D5FCD8964484538BFC92C"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 A1F6258C877D5FCD8964484538BFC92C",
|
||||
"crypto_context": {
|
||||
"encryption_key": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"plaintext": "00000000000000000000000000000000"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "ECDH Shared Secret (X25519)",
|
||||
"spec_ref": "versions/v0.1.0/15-identity.md",
|
||||
"protocol_version": 0,
|
||||
"description": "X25519 ECDH key exchange test vectors. MeshCore uses Ed25519 keys transposed to X25519 for key exchange. The resulting 32-byte shared secret is used as: AES key (bytes 0-15) and HMAC key (bytes 0-31).",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "ecdh-001",
|
||||
"description": "RFC 7748 Test Vector: X25519 key exchange (Alice's perspective)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "77076D0A7318A57D3C16C17251B26645DF4C2F87EBC0992AB177FBA51DB92C2A",
|
||||
"recipient_public_key": "DE9EDB7D7B7DC1B4D35B61C2ECE435373F8343C85B78674DADFC7E146F882B4F"
|
||||
},
|
||||
"notes": "RFC 7748 Section 6.1. Alice's private key and Bob's public key produce the shared secret. Note: MeshCore transposes Ed25519 keys to X25519, so actual ECDH inputs differ from raw Ed25519 keys."
|
||||
},
|
||||
{
|
||||
"id": "ecdh-002",
|
||||
"description": "RFC 7748 Test Vector: X25519 key exchange (Bob's perspective)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 4A5D9D5BA4CE2DE1728E3BF480350F25E07E21C947D19E3376F09B3C1E161742",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "5DAB087E624A8A4B79E17F8B83800EE66F3BB1292618B6FD1C2F8B27FF88E0EB",
|
||||
"recipient_public_key": "8520F0098930A754748B7DDCB43EF75A0DBF3A0D26381AF4EBA4A98EAA9B4E6A"
|
||||
},
|
||||
"notes": "RFC 7748 Section 6.1. Bob's private key and Alice's public key produce the same shared secret as ecdh-001, verifying the commutative property of ECDH."
|
||||
},
|
||||
{
|
||||
"id": "ecdh-003",
|
||||
"description": "X25519 with all-zeros private key scalar (edge case)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"recipient_public_key": "DE9EDB7D7B7DC1B4D35B61C2ECE435373F8343C85B78674DADFC7E146F882B4F"
|
||||
},
|
||||
"notes": "Edge case: all-zero private key after clamping becomes a low-order scalar. X25519 with a clamped all-zero key (which becomes 0x40...00) against any public key. The all-zero shared secret indicates this is a degenerate key and implementations SHOULD reject it."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "Ed25519 Sign/Verify",
|
||||
"spec_ref": "versions/v0.1.0/15-identity.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Ed25519 signature test vectors. MeshCore uses Ed25519 for advertisement signing. These vectors use RFC 8032 test keypairs for cross-validation.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "ed-001",
|
||||
"description": "RFC 8032 Test Vector 1: empty message",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "9D61B19DEFFD5A60BA844AF492EC2CC44449C5697B326919703BAC031CAE7F60",
|
||||
"sender_public_key": "D75A980182B10AB7D54BFED3C964073A0EE172F3DAA3F4A18446B0B8D183F8E3",
|
||||
"plaintext": ""
|
||||
},
|
||||
"notes": "RFC 8032 Section 7.1 Test Vector 1. Private key (seed) is 32 bytes; the 64-byte format used by MeshCore includes the expanded key. Signature over empty message."
|
||||
},
|
||||
{
|
||||
"id": "ed-002",
|
||||
"description": "RFC 8032 Test Vector 2: single-byte message 0x72",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "92A009A9F0D4CAB8720E820B5F642540A2B27B5416503F8FB3762223EBDB69DA085AC1E43E159C7E94B2BA35F6F6A1918E25682F9B0ADC5C33C2BF3C39F04E50"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 92A009A9F0D4CAB8720E820B5F642540A2B27B5416503F8FB3762223EBDB69DA085AC1E43E159C7E94B2BA35F6F6A1918E25682F9B0ADC5C33C2BF3C39F04E50",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "4CCD089B28FF96DA9DB6C346EC114E0F5B8A319F35ABA624DA8CF6ED4FB8A6FB",
|
||||
"sender_public_key": "3D4017C3E843895A92B70AA74D1B7EBC9C982CCF2EC4968CC0CD55F12AF4660C",
|
||||
"plaintext": "72"
|
||||
},
|
||||
"notes": "RFC 8032 Section 7.1 Test Vector 2. Signature over the single byte 0x72."
|
||||
},
|
||||
{
|
||||
"id": "ed-003",
|
||||
"description": "RFC 8032 Test Vector 3: two-byte message",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "6291D657DEEC24024827E69C3ABE01A30CE548A284743A445E3680D7DB5AC3AC18FF9B538D16F290AE67F760984DC6594A7C15E9716ED28DC027BECEEA1EC40A"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 6291D657DEEC24024827E69C3ABE01A30CE548A284743A445E3680D7DB5AC3AC18FF9B538D16F290AE67F760984DC6594A7C15E9716ED28DC027BECEEA1EC40A",
|
||||
"crypto_context": {
|
||||
"sender_private_key": "C5AA8DF43F9F837BEDB7442F31DCB7B166D38535076F094B85CE3A2E0B4458F7",
|
||||
"sender_public_key": "FC51CD8E6218A1A38DA47ED00230F0580816ED13BA3303AC5DEB911548908025",
|
||||
"plaintext": "AF82"
|
||||
},
|
||||
"notes": "RFC 8032 Section 7.1 Test Vector 3. Signature over the two-byte message 0xAF82."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "Encrypt-then-MAC Roundtrip",
|
||||
"spec_ref": "versions/v0.1.0/14-crypto.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Full encrypt-then-MAC pipeline test vectors. Each vector provides the shared secret, plaintext, and expected MAC+ciphertext output. Implementations should verify: (1) encrypt produces the ciphertext, (2) HMAC produces the MAC, (3) MACThenDecrypt recovers the plaintext.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "etm-001",
|
||||
"description": "Encrypt-then-MAC: 'Hello' with key 00..1F",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "EAB5 D9FD218D50A4409143A7243D6D913502"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 EAB5D9FD218D50A4409143A7243D6D913502",
|
||||
"crypto_context": {
|
||||
"shared_secret": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "48656C6C6F"
|
||||
},
|
||||
"notes": "AES key = secret[0..15], HMAC key = secret[0..31]. Output = MAC(2) || Ciphertext(16) = 18 bytes."
|
||||
},
|
||||
{
|
||||
"id": "etm-002",
|
||||
"description": "Encrypt-then-MAC: 'Pipeline test!' with key 00..1F",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "FB32 9EFCA5121B41B626F93A7CBEE440CACE"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 FB329EFCA5121B41B626F93A7CBEE440CACE",
|
||||
"crypto_context": {
|
||||
"shared_secret": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
||||
"encryption_key": "000102030405060708090A0B0C0D0E0F",
|
||||
"plaintext": "506970656C696E65207465737421"
|
||||
},
|
||||
"notes": "Plaintext 'Pipeline test!' (14 bytes). Zero-padded to 16 bytes before AES encryption."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "HMAC-SHA256 Truncated to 2 Bytes",
|
||||
"spec_ref": "versions/v0.1.0/14-crypto.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Tests HMAC-SHA256 computation with 32-byte key, truncated to CIPHER_MAC_SIZE (2 bytes). The HMAC key is the full 32-byte shared secret (PUB_KEY_SIZE), not just the 16-byte AES key.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "hmac-001",
|
||||
"description": "HMAC-SHA256(key=00..1F, msg='test message') truncated to 2 bytes",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "90B8"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 90B8",
|
||||
"crypto_context": {
|
||||
"shared_secret": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
||||
"plaintext": "74657374206D657373616765"
|
||||
},
|
||||
"notes": "HMAC-SHA256(key=00..1F, 'test message') = 90B89BC3C5CA2C29... Truncated to 2 bytes = 90B8."
|
||||
},
|
||||
{
|
||||
"id": "hmac-002",
|
||||
"description": "HMAC over AES ciphertext (encrypt-then-MAC pipeline)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "EAB5"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 EAB5",
|
||||
"crypto_context": {
|
||||
"shared_secret": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
||||
"plaintext": "D9FD218D50A4409143A7243D6D913502"
|
||||
},
|
||||
"notes": "HMAC key = full 32-byte secret. Message = the AES ciphertext of 'Hello'. Result truncated to 2 bytes = EAB5."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "SHA-256 ACK CRC Computation",
|
||||
"spec_ref": "versions/v0.1.0/04-payload-ack.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Tests MeshCore ACK CRC computation: SHA-256(timestamp_le || txt_type_attempt || text || sender_pub_key)[0..3]. Each vector presents the full ACK packet that would be returned, along with the crypto_context showing the plaintext fed to SHA-256. Vectors ack-crc-001..004 share timestamp/text/pub_key and differ only in the attempt nibble of txt_type_attempt, demonstrating that each retry produces a distinct ACK CRC.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "ack-crc-001",
|
||||
"description": "ACK CRC for TXT_MSG 'hello', ts=0x12345678, attempt=0, zero pubkey",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "ack",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"ack_crc": "B2EC0C9E"
|
||||
}
|
||||
},
|
||||
"binary": "0D 00 9E0CECB2",
|
||||
"crypto_context": {
|
||||
"plaintext": "78563412 00 68656C6C6F",
|
||||
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"notes": "SHA-256(timestamp(4) || txt_type_attempt(1) || text || sender_pub_key(32))[0..3] = 9E0CECB2 (LE). Displayed ack_crc field is the uint32 value 0xB2EC0C9E."
|
||||
},
|
||||
{
|
||||
"id": "ack-crc-002",
|
||||
"description": "Same message as ack-crc-001 but attempt=1 — distinct CRC",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "ack",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"ack_crc": "13F08151"
|
||||
}
|
||||
},
|
||||
"binary": "0D 00 5181F013",
|
||||
"crypto_context": {
|
||||
"plaintext": "78563412 01 68656C6C6F",
|
||||
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"notes": "txt_type_attempt=0x01 (TXT_TYPE_PLAIN<<2 | attempt=1). Confirms attempt increment changes ACK CRC."
|
||||
},
|
||||
{
|
||||
"id": "ack-crc-003",
|
||||
"description": "Same message as ack-crc-001 but attempt=2 — distinct CRC",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "ack",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"ack_crc": "4AD71DDF"
|
||||
}
|
||||
},
|
||||
"binary": "0D 00 DF1DD74A",
|
||||
"crypto_context": {
|
||||
"plaintext": "78563412 02 68656C6C6F",
|
||||
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "ack-crc-004",
|
||||
"description": "Same message as ack-crc-001 but attempt=3 — distinct CRC (max attempt)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "ack",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"ack_crc": "1A537B8F"
|
||||
}
|
||||
},
|
||||
"binary": "0D 00 8F7B531A",
|
||||
"crypto_context": {
|
||||
"plaintext": "78563412 03 68656C6C6F",
|
||||
"sender_public_key": "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"notes": "attempt=3 is the maximum value representable in the 2-bit attempt field."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "SHA-256 Basic",
|
||||
"spec_ref": "versions/v0.1.0/14-crypto.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Basic SHA-256 hash computation test vectors. MeshCore uses SHA-256 for packet hashing, channel hash derivation, and HMAC.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "sha-001",
|
||||
"description": "SHA-256 of empty string",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
|
||||
"crypto_context": {
|
||||
"plaintext": ""
|
||||
},
|
||||
"notes": "SHA-256('') = E3B0C442...B855. Standard NIST test vector."
|
||||
},
|
||||
{
|
||||
"id": "sha-002",
|
||||
"description": "SHA-256 of 'abc'",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD",
|
||||
"crypto_context": {
|
||||
"plaintext": "616263"
|
||||
},
|
||||
"notes": "SHA-256('abc') = BA7816BF...15AD. Standard NIST test vector."
|
||||
},
|
||||
{
|
||||
"id": "sha-003",
|
||||
"description": "SHA-256 of 'MeshCore'",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "F4F17278283E082A4743CCA308285D601E0F9943E6D6F9271B5B8C7DFED09DC0"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 F4F17278283E082A4743CCA308285D601E0F9943E6D6F9271B5B8C7DFED09DC0",
|
||||
"crypto_context": {
|
||||
"plaintext": "4D657368436F7265"
|
||||
},
|
||||
"notes": "SHA-256('MeshCore')."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"$schema": "../../schema/test-vector.schema.json",
|
||||
"name": "SHA-256 Packet Hash",
|
||||
"spec_ref": "versions/v0.1.0/16-packet-hash.md",
|
||||
"protocol_version": 0,
|
||||
"description": "Tests MeshCore packet hash computation: SHA-256(payload_type || payload)[0..7]. TRACE packets additionally include path_len in the hash input.",
|
||||
"vectors": [
|
||||
{
|
||||
"id": "phash-001",
|
||||
"description": "Packet hash for ACK with CRC 0xDEADBEEF",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "1BEE08540E8F7E5B"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 1BEE08540E8F7E5B",
|
||||
"crypto_context": {
|
||||
"plaintext": "03 EFBEADDE"
|
||||
},
|
||||
"notes": "SHA-256(0x03 || EFBEADDE)[0..7] = 1BEE08540E8F7E5B. Input: type byte 0x03 (ACK) + CRC 0xDEADBEEF as LE."
|
||||
},
|
||||
{
|
||||
"id": "phash-002",
|
||||
"description": "Packet hash for TRACE (path_len=0): includes path_len in hash",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "C105C34E45E60009"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 C105C34E45E60009",
|
||||
"crypto_context": {
|
||||
"plaintext": "09 00 01000000 02000000 00"
|
||||
},
|
||||
"notes": "SHA-256(0x09 || 0x00 || tag=1_LE || auth=2_LE || flags=0)[0..7]. TRACE special case: path_len byte (0x00) included after type byte."
|
||||
},
|
||||
{
|
||||
"id": "phash-003",
|
||||
"description": "Packet hash for TRACE (path_len=3): different hash due to path_len",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "B83FB2E0EE276404"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 B83FB2E0EE276404",
|
||||
"crypto_context": {
|
||||
"plaintext": "09 03 01000000 02000000 00"
|
||||
},
|
||||
"notes": "Same TRACE payload but path_len=3 instead of 0. Different hash proves path_len is included in computation."
|
||||
},
|
||||
{
|
||||
"id": "phash-004",
|
||||
"description": "Packet hash for ADVERT (all-AA pubkey, ts=0, all-BB sig)",
|
||||
"type": "encode_decode",
|
||||
"structured": {
|
||||
"header": {
|
||||
"version": 0,
|
||||
"payload_type": "raw_custom",
|
||||
"route_type": "flood"
|
||||
},
|
||||
"path": {
|
||||
"hash_size": 1,
|
||||
"hash_count": 0,
|
||||
"hashes": []
|
||||
},
|
||||
"payload": {
|
||||
"data": "F73157720FB1B5E1"
|
||||
}
|
||||
},
|
||||
"binary": "3D 00 F73157720FB1B5E1",
|
||||
"crypto_context": {
|
||||
"plaintext": "04 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 00000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
},
|
||||
"notes": "SHA-256(0x04 || advert_payload)[0..7]. Type 0x04 = ADVERT. Not a TRACE, so path_len is NOT included."
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user