Courier vectors: pin the pre-image in the signature test too

The signature test signed whatever pre-image it was handed and verified it,
which is self-consistent by construction — it would have passed over a wrong
canonicalization. Mutating an input (timestamp +1ms) proved it: the
comparison test failed and this one did not.

It now pins the pre-image before signing, so both tests fail on any change to
field layout, timestamp encoding or payload length.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ecgang 2026-07-25 15:47:19 -07:00
parent 6a675ab4fc
commit 5ae772fdd8

View File

@ -157,6 +157,13 @@ struct CourierVectorTests {
let packet = try Self.envelopePacket()
let preimage = try #require(packet.toBinaryDataForSigning())
// Pin what is being signed. Without this the test is self-consistent by
// construction it would sign whatever it was handed, verify it, and
// pass over a wrong canonicalization. Proven by mutating an input and
// watching this line, not the verification below, be the one that fails.
#expect(preimage.hexEncodedString()
== Self.preimageBodyHex + String(repeating: "98", count: 152))
let key = try Curve25519.Signing.PrivateKey(rawRepresentation: Self.signingSeed)
#expect(key.publicKey.rawRepresentation.hexEncodedString()
== "2152f8d19b791d24453242e15f2eab6cb7cffa7b6a5ed30097960e069881db12")