Repository navigation
feat: per-contact shielded address index and a payment reference memo kind - #5893
Conversation
…the address The diversifier index of the shielded address a DashPay contact request carries is a keyed hash of the request's unique key (owner, recipient, account reference) under a key derived from the account's full viewing key. Two devices on one seed derive the same address for the same request and never the same address for two contacts, with no counter or stored state. Also encodes and decodes `encryptedShieldedAddress`: an IV and the 43-byte address under AES-256-CBC with the request's DIP-15 shared key, 64 bytes. Tested against the vectors of the DashPay shielded payment addresses DIP. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Memo kind 2, `PaymentRef`, carries a reference the payee chose and gave to the payer, such as an invoice or order number, so the payee can match a shielded payment to its records. It is the reference padded on the right with zero bytes to 32; an all-zero payload is no reference and decodes as an unknown memo. It names what is paid, never who pays. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 240d13c) |
…om the account's viewing keys `AccountViewingKeys::contact_address` gives the address a shielded account hands the contact of one contact request: the external address at the index the request's unique key hashes to under the account's full viewing key. `contact_index_of` maps an address of the account back to its per-contact index, for attributing a payment that arrives on it. Tests run the DashPay shielded payment addresses DIP's vectors end to end: seed, identity shielded account, full viewing key, profile address, and the address of each contact request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
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 3d366b4. No blocking correctness, layering, or consensus-versioning issue was established; three non-blocking API/documentation clarifications remain. This was a static review: the current Kotlin SDK build/tests passed, no failed code checks were reported, and PastaClaw review and PR Hygiene remain pending.
🟡 3 suggestion(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: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The substantial new cryptographic implementation in shielded_address.rs and AccountViewingKeys::contact_address combines keyed address-index derivation, encryption/decryption, and viewing-key handling whose correctness determines stable per-contact payment addresses. - 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— platform-versioning (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-dpp/src/shielded/memo.rs`:
- [SUGGESTION] packages/rs-dpp/src/shielded/memo.rs:47-53: Document the enum additions as Rust source-compatibility changes
Both `ShieldedMemo` and `platform_encryption::CryptoError` are publicly exported enums without `#[non_exhaustive]`. Adding `PaymentRef` and the two error variants makes downstream exhaustive matches fail to compile when consumers update, even though existing workspace consumers still compile and the memo wire encoding remains compatible. Replace the PR's Breaking Changes claim of "None" with a migration note explaining that exhaustive matches need new arms or a fallback. Keep the ordinary `feat:` title: the book's "Commits, pull requests, and what to run before pushing" section reserves `!` for consensus-breaking changes, which this is not.
- [SUGGESTION] packages/rs-dpp/src/shielded/memo.rs:101-102: Document the actual non-text result of payment_ref_text
The documentation says a non-UTF-8 reference "is shown in hexadecimal", but this helper only borrows valid UTF-8 and returns `None` otherwise; it performs no hexadecimal formatting. The new non-text round-trip test explicitly pins that behavior. Clarify that hexadecimal rendering is the caller's responsibility so consumers know how to handle the `None` result.
In `packages/rs-platform-wallet/src/wallet/shielded/keys.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/keys.rs:225-228: Qualify contact-address uniqueness and expose the collision-check duty
`contact_address` promises that two requests never share an address, but `shielded_contact_index` truncates HMAC output to 11 bytes and forces the high bit, leaving a finite 87-bit output space. Its own documentation consequently requires callers to compare previously issued indices and retry under another `account_reference` on a collision. State that qualification at this wallet entry point, and soften the same absolute claim in `shielded_address.rs`'s module documentation. Derivation itself needs no allocation state; collision checking needs access to earlier requests or their derived indices, not necessarily a separately persisted index table. This is a documentation correction, not a request to add the future contact-request allocation flow here.
| /// A payment reference: what the payment is for, in a value the payee chose and | ||
| /// gave to the payer, such as an invoice or order number, padded on the right with | ||
| /// zero bytes. The payee matches all 32 bytes against its own records. | ||
| /// | ||
| /// It never says who paid. Anyone who has seen a reference can attach it to a | ||
| /// payment, so the payee checks the amount it received against the request. | ||
| PaymentRef([u8; MEMO_PAYLOAD_SIZE]), |
There was a problem hiding this comment.
✅ Resolved at
83901e22; see the replies below.
🟡 Suggestion: Document the enum additions as Rust source-compatibility changes
Both ShieldedMemo and platform_encryption::CryptoError are publicly exported enums without #[non_exhaustive]. Adding PaymentRef and the two error variants makes downstream exhaustive matches fail to compile when consumers update, even though existing workspace consumers still compile and the memo wire encoding remains compatible. Replace the PR's Breaking Changes claim of "None" with a migration note explaining that exhaustive matches need new arms or a fallback. Keep the ordinary feat: title: the book's "Commits, pull requests, and what to run before pushing" section reserves ! for consensus-breaking changes, which this is not.
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, platform-versioning, rust-quality, security-auditor)
There was a problem hiding this comment.
Done in the description: Breaking Changes now says there is no consensus change (the title stays feat:) and gives the migration note, that ShieldedMemo and CryptoError gain variants and code matching either exhaustively needs a new arm or a fallback.
🤖 Addressed by Claude Code
There was a problem hiding this comment.
Resolved (re-reviewed at 83901e22): Your current Breaking Changes section explicitly documents the added ShieldedMemo and CryptoError variants and the exhaustive-match migration, while retaining the ordinary feat title and unchanged memo-wire compatibility.
| /// The same request always gives the same address, and two requests never share | ||
| /// one, on every device holding the seed and with nothing stored. `owner_id` is | ||
| /// the identity that sends the request and owns this account, and | ||
| /// `account_reference` the value the request publishes. |
There was a problem hiding this comment.
✅ Resolved at
83901e22; see the replies below.
🟡 Suggestion: Qualify contact-address uniqueness and expose the collision-check duty
contact_address promises that two requests never share an address, but shielded_contact_index truncates HMAC output to 11 bytes and forces the high bit, leaving a finite 87-bit output space. Its own documentation consequently requires callers to compare previously issued indices and retry under another account_reference on a collision. State that qualification at this wallet entry point, and soften the same absolute claim in shielded_address.rs's module documentation. Derivation itself needs no allocation state; collision checking needs access to earlier requests or their derived indices, not necessarily a separately persisted index table. This is a documentation correction, not a request to add the future contact-request allocation flow here.
| /// The same request always gives the same address, and two requests never share | |
| /// one, on every device holding the seed and with nothing stored. `owner_id` is | |
| /// the identity that sends the request and owns this account, and | |
| /// `account_reference` the value the request publishes. | |
| /// The same request always gives the same address on every device holding the | |
| /// seed, without storing an address allocation. Distinct requests can collide | |
| /// with negligible probability; before issuing an address, the caller checks | |
| /// previously issued indices and retries with another `account_reference` on a | |
| /// match (see [`shielded_contact_index`]). `owner_id` is the identity that sends | |
| /// the request and owns this account, and `account_reference` is the value the | |
| /// request publishes. |
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)
There was a problem hiding this comment.
Fixed in cd62b4c: contact_address now says two requests share an address only if their 87-bit indices collide, and that the caller checks earlier indices and retries under another account_reference. The module documentation in shielded_address.rs drops the same absolute claim.
🤖 Addressed by Claude Code
There was a problem hiding this comment.
Resolved (re-reviewed at 83901e22): Your updated contact_address and module documentation now acknowledge the finite 87-bit collision space and explain the caller's comparison-and-retry duty, resolving the original absolute uniqueness claim.
| /// A payment reference as text, when it is valid UTF-8 once its zero padding is | ||
| /// removed. A reference that is not, a hash for example, is shown in hexadecimal. |
There was a problem hiding this comment.
✅ Resolved at
83901e22; see the replies below.
🟡 Suggestion: Document the actual non-text result of payment_ref_text
The documentation says a non-UTF-8 reference "is shown in hexadecimal", but this helper only borrows valid UTF-8 and returns None otherwise; it performs no hexadecimal formatting. The new non-text round-trip test explicitly pins that behavior. Clarify that hexadecimal rendering is the caller's responsibility so consumers know how to handle the None result.
| /// A payment reference as text, when it is valid UTF-8 once its zero padding is | |
| /// removed. A reference that is not, a hash for example, is shown in hexadecimal. | |
| /// A payment reference as text, when it is valid UTF-8 once its zero padding is | |
| /// removed. Returns `None` for an empty or non-UTF-8 reference; callers that need | |
| /// to display a non-text reference render the raw bytes as hexadecimal. |
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)
There was a problem hiding this comment.
Fixed in cd62b4c: the documentation now says payment_ref_text returns None for a reference that is not text, and that the caller renders its 32 bytes in hexadecimal.
🤖 Addressed by Claude Code
There was a problem hiding this comment.
Resolved (re-reviewed at 83901e22): Your documentation update matches the implementation: payment_ref_text returns None for non-text references, and callers handle hexadecimal rendering.
|
Bots are done — your move: post |
…ielded-address-primitives Both sides added methods and tests to `AccountViewingKeys` at the same place: v5.1-dev the fresh address and own-recipient check, this branch the per-contact address and index. Both are kept. `contact_index_of` now says that a fresh address, drawn from the whole index space, can lie in the range per-contact addresses use and match no request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
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 2 only (queue backlog)
The current head incorporates the base merge and correctly clarifies that contact_index_of does not by itself identify a known contact; no blocking defect was found in the reviewed changes. All three prior suggestions remain valid against the exact head, ba9bcb2. Validation was static-only: current Rust workspace, wasm32, Swift, Kotlin, and JS checks pass; the dedicated wallet test job is skipped, and review/PR Hygiene checks remain pending.
🟡 3 suggestion(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.
Still open from earlier rounds (3)
- 🟡 Suggestion: Document the actual non-text result of payment_ref_text —
packages/rs-dpp/src/shielded/memo.rs:101-102(thread) - 🟡 Suggestion: Qualify contact-address uniqueness and expose the collision-check duty —
packages/rs-platform-wallet/src/wallet/shielded/keys.rs:277-280(thread) - 🟡 Suggestion: Document the enum additions as Rust source-compatibility changes —
packages/rs-dpp/src/shielded/memo.rs:47-53(thread)
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: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The change adds intricate cryptographic and key-handling logic in shielded_address.rs and AccountViewingKeys::contact_address, combining domain-separated keyed derivation, an 88-bit index namespace, and encrypted address encoding whose correctness must remain stable across wallet restores. - Phase 1 reviewers: not run (skipped for throughput: 12 PRs queued, above the 10 limit)
- 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— platform-versioning (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-dpp/src/shielded/memo.rs`:
- [SUGGESTION] packages/rs-dpp/src/shielded/memo.rs:101-102: Document the actual non-text result of payment_ref_text
(carried; thread: https://github.com/dashpay/platform/pull/5893#discussion_r4551448278)
- [SUGGESTION] packages/rs-dpp/src/shielded/memo.rs:47-53: Document the enum additions as Rust source-compatibility changes
(carried; thread: https://github.com/dashpay/platform/pull/5893#discussion_r4551448221)
In `packages/rs-platform-wallet/src/wallet/shielded/keys.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/keys.rs:277-280: Qualify contact-address uniqueness and expose the collision-check duty
(carried; thread: https://github.com/dashpay/platform/pull/5893#discussion_r4551448242)
|
Bots are done — your move: post |
…turns `contact_address` and the module documentation said two contact requests never share an address. They share one only if their 87-bit indices collide, which is negligible, and the sender checks for it before sending; both now say so and point at the check. `payment_ref_text` returns `None` for a reference that is not text. Its documentation said such a reference is shown in hexadecimal, which is the caller's part. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Cargo 1.100 puts a build script's `OUT_DIR` one level deeper: `target/<profile>/build/<package>/<hash>/out`, where it was `target/<profile>/build/<package>-<hash>/out`. The three build scripts that stage headers under `target/<profile>/include` found that directory by going three levels up from `OUT_DIR`, so under the new layout the headers landed in `target/<profile>/build/include` and the Swift SDK build, which installs the stable toolchain, reported `rs-sdk-ffi.h` missing. They now take the parent of the `build` directory, which is the profile directory under both layouts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
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
The new contact-address helpers coexist with a fresh-address generator that can enter the DIP's reserved contact range on identity accounts; one non-blocking suggestion remains to reconcile that allocation policy. Static inspection found no additional issue in the memo encoding, encrypted-field handling, or header-output changes. Current CI passes Rust workspace, wasm32, Kotlin, Swift, and dashmate checks; three JavaScript test jobs remain pending, with no failed code checks reported.
🟡 1 suggestion(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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); 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) — The substantial change adds cryptographic key derivation, shielded-address encryption/decryption, and wallet viewing-key handling in shielded_address.rs and keys.rs, directly affecting cryptography and key handling. - 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:310-313: Keep wallet-local fresh addresses out of the per-contact range
For an identity shielded account, `fresh_address_from` samples all 88 index bits and rejects only zero, so approximately half its results pass this new contact-range filter. The linked DIP's Identity Shielded Accounts section reserves `1..2^32-1` for wallet-local receiving addresses, `2^32..2^87-1` for future use, and the upper half exclusively for derived contact addresses. The documented requirement to match a returned index against an issued request prevents immediate false attribution, but does not preserve that partition. Provide a DIP-compliant wallet-local allocation path restricted to nonzero 32-bit indices for identity accounts, and test that its addresses return `None` from `contact_index_of`. Ordinary shielded accounts need not inherit this identity-specific restriction.
| self.incoming_viewing_key | ||
| .diversifier_index(address) | ||
| .map(|index| *index.as_bytes()) | ||
| .filter(is_shielded_contact_index) |
There was a problem hiding this comment.
✅ Resolved at
240d13ca; see the replies below.
🟡 Suggestion: Keep wallet-local fresh addresses out of the per-contact range
For an identity shielded account, fresh_address_from samples all 88 index bits and rejects only zero, so approximately half its results pass this new contact-range filter. The linked DIP's Identity Shielded Accounts section reserves 1..2^32-1 for wallet-local receiving addresses, 2^32..2^87-1 for future use, and the upper half exclusively for derived contact addresses. The documented requirement to match a returned index against an issued request prevents immediate false attribution, but does not preserve that partition. Provide a DIP-compliant wallet-local allocation path restricted to nonzero 32-bit indices for identity accounts, and test that its addresses return None from contact_index_of. Ordinary shielded accounts need not inherit this identity-specific restriction.
source: gpt-6.1-sol (phase2-reviewer: general)
There was a problem hiding this comment.
Fixed in fafe132 for every account: fresh_address now redraws an index of 2^87 or above, as it already did index 0, so a fresh address has 87 random bits and contact_index_of returns None for all of them (new test should_redraw_a_fresh_index_in_the_contact_range). I did not add a separate 32-bit path for identity accounts: this change has no notion of an identity account yet, and a 32-bit random index would start repeating addresses after tens of thousands of draws. Whether the DIP keeps its 32-bit wallet-local band or widens it to everything below 2^87 is being settled on the DIP.
🤖 Addressed by Claude Code
There was a problem hiding this comment.
Resolved (re-reviewed at 240d13ca): Your redraw loop now rejects zero and every index at or above 2^87, so fresh addresses cannot be recognized by contact_index_of. The current DIP policy represented by this change permits wallet-local indices below 2^87, so the earlier request for a separate 32-bit allocation path no longer applies.
|
Bots are done — your move: post |
…ntact range `fresh_address` drew its diversifier index from the whole 88-bit space, so about half of the addresses it returned sat at 2^87 or above, the half that holds the addresses of DashPay contact requests. Such an address was the account's own but read as a contact's address that matched no request. An index in that range is now redrawn, as index 0 already was. A fresh address still has 87 random bits, and `contact_index_of` returns `None` for every one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
The DIP no longer keeps 1 to 2^32 - 1 for a wallet's own addresses: they take any index below 2^87. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 1 finding(s) of this review were settled in the inline threads.
- ✅ Withdrawn: 🟡 Use the protocol account-reference type at the derivation boundary
Static review found no blocking correctness, security, or layering defects. Two non-blocking issues remain: the new derivation APIs accept account-reference values that cannot be represented by the current u32 protocol field, and the fresh-address documentation is unnecessarily contradictory. Rust workspace tests and the JavaScript build were still running in the supplied CI snapshot; completed relevant checks passed.
🟡 1 0 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large diff implements cryptographic key derivation, shielded-address encryption/decryption, and wallet viewing-key address derivation in shielded_address.rs and keys.rs, directly changing critical cryptography and key-handling surfaces. - 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— platform-versioning (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-encryption/src/shielded_address.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/rs-platform-encryption/src/shielded_address.rs:90: Use the protocol account-reference type at the derivation boundary
`account_reference` is a `u32` in the contact-request model, wallet flow, and contract schema, but this public derivation API accepts `u64`; `AccountViewingKeys::contact_address` repeats the same broader type at line 291. That permits callers to derive addresses for values above `u32::MAX`, even though no valid contact request can publish or later reproduce those values. Keep the required eight-byte little-endian DIP encoding internally, but accept `u32` at both public boundaries and widen it only when building the hash preimage.
In `packages/rs-platform-wallet/src/wallet/shielded/keys.rs`:
- [NITPICK] packages/rs-platform-wallet/src/wallet/shielded/keys.rs:220-225: Correct the fresh-address range documentation
The comment first describes the returned index as below `2^87`, then uses an awkward `and so is an index of 2^87 or above` construction that can be read as contradicting the stated result rather than describing the rejected draw. Clarify that indices at or above `2^87` are redrawn, so the returned index is always below the contact range.
| index_key: &[u8; 32], | ||
| owner_id: &[u8; 32], | ||
| to_user_id: &[u8; 32], | ||
| account_reference: u64, |
There was a problem hiding this comment.
✅ Withdrawn at
240d13ca; see the replies below.
🟡 Suggestion: Use the protocol account-reference type at the derivation boundary
account_reference is a u32 in the contact-request model, wallet flow, and contract schema, but this public derivation API accepts u64; AccountViewingKeys::contact_address repeats the same broader type at line 291. That permits callers to derive addresses for values above u32::MAX, even though no valid contact request can publish or later reproduce those values. Keep the required eight-byte little-endian DIP encoding internally, but accept u32 at both public boundaries and widen it only when building the hash preimage.
source: gpt-6.1-sol (phase2-reviewer: rust-quality)
There was a problem hiding this comment.
Keeping u64 here on purpose. The DIP defines the input as the accountReference the document publishes, encoded as an unsigned 64-bit integer, and DashPay v3 declares that property as an integer with a minimum of 0 and no maximum, stored in 64 bits. A consensus-valid contact request can therefore publish a value above u32::MAX, and a u32 parameter could not derive or recompute its address. Callers that hold the DIP-15 32-bit value widen it without loss.
🤖 Addressed by Claude Code
There was a problem hiding this comment.
You're right: contactRequest.accountReference in the v3 schema has minimum: 0 and no maximum, unlike the explicitly u32-bounded key indices. I conflated the wallet's current u32 model with the contract's allowed range, so my claim that values above u32::MAX cannot be published was wrong. Keeping u64 here preserves those values and the documented eight-byte derivation encoding; I withdraw the suggestion.
Withdrawing this finding.
|
Bots are done — your move: post |
Co-authored-by: Lil Claw <pasta+claw@dashboost.org>
Basic explanation
What this does: Adds two building blocks for private DashPay payments. Nothing uses them yet, so behaviour does not change. The first works out which private (shielded) payment address a wallet gives to a contact. The address is computed from the contact request itself (who sends it, to whom, and its account reference) and a key only the wallet holds, and this change also encrypts and decrypts that address for the contact request, and lets the wallet's viewing keys turn a contact request into its address. The second is a new kind of note attached to a shielded payment, a payment reference: a value such as an invoice number that the payee gave to the payer.
Value: Every wallet that follows the rule gives each contact a different address, even with two devices on one seed and after a restore, with nothing to store or keep in step. A counter cannot guarantee that: two devices would hand the same address to different contacts. A payee can match a private payment to an invoice. Both live once in Rust, checked against the DIP's test vectors, for the Rust, Swift and Kotlin SDKs to share.
Risks: Low. No consensus rule changes and nothing calls the new functions yet. The derivation must never change once wallets use it, because a different result would give a contact a different address; the tests pin it to the DIP's vectors. A wallet without this change still keeps a payment reference memo intact, as a memo of an unknown kind.
Issue being fixed or feature implemented
The DashPay shielded payment addresses DIP (dashpay/dips#195) defines how a wallet derives the shielded address it gives each contact, how a contact request carries it, and a payment reference memo. Platform implements none of these. Today the wallet takes the address to send from the host application, so nothing stops one address going to every contact.
The contract field that carries the address is #5892, which is merged. This change does not depend on it.
What was done?
packages/rs-platform-encryption/src/shielded_address.rs(new)shielded_contact_index_key(full_viewing_key): the key an account derives its per-contact indices under,HMAC-SHA256("DashPay/shielded/contact-index-key/v1", full viewing key).shielded_contact_index(index_key, owner_id, to_user_id, account_reference): the 88-bit diversifier index of the address a contact request carries, a keyed hash of the request's unique key with bit 87 set, so it always lies in the range kept for contacts.is_shielded_contact_index(index): whether an index lies in that range.encrypt_shielded_addressanddecrypt_shielded_address: the 64-byteencryptedShieldedAddress, an IV followed by the 43-byte address under AES-256-CBC with the request's DIP-15 shared key. Decryption refuses any other field length, the reserved 80 bytes included, and a plaintext that is not 43 bytes.CryptoErrorvariants for those refusals.The module needs no shielded pool types. Turning an index into an address is the wallet's step, below.
packages/rs-platform-wallet/src/wallet/shielded/keys.rsAccountViewingKeys::contact_address(owner_id, to_user_id, account_reference): the address a shielded account gives the contact of one contact request, the external address at the request's index.AccountViewingKeys::contact_index_of(address): the per-contact index an address of the account sits at, orNonefor another account's address and for the account's profile and wallet-local addresses. A wallet uses it to attribute a payment that arrives on a contact's address.Neither decides which account an identity uses, or when a wallet sends an address; those come with the wallet's contact request flow.
AccountViewingKeys::fresh_address, added by #5888, drew its index from the whole index space, so about half of fresh addresses fell in the range kept for contact requests. It now redraws an index of 2^87 or above, as it already redraws index 0. A fresh address keeps 87 random bits, andcontact_index_ofreturnsNonefor every one.ff..ffis the account's own, andcontact_index_ofreturnsSome(ff..ff).packages/rs-dpp/src/shielded/memo.rsShieldedMemo::PaymentRef([u8; 32]), memo kind 2: the payee's reference padded on the right with zero bytes.ShieldedMemo::payment_ref(reference)builds one from 1 to 32 bytes and refuses an empty or all-zero reference.ShieldedMemo::payment_ref_textgives the reference as text when it is valid UTF-8 without its padding.Example, the index of a contact request from identity
0x11..11to0x22..22with account reference0x01234567, under the DIP's test account:Example, decoding the memo
02000000followed byINV-2026-0042and zero padding:ShieldedMemo::Other { kind: 2, .. }.ShieldedMemo::PaymentRef(..), whose text isINV-2026-0042.Other.Build scripts (not part of the feature)
The Swift SDK build fails on every branch since Rust 1.100.0 was released on 12 November: Cargo 1.100 moved build script output one directory deeper, and three build scripts wrote the FFI headers to the wrong place. The fix is its own pull request, #5898. The same commit is on this branch so that its Swift check can pass; the two are identical and merge cleanly in either order.
How Has This Been Tested?
shielded_address.rs: eight tests. They reproduce the DIP's vectors (the index key, three indices, the 64-byte field) and cover the refusals: other field lengths, a plaintext that is not 43 bytes, and a field that does not decrypt.memo.rs: five tests for the new kind, including the DIP's memo vector and the all-zero payload.keys.rs: a test that a fresh index in the contact range is redrawn, and three tests that run the DIP's vectors end to end through the wallet's own key derivation: seed, identity shielded account, full viewing key, profile address, and the address of each contact request, on mainnet and testnet.Run locally:
cargo test -p platform-encryption --lib shielded_addresscargo test -p dpp --all-features --lib shielded::memocargo test -p platform-wallet --features shielded --lib shielded::keyscargo clippy -p platform-encryption --all-targets,cargo clippy -p dpp --all-features --lib --testsandcargo clippy -p platform-wallet --features shielded --lib --testsBreaking Changes
No consensus change, so the title carries no
!.Rust source compatibility:
dpp::shielded::ShieldedMemogains thePaymentRefvariant, andplatform_encryption::CryptoErrorgainsInvalidEncryptedShieldedAddressLengthandInvalidShieldedAddressLength. Neither enum is#[non_exhaustive], so code outside this workspace that matches one exhaustively will need a new arm or a fallback arm when it updates. Nothing in the workspace does. The memo's wire encoding is unchanged: a reader without this change keeps a kind 2 memo asOther.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
240d13c/self-revieweddpp— you own itrs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/build.rs) — HashEngineering or ZocoLini or llbartekll or romchornyirs-platform-wallet(packages/rs-platform-wallet/src/wallet/shielded/keys.rs) — HashEngineering or ZocoLini or llbartekll or romchornyirust-sdk-ffi(packages/rs-sdk-ffi/build.rs) — lklimek or shumkovWhen 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