iOS dual-signature blob order differs from desktop (kaz‖ml vs ml‖kaz) — cross-platform share verification will fail #236

Closed
opened 2026-11-20 09:22:51 +01:00 by amiryahaya · 1 comment
Owner

Discovered in the slice-3 dual-pass review (epic #223).

The gap: when wrapping a key for a recipient, iOS concatenates the dual signature as kazSignSignature + mlDsaSignature (CryptoManager.swift wrapKeyForRecipient), while desktop concatenates ml_dsa ‖ kaz_sign and splits ml-first at a fixed 3309 bytes (crypto_service.rs). An iOS-produced signature blob can never verify on desktop (and desktop's split sizes are themselves flagged 'needs determining' in code).

Same bug class as the KEM wire order fixed in #235-adjacent slice-3 work — silent cross-platform contract mismatch.

Suggested resolution: switch iOS to the desktop order (ml ‖ kaz), pin with a bidirectional signature vector test like tests/fixtures/ml-kem-hybrid-vectors.json does for the KEMs, and pin desktop's split sizes explicitly.

Also same class (from the same review): GET /api/invitations + /sent response envelope drift vs ReceivedInvitationsResponse/SentInvitationsResponse (see #234); AuthRepositoryImpl posts /invitations/token/{token}/accept which has no server route.

Relates to #223, #234.

Discovered in the slice-3 dual-pass review (epic #223). **The gap:** when wrapping a key for a recipient, iOS concatenates the dual signature as `kazSignSignature + mlDsaSignature` (CryptoManager.swift wrapKeyForRecipient), while desktop concatenates `ml_dsa ‖ kaz_sign` and splits ml-first at a fixed 3309 bytes (crypto_service.rs). An iOS-produced signature blob can never verify on desktop (and desktop's split sizes are themselves flagged 'needs determining' in code). **Same bug class as the KEM wire order fixed in #235-adjacent slice-3 work** — silent cross-platform contract mismatch. **Suggested resolution:** switch iOS to the desktop order (ml ‖ kaz), pin with a bidirectional signature vector test like tests/fixtures/ml-kem-hybrid-vectors.json does for the KEMs, and pin desktop's split sizes explicitly. **Also same class (from the same review):** `GET /api/invitations` + `/sent` response envelope drift vs ReceivedInvitationsResponse/SentInvitationsResponse (see #234); AuthRepositoryImpl posts /invitations/token/{token}/accept which has no server route. Relates to #223, #234.
Author
Owner

RESOLVED via PR #239 (merged 9ba3928) — all three contract breaks fixed, dual-pass review clean (0 Critical; the 3 Importants were fixed in-PR: consumer count guards were already in, invited_by_name Email fallback added server-side, server-side shape assertions added, decoder extracted + 4 unit tests).

  1. Signature blob order: wrapKeyForRecipient now mlDSA ‖ kazSIGN (desktop sign_with_key order; ML-DSA fixed 3309 makes ML-first the only deterministic split). Latent — nothing transmits the blob yet — fixed before wiring.
  2. Invitations list contract: server list DTO now carries tenant_name + invited_by_name (fixes desktop blank-name rendering too); iOS decodes the real paged envelope — both list screens work at runtime again, and server-side shape assertions pin the contract so removing the fields fails the server suite.
  3. Signature interop vectors: 8 fixture sections, bidirectional — desktop KAZ-SIGN-256 + ML-DSA-65 signatures verify on iOS; iOS-signed KAZ-SIGN/ML-DSA vectors verify under desktop Rust. Non-empty sections enforced on both sides.

Also: APIClient date decoding made fractional-seconds-tolerant (extracted makeDecoder() + 4 unit tests); dead KAZ-SIGN level-128 compat constants removed.

Still open, same contract-drift family (desktop side): per_page vs page_size naming mismatch and unbound status query param in desktop invitationStore (TS-tolerated today); /shares/invitations envelope drift (iOS InvitationsListResponse{invitations} vs server PagedResponse{items}) — both worth a desktop-side PR.

**RESOLVED via PR #239 (merged 9ba3928) — all three contract breaks fixed, dual-pass review clean (0 Critical; the 3 Importants were fixed in-PR: consumer count guards were already in, invited_by_name Email fallback added server-side, server-side shape assertions added, decoder extracted + 4 unit tests).** 1. **Signature blob order**: wrapKeyForRecipient now `mlDSA ‖ kazSIGN` (desktop sign_with_key order; ML-DSA fixed 3309 makes ML-first the only deterministic split). Latent — nothing transmits the blob yet — fixed before wiring. 2. **Invitations list contract**: server list DTO now carries `tenant_name` + `invited_by_name` (fixes desktop blank-name rendering too); iOS decodes the real paged envelope — both list screens work at runtime again, and server-side shape assertions pin the contract so removing the fields fails the server suite. 3. **Signature interop vectors**: 8 fixture sections, bidirectional — desktop KAZ-SIGN-256 + ML-DSA-65 signatures verify on iOS; iOS-signed KAZ-SIGN/ML-DSA vectors verify under desktop Rust. Non-empty sections enforced on both sides. Also: APIClient date decoding made fractional-seconds-tolerant (extracted `makeDecoder()` + 4 unit tests); dead KAZ-SIGN level-128 compat constants removed. **Still open, same contract-drift family (desktop side):** `per_page` vs `page_size` naming mismatch and unbound `status` query param in desktop invitationStore (TS-tolerated today); `/shares/invitations` envelope drift (iOS `InvitationsListResponse{invitations}` vs server PagedResponse{items}) — both worth a desktop-side PR.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#236
No description provided.