From 29ebbcfb6240bc4ddb2d8b0289576ebba7f2d3a1 Mon Sep 17 00:00:00 2001 From: ecgang Date: Sun, 26 Jul 2026 11:50:38 -0700 Subject: [PATCH] Courier vectors: move the ciphertext-hash vector to where it can be checked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The remaining piece of the spray-receipt example this PR already removed once. `ciphertextHash` documents the envelope identity a spray receipt carries, and nothing on main carries one — `CourierStore.ciphertextHash` arrives with the courier-spray branch. So the test could not call the function the vector describes; it re-spelled the truncation instead, which would have passed just as green against a helper that truncated differently. A vector nobody can check is worse than no vector, because it reads as verified. It moves to the spray PR, where the production function exists and the assertion can go through it. Everything left in the file is now asserted against code that runs on main. Co-Authored-By: Claude Opus 5 (1M context) --- docs/courier-test-vectors.json | 5 ----- .../CourierVectorTests.swift | 21 ------------------- 2 files changed, 26 deletions(-) diff --git a/docs/courier-test-vectors.json b/docs/courier-test-vectors.json index abf05acc..82d24bce 100644 --- a/docs/courier-test-vectors.json +++ b/docs/courier-test-vectors.json @@ -71,11 +71,6 @@ "expected": "ad8514c90ca1fa6bf44e38c8a6252482" }, - "ciphertextHash": { - "_comment": "SHA-256 of the ciphertext, truncated to 16 bytes. This is the envelope identity a spray receipt carries.", - "expected": "bb85dcc4d8b17377c61817992df95826" - }, - "packetSigning": { "_comment": [ "THE trap. The signature does NOT cover the bytes as they appear on the", diff --git a/localPackages/BitFoundation/Tests/BitFoundationTests/CourierVectorTests.swift b/localPackages/BitFoundation/Tests/BitFoundationTests/CourierVectorTests.swift index eff7db94..adb2d189 100644 --- a/localPackages/BitFoundation/Tests/BitFoundationTests/CourierVectorTests.swift +++ b/localPackages/BitFoundation/Tests/BitFoundationTests/CourierVectorTests.swift @@ -99,9 +99,6 @@ struct CourierVectorTests { let epochDay: UInt32 let expected: String } - struct CiphertextHash: Decodable { - let expected: String - } struct PacketSigning: Decodable { struct Packet: Decodable { let version: UInt8 @@ -133,7 +130,6 @@ struct CourierVectorTests { let envelopeTLV: EnvelopeTLV let copiesClamping: CopiesClamping let recipientTagDerivation: RecipientTagDerivation - let ciphertextHash: CiphertextHash let packetSigning: PacketSigning let signature: Signature } @@ -227,23 +223,6 @@ struct CourierVectorTests { #expect(recomputed == tag) } - /// The 16-byte envelope identity a spray receipt carries. - /// - /// Weaker than the other vectors, and deliberately so: this derivation has - /// no consumer on main yet — the function that reads it arrives with the - /// courier-spray work. What production surface exists is asserted (the - /// `sha256Hash()` implementation and the `tagLength` constant), but the - /// truncation is spelled out here rather than called, so a future - /// `ciphertextHash` helper that truncates differently would not fail this. - /// When that helper lands it should assert against this same vector. - @Test func ciphertextHashIsSHA256TruncatedTo16() throws { - let v = try Self.loadVectors() - let hash = Data(try Self.hex(v.inputs.ciphertext) - .sha256Hash() - .prefix(CourierEnvelope.tagLength)) - #expect(hash.hexEncodedString() == v.ciphertextHash.expected) - } - // MARK: Packet canonicalization — the trap worth a vector /// A real `courierEnvelope` frame: type 0x04 carrying an encoded envelope,