Repository navigation
feat(platform-wallet): fresh shielded addresses and an own-address check - #5888
Conversation
…ersifier index AccountViewingKeys::fresh_address draws an 11-byte diversifier index from the OS CSPRNG (index 0 redrawn), so each call returns an unlinkable address that the scan still finds through the IVK. The own-recipient test moves to AccountViewingKeys::is_own_recipient so the scan and the coming export share one function. SDD-Task: T1 SDD-AC: AC-06 SDD-AC: AC-08 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ess check PlatformWallet::shielded_fresh_address / is_own_shielded_address answer over the bound account's viewing keys (None when not bound), and the C exports platform_wallet_manager_shielded_fresh_address / platform_wallet_manager_is_own_shielded_address follow the default-address export's WalletMissing / Unbound / Bound shape. No address is formatted into any error message. SDD-Task: T2 SDD-AC: AC-01 SDD-AC: AC-07 SDD-AC: AC-08 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…addresses Drives the real coordinator against a mock pool holding notes to five fresh addresses and one foreign address: the scan records exactly the five own notes and their balance, a wallet restored from the same seed finds the same notes, and it recognises every fresh address as its own. No production change; the note builder in cancelled_scan_tests is shared via pub(super) instead of copied. SDD-Task: T4 SDD-AC: AC-04 SDD-AC: AC-05 Co-Authored-By: Claude Opus 5.5 <[email protected]>
PlatformWalletManager wrappers over the new C exports, with the same guards and nil-when-unbound mapping as shieldedDefaultAddress. Unit tests cover the unconfigured-manager and wrong-length wallet id guards. Test notes: the SwiftDashSDKTests suite on an iOS 27.2 simulator passes except KeychainSignerAdditionalSigningKeysTests (two keychain XCTUnwrap failures, unrelated to this change) and a flaky PlatformWalletProgressPollTests case that passes on rerun. SDD-Task: T3 SDD-AC: AC-01 SDD-AC: AC-07 SDD-AC: AC-08 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s on a bound wallet The fresh-address export writes 43 bytes with out_present set, a new address per call and never the default; the own-address export answers true for a fresh address of the wallet and false for a foreign one. The no-op viewing-key callbacks move to test_fixtures so a bound-wallet fixture can declare SHIELDED_VIEWING_KEYS, which a seed-backed bind requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PlatformWalletManager is @mainactor, so shieldedFreshAddress and isOwnShieldedAddress cannot be called off the main actor as their doc comments said; they run on it and block while the FFI call drives the Rust runtime. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit e87bb32) |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the findings against head 46c203b and found no blocking correctness, security, or layering defects. Three non-blocking improvements and one visibility nit remain: avoid an unnecessary FFI allocation, deterministically test randomness edge cases, cover malformed lengths through the FFI export, and retain private visibility for an unshared test helper. This was a static review; Rust wallet tests and the Swift frozen-schema check passed, while the Swift build job failed with a self-hosted-runner communication error rather than a reported code failure, and its logs were unavailable.
🟡 3 suggestion(s) | 💬 1 nitpick(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large cross-language change that modifies shielded key derivation and recipient ownership checks inOrchardKeySet/keys.rs, a critical cryptographic and key-handling surface. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-platform-wallet/src/wallet/shielded/keys.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/keys.rs:474-476: Test zero-index rejection and entropy failure deterministically
The production OsRng draws effectively never exercise the zero-index retry: each draw reaches that branch with probability 2^-88. Removing the redraw loop would therefore leave these assertions passing almost every time, and the entropy-failure branch also has no regression coverage. Extract a private helper accepting a TryRngCore source while keeping the public method fixed to OsRng. Test a scripted source that returns zero followed by a known nonzero index, and a source that fails, verifying the selected address and ShieldedKeyDerivation error respectively.
In `packages/rs-platform-wallet-ffi/src/shielded_sync.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_sync.rs:799: Borrow the recipient instead of copying the host buffer
The export allocates and copies address_len bytes even though the wallet only needs a borrowed slice and rejects lengths other than 43. This makes malformed, large inputs incur allocation and copying before the wallet can reject them. The call completes synchronously through block_on, so the caller's documented buffer lifetime already covers the operation. Remove to_vec() and pass the borrowed address slice directly to is_own_shielded_address; recipient validation should remain in the wallet.
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_sync.rs:1459-1461: Cover malformed recipient lengths through the FFI export
The new export promises that a bound account answers false for recipient lengths other than 43, but its bound-wallet tests only pass valid-length addresses. The wallet-level 42-byte test does not exercise pointer/length marshalling or publication of out_present and out_is_own at the ABI boundary. Add bound-wallet export cases using a valid non-null backing buffer with lengths 0, 42, and 44, asserting Success, out_present == true, and out_is_own == false.
In `packages/rs-platform-wallet/src/wallet/shielded/cancelled_scan_tests.rs`:
- [NITPICK] packages/rs-platform-wallet/src/wallet/shielded/cancelled_scan_tests.rs:120: Keep the unshared tree_path helper private
The new sibling tests call coordinator_over, which creates its path internally; they do not call tree_path. Unlike the shared helpers and RecordingPersistence return type, this helper does not need wider visibility.
|
Bots are done — your move: post |
thepastaclaw
left a comment
There was a problem hiding this comment.
CI failed after approval — commit 46c203b
The standing review approved this commit; this follow-up moves the verdict to COMMENT: checks that failed after the review may relate to this change, and the evidence does not rule it out.
Failing checks:
Why it is unclear: The failing Swift SDK build and tests check covers Swift code and tests changed by this PR, but its failure log is unavailable (HTTP 404). The earlier review mentions a runner communication error, but the supplied failure evidence does not confirm that cause for this failure.
Nothing was re-reviewed: the findings of the standing review are unchanged. The next push gets a full review; a re-run that passes does not restore the approval.
Review provenance
Source: CI-check lane gpt-6.1-sol (agent: triage); no reviewer or verifier lanes ran for this follow-up
- Verdict moved because CI failed on this commit after the review; failure logs read: 0 GitHub Actions job(s)
…e own-check recipient - fresh_address draws through a private fresh_address_from(rng), so tests script an index-0 draw (redrawn) and a randomness failure (an error). - The is-own FFI export borrows the caller's buffer instead of copying it. - The bound-wallet FFI test covers recipient lengths 0, 42 and 44 (not own). - tree_path in cancelled_scan_tests is private again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> SDD-Published-From: 008cc9c2000cc840cd0ef88ab04c31382a072946
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Static verification of e87bb32 found no remaining in-scope defects in fresh-address generation, ownership checks, or FFI/Swift marshaling. Current CI reports Rust workspace tests passing and Swift SDK build/tests pending, with no failed code checks; the unchanged workspace filters do not establish execution of the new shielded-wallet tests. No local builds or tests were run.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large cross-layer change that modifies shielded key/address derivation and own-recipient classification inpackages/rs-platform-wallet/src/wallet/shielded/keys.rs, directly affecting cryptographic key handling and privacy-sensitive wallet behavior. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Missing human approval. Automatic reviewer requests are paused and this PR is excluded from reviewers' queues. Merge, close, or draft another active PR by this author to free a review slot. Required human review can be satisfied without a slot; once all merge requirements are met, PR Hygiene passes. |
llbartekll
left a comment
There was a problem hiding this comment.
Reviewed the wallet, FFI and Swift layers at e87bb32 — no bugs found.
- Every 11-byte Orchard diversifier index yields a valid address, so the only redraw needed is index 0, and that one is tested with a scripted RNG.
- Nothing needs persisting: the scan and
is_own_recipientboth go through the IVK, and the scan test confirms notes to fresh addresses are found and counted. - The FFI exports follow
shielded_default_address(outputs untouched on error,out_present = falsewhen unbound), and the Swift wrappers only marshal.
Swift SDK build was still running when I approved.
|
Policy satisfied — this can merge. |
…merge develop cade2c0154 is #5888 merged into v5.1-dev; its v13.rs/v14.rs match d4750290ff (the protocol 14 testnet runs). Develop is merged in; the ADR index keeps develop's 0010–0012, 0032–0033 and this PR's 0046–0048. Co-Authored-By: Claude Opus 5.5 <[email protected]> SDD-Published-From: a2463e6c6463aa1daa3227f41cc2bdcd47c5f39e
Issue being fixed or feature implemented
Closes #5869. A wallet can only hand out its default Orchard address today, so every payer of a shielded Receive pays the same address and can be linked to every other payer. The iOS wallet (dashpay/dashwallet-ios#1372) shows a fresh address per Receive session and needs two things from the SDK: a fresh diversified address, and a way to tell whether a shielded recipient is one of the wallet's own addresses (the history shows sends to own fresh addresses as internal).
What was done?
platform-wallet:OrchardKeySetderives a fresh payment address at a uniformly random 88-bit (11-byte) diversifier index from the OS CSPRNG, redrawing index 0 (the default address). Nothing is persisted: the incoming viewing key finds notes to every diversified address. The own-recipient test the scan already used for self-change moves tokeys.rsand is shared.PlatformWallet::shielded_fresh_address/is_own_shielded_address.platform_wallet_manager_shielded_fresh_addressandplatform_wallet_manager_is_own_shielded_address, followingplatform_wallet_manager_shielded_default_address(43 raw bytes,out_present = falsewhen not bound, unknown wallet →ErrorWalletOperation). The own-address check returns false for a malformed recipient.PlatformWalletManager.shieldedFreshAddress(walletId:account:)andisOwnShieldedAddress(walletId:account:raw43:). Both are synchronous and block the main actor, like the rest of the class.How Has This Been Tested?
platform-walletunit tests: two fresh addresses differ and never equal the default; the own-recipient test is true for default and fresh addresses and false for foreign or malformed ones.fresh_address_scan_tests.rs).platform-wallet-ffi(--features shielded): both exports on a bound wallet (43 bytes,out_present, a new address per call, own vs foreign), plus not bound, unknown wallet and null pointers. Full crate: 563 passed.ShieldedFreshAddressTests; end to end through the iOS app's tests (100 fresh derivations, p95 ≈ 0.5 ms on an iOS simulator in Debug).Breaking Changes
None — additive exports only.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull request🤖 Generated with Claude Code
PR Hygiene ·
e87bb32rs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/persistence.rs,packages/rs-platform-wallet-ffi/src/shielded_sync.rs,packages/rs-platform-wallet-ffi/src/test_fixtures.rs) — approved by llbartekllrs-platform-wallet(packages/rs-platform-wallet/src/wallet/platform_wallet.rs,packages/rs-platform-wallet/src/wallet/shielded/cancelled_scan_tests.rs,packages/rs-platform-wallet/src/wallet/shielded/coordinator.rsand 5 more) — approved by llbartekllswift-sdk— you own itWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit