mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
Courier vectors: move the ciphertext-hash vector to where it can be checked
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) <noreply@anthropic.com>
This commit is contained in:
parent
4ab3e1a0e2
commit
29ebbcfb62
@ -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",
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user