feat(crypto): seal tenant envelopes with the X-Wing hybrid suite (HPK2) #228
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 525 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #228"
general
weight: 0.35
abendrothj
What and why
Part of #187 (P35). Tenant envelopes move to the hybrid post-quantum suite ADR 0007 decides: HPKE with X-Wing (X25519 + ML-KEM-768), HKDF-SHA256 and AES-256-GCM, frame
HPK2 || enc (1120) || ciphertext.1.
build(crypto): upgrade hpke to 0.14.1. Still HPK1; the committedhpk1.jsonvectors are byte-identical. hpke 0.14 turns on x25519-dalek'szeroizeitself, so #244's direct x25519-dalek 2 dependency is gone;TenantKeypairkeepsZeroizeOnDrop, and the zeroize test covers both suites' private keys.envelope-wasmuses getrandom 0.4 withwasm_js.2.
feat(crypto): seal tenant envelopes with the X-Wing hybrid suite (HPK2):- Keys know their suite, and a key opens only frames of its own suite. Public keys are parsed by length (32 HPK1, 1216 HPK2); private keys are exported as
magic || key.infostrings are-v2for HPK2.- Key loaders take a
SuitePolicy. FromAPP_ENV: production accepts only HPK2, development also HPK1, so the browser keeps working until #186; in production, browser enrollment and uploads are refused until then (fail closed, not a regression). The rawhpk1_*loaders are the browser's path and take no policy until P36. Refusals emitcrypto.suite_refused.- Key release and the stand-in accept only HPK2 tenant keys (
SuitePolicy::only). The enclave's own key-release key stays X25519 until #176, so dev key release wraps HPK2 tenant keys classically (recorded in the threat model).-
envelope-wasmstays HPK1-only until #186.- ADR 0007 is accepted: draft-06 pinned,
hpke-jsas the second implementation in both directions.3. Uploads: the route refuses a suite the deployment doesn't accept, a suite other than the tenant's enrolled key's, or, with no enrolled key, a suite other than the current snapshot's (422, audited), so a readable snapshot is never replaced by one no key can open. An unreadable enrollment record fails closed.
4. One seal path:
hpke_seal_to_tenantcalls the seeded-RNG function with the OS RNG, so the vectors pin what production seals. The server keeps curve25519-dalek's basepoint table (precomputed-tablesunderserver); the wasm build doesn't.5. Every refused enrollment key is audited as
crypto.key_enrollmentdenied.docs/BENCHMARKS.mdrecords both suites' numbers from onebenchrun of this head. #187 closes after the hybrid target and regression run (#185's second PR).How it was tested
@noble/post-quantum; HPK2 frames sealed byhpke-jsopen in Rust, and Rust-sealed frames (hpk2-rust-sealed.json) open inhpke-js. A seal-side KDF change fails the hpke-js opens.- a non-canonical 1216-byte key;
- production refusing an X25519 enrollment;
- bad base64 at enrollment;
- mixed-suite upload bodies;
- an upload in another suite than the enrolled key or the current snapshot;
- an unreadable enrollment record;
- the stand-in refusing HPK1;
- a released HPK1 key;
- an HPK1 key on the dev release stack;
- the production demo-key policy.
scripts/test-simulated-tee.sh: all stages pass; every stored object is an HPK2 envelope.hpke_envelopecovers both suites.cargo tree:precomputed-tableson forplatform-api, off forenvelope-wasm; getrandom 0.4 withwasm_jsin the wasm tree.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsAPP_ENVis production, so HPK1 is refused)docs/DATA_POLICY.md); vector seeds are public and test-onlyCHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made (ADR 0007 accepted)