feat(stealth-keygen): add HKDF and account-scoped confidential keys #1
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 388 lines diff across 4 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.357
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1"
general
weight: 0.35
valentynkit
What this PR brings in
This PR brings in the latest cryptographic features from
stealth-keygen:derive_balance_key(&context)to both payment types, returning the SDK’sAeKeyfor encrypting and decrypting the available-balance copy.ElGamalContext.Only the recipient can reconstruct the payment signing key. Both parties can derive the initial account’s encryption keys. This PR adds the off-chain cryptographic functionality; it does not implement confidential-account setup or transaction submission.
Differences from Scope’s original design
The implementation differs from the target described in Scope’s
docs/crypto.md:| Area | Scope’s documented target | Current implementation |
|---|---|---|
| Key derivation | HKDF-SHA512 | HKDF-SHA256 |
| Protocol salt |
stealth-conf/v1|stealth-keygen-v2|| Discovery and spending inputs | Purpose labels combined with ephemeral public key
Eand payment indexk| Separatediscovery-tagandspend-tweaklabels over the shared-secret-derived root, without explicitEorkfields || Confidential-key derivation | Derive
ct_ikm, then pass it to the SDK to obtain ElGamal and authenticated-encryption keys | Derive ElGamal scalar material and symmetric-key bytes directly through separate HKDF branches || Encryption context |
Eandkin the confidential-key-material derivation | Chain ID, application program ID, mint, and token-account address || Crate boundary |
stealth-keygenexports secret bytes and has no Solana dependencies;scope-clientconstructs SDK keys |stealth-keygendirectly returns SDKElGamalKeypairandAeKeytypes || SDK version | Workspace-managed
solana-zk-sdk7.0.1 | Standalone library pinssolana-zk-sdk6.0.1 || Disclosure interface | Receipts carry
ct_ikm, from which the verifier derives both encryption keys | Noct_ikmexport or Scope receipt integration yet |These differences require an explicit decision before merging. The current implementation does not produce the same derived keys as Scope’s documented schedule and cannot directly satisfy its planned
ct_ikmreceipt interface.This PR does not complete Q14. Recipient-only destination derivation, the remaining Scope API changes, and external cryptographic review remain separate work. Standalone test results also do not replace Scope’s workspace and CI checks.