agent: drop versions before 07/2024 (support of PQ encryption and securing reply queue) - #1841
agent: drop versions before 07/2024 (support of PQ encryption and securing reply queue)#1841epoberezkin wants to merge 5 commits into
Conversation
…uring reply queue)
There was a problem hiding this comment.
Raises the minimum supported versions (SMP agent 2→6, E2E ratchet 2→3) and current SMP agent version 7→8, then deletes every branch that was conditional on the dropped-below versions: PQ-encryption gating (versionPQSupport_, pqRatchetE2EEncryptVersion guards), the old short/long header encodings (encodeLarge/largeP, encodeMsgHeader/msgHeaderP, encodeEncRatchetMessage), version-dependent padding sizes, and receipt/ratchet-sync version checks. The wire formats collapse to their PQ-capable forms and several ad-hoc encoders become plain Encoding instances.
I traced the version floor through the touched code and it is internally consistent: with agent ≥ 6 and E2E ≥ 3 every dropped predicate (>= pqdrSMPAgentVersion, >= pqRatchetE2EEncryptVersion, >= deliveryRcptsSMPAgentVersion, >= ratchetSyncSMPAgentVersion) was already always true, so removing them preserves behavior for supported peers. adjustE2EVRange in Ratchet mirrors the existing adjustAgentVRange (clamp min up to the supported floor, scoped to contact URIs), so it follows an established convention rather than inventing one. Padding functions now depend only on PQSupport, which both sides negotiate, so sender/receiver sizes still agree. Call sites, exports, and tests were all updated to match; no dangling references to the removed constants remain. This is a deliberate, breaking drop of pre-mid-2024 peers, as the title states.
Findings are minor:
- In
smpInvitation(Agent.hs) the newpqSupport <- lift $ PQSupportOn <$ compatibleInvitationUri connReqcomputescompatibleInvitationUriand discards it via<$, always producingPQSupportOn; the adjacent comment "assume there is no PQ encryption support" now contradicts the code. Suggested replacing with the constant and fixing the comment. - Two
ConnectionRequestTestsassertions keep "-- adjusted to v2" comments after the value moved tocontactAddressV6; they now clamp to v6.
Nits (not worth a suggestion): the new agent-version changelog line in Protocol.hs (-- 8 - ...) has trailing whitespace; _pqRatchetE2EEncryptVersion / _sndAuthKeySMPAgentVersion keep an underscore prefix despite being referenced (via the minSupported… aliases), which reads as "unused" — intentional as documentation of the floor's origin, but slightly misleading.
No correctness, security, or concurrency issues found.
There was a problem hiding this comment.
This branch raises the agent minimum version to 6 (secured reply queues, 6/2024) and the e2e-encryption minimum to 3 (PQDR, 3/2024), then deletes every version gate that those minimums make unconditional. The mechanical collapse is done consistently and reads well:
versionPQSupport_/addrKeysE2EVersionremoved; PQ support is now the requestedPQSupportdirectly. Correct:compatibleInvitationUri/compatibleContactUrionly returnJustwhen the peer overlaps the supported ranges, andadjustE2EVRangeclamps incoming e2e ranges up to 3, soagentV >= 5ande2eV >= 3always held anyway.- Ratchet encoding gates dropped:
E2ERatchetParams,MsgHeader,EncMessageHeader,EncRatchetMessagenow have plainEncodinginstances that always include the KEM field and always useLarge(2-byte) framing;largeP/encodeLarge/encodeMsgHeader/msgHeaderPare gone.paddedHeaderLen,fullHeaderLen,e2eEncConnInfoLength,e2eEncAgentMsgLength,replyKEM_,pqEnableSupport,joinContactInitialKeyslose their version parameter. All call sites are updated. This is a deliberate wire-format break for pre-3/2024 peers, which matches the PR's stated intent. A_MESSAGEgains amessageErr :: Stringfield and callers thread short context strings through parse failures. Consistent with the existingA_PROHIBITED {prohibitedErr}pattern;A_MESSAGEis only produced locally and reported via JSON, so no cross-agent wire concern.
Blocking:
tests/AgentTests.hsusesfdescribe "Functional API", which focuses that group and silently skips every other test inagentTests. This must be reverted todescribebefore merge, otherwise CI runs a fraction of the suite.
Two earlier suggestions were marked resolved but head still disagrees:
Agent.hssmpInvitationstill doesPQSupportOn <$ compatibleInvitationUri connReq(dead computation) with a comment that contradicts the code.ConnectionRequestTests.hsstill carries "-- adjusted to v2" comments where the value is now v6.
Minor: trailing whitespace on the new version-history line in Protocol.hs. Non-blocking observations, no change requested: rpcAddressSMPAgentVersion (v8) is defined but currentSMPAgentVersion is hardcoded to VersionSMPA 8 rather than referencing it (matches the pre-existing convention, so fine); the underscore-prefixed but still-used _sndAuthKeySMPAgentVersion / _pqRatchetE2EEncryptVersion read oddly but compile clean; the numbered parse-context tags ("1".."6") in processSMPTransmissions are cryptic but serviceable.
There was a problem hiding this comment.
Summary
Raises the minimum supported agent version to 6 (secure reply queues, sndAuthKey) and E2E version to 3 (PQDR), dropping everything before 07/2024. Because every supported peer now sits at or above the versions that gated PQ encoding, the branch removes all the v >= pqRatchetE2EEncryptVersion / v >= pqdrSMPAgentVersion conditionals and the version parameters that fed them. It also collapses the hand-written encodeMsgHeader/msgHeaderP, encRatchetMessageP, and encodeLarge/largeP pairs into plain Encoding instances, and threads user-requested PQSupport straight through instead of down-negotiating it per version.
I verified the refactor preserves wire behaviour for all still-supported peers:
- E2E params,
MsgHeader,EncMessageHeader, andEncRatchetMessagenow always use the "with KEM" /Large(2-byte) encoding. For v≥3 peers this is byte-identical to the old gated encoding; only the dropped v1/v2 short encodings are removed, which is the stated intent. e2eEncConnInfoLength/e2eEncAgentMsgLengthlose their version arg; at min agent v6 (≥5) the reduced sizes were already selected, so no size change for supported peers.versionPQSupport_wasPQSupport Truefor every supported (agent≥6, e2e≥3) combination, so removing thepqSupportAnd versionPQSupport_ …steps and passingPQSupportthrough unchanged is behaviour-preserving. TheREQevent now reportsPQSupportOnunconditionally, matching the earlier resolved comments.adjustE2EVRangemirrors the pre-existingadjustAgentVRange(clamping a published range's min up to the new minimum); consistent with established convention.
A_MESSAGE gaining messageErr :: String is safe: SMPAgentError has no binary wire encoding (only a deriveJSON instance for the local agent↔client API), and the new field matches the shape of A_PROHIBITED/A_QUEUE/A_LINK. It turns a previously opaque parse error into a diagnostic, which is an improvement.
Tests are updated consistently (version literals 1/2→6/7/8, dropped sqSecured parameter now that reply queues are always secured, removal of the now-moot testDeliveryReceiptsVersion). The fdescribe and stale-comment issues from the prior review are resolved in head.
No correctness, security, or concurrency issues found. The change is coherent and the diff tells a single story.
Minor notes (non-blocking)
- The
parseMessagecall sites inprocessSMPTransmissionsuse bare numeric context tags ("1"…"6","4","5","6"). Given the commit's goal of adding error context, descriptive labels (e.g. "conf reply info", "client envelope") would be more useful in logs than digits; the other new contexts ("decrypt message", "parse msg header", "parse link data") already read well. _sndAuthKeySMPAgentVersionand_pqRatchetE2EEncryptVersionkeep an underscore prefix (conventionally "unused") while actually being used as theminSupported…bindings. Slightly misleading to a cold reader; consider dropping the underscore or inlining with a comment.Ratchet.hsline 337:encodeKem kem = casehas a double space.
No description provided.