Skip to content

feat: create an entry of any private document type from the shielded pool in KotlinExampleApp (type 29) - #6169

Merged
QuantumExplorer merged 7 commits into
v5.1-devfrom
feat/kotlin-example-private-document-create
Nov 24, 2026
Merged

QuantumExplorer merged 7 commits into
v5.1-devfrom
feat/kotlin-example-private-document-create

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does. Android can now create an entry of a private document type (protocol version 15). The entry is encrypted to one key of a recipient identity and paid from the wallet's shielded pool (state transition type 29), so nothing on chain names the sender or the recipient. Until now KotlinExampleApp could only read these entries (DOC-17). This ports SwiftExampleApp's create screen (#6130).

Value. Android and iOS can now test type 29 the same way on a protocol version 15 network, for any private type, not just DashPay's.

Risks. Low. No Rust wallet, FFI, Drive or consensus code changes. Rust already does all the deciding: the sender key, the recipient key check, the schema and capacity checks, sealing, the fee and how the result is classified. The new code converts arguments and shows what Rust returns. The spend itself is the same pool-paid path DashPay private contact requests already use. The app's own part is keeping a paid create safe:

  • it outlives the screen;
  • it is never sent twice while it may already have gone through;
  • the draft is not visible in screenshots.

Before / after

Before: Contracts → contract → a type with the Private badge showed only Read Entries. Kotlin had no binding for the create, the recipient keys or the fee.

After: on a build with shielded support, the same section also shows Create Entry (documentType.privateEntryCreateLink). It opens PrivateDocumentEntryCreateScreen, where you:

  • pick the wallet that pays (its account-0 shielded balance is shown) and a sender among that wallet's identities;
  • type the recipient id (base58 or hex) or pick a device identity, then Load Keys lists the keys Rust allows;
  • choose Anonymous or Deniable MAC (a signed entry is not offered, as on iOS);
  • fill the properties form (the same editors as New Document; strings are sent exactly as typed) and see Fee (at least) from Rust;
  • tap Create Entry.

Results:

  • Success: shows the commitment, the sender key, and a link to Read Entries.
  • Refused: Rust's message is shown as it came.
  • Network below protocol version 15: shown as not active.
  • May have gone through (ShieldedSpendUnconfirmed, or an unconfirmed broadcast or result): shown as such and never as failed. That exact request is not sent again while the app runs.

How the screen keeps a create safe:

  • The create runs on the application scope, so going back or rotating during the proof keeps it running, and its outcome is still there when the screen is reopened.
  • A tap is judged on the form as it is when the tap is handled. A recipient edited after Load Keys sends nothing.
  • The window is secure (no screenshot, no recents thumbnail), and the form is covered when the app leaves the foreground.

The test tags are Swift's accessibility ids, unchanged (privateEntryCreate.*).

Issue being fixed or feature implemented

Parity manifest entry documents.private_document_entry_create: Kotlin was unsupported. I searched open PRs and issues first and found no Kotlin work covering this.

What was done?

  • rs-unified-sdk-jni: new private_document_create.rs with three exports that bridge:

    • platform_wallet_manager_private_document_recipient_keys, freed with platform_wallet_private_document_recipient_keys_free before returning;
    • platform_wallet_manager_private_document_create_fee;
    • platform_wallet_manager_create_private_document_entry, behind the shielded feature as in the FFI.

    The JNI layer refuses only values the C type cannot hold, rather than truncating them: a negative count or account, a key id outside u32, an auth mode outside a byte, a wrong-length id, a null or NUL-holding string, and a Java string with an unpaired surrogate. Strings are read as their UTF-16 code units (GetStringLength / GetStringRegion) and decoded with String::from_utf16, because jni's own conversion replaces a bad surrogate silently and GetStringUTFChars output differs between VMs. The create's result array is allocated before anything is paid. read_32 is shared with the read export. Which auth modes exist is still the FFI's call (it refuses 2, signed).

  • Kotlin SDK:

    • ffi/PrivateDocumentCreateNative.kt;
    • wallet/PlatformWalletManagerPrivateDocuments.kt, with manager extensions, as Swift puts these on PlatformWalletManager;
    • JVM decoding tests;
    • the instrumented PrivateDocumentsFfiTest now covers the symbols, descriptors and refusals of the new exports (the create's only on a shielded build).
  • KotlinExampleApp:

    • PrivateDocumentEntryCreateScreen and route PrivateDocumentEntryCreate;
    • the Create Entry link in PrivateTypeSection, shown only on a shielded build;
    • PrivateDocumentEntryCreateCoordinator, on the application scope (the ShieldedIdentityPaymentCoordinator pattern), which owns the running create and its outcome and remembers every request that may have gone through;
    • buildPropertiesJson gains trimStrings, which the private create sets to false (New Document is unchanged).

    JVM tests cover the outcome mapping, the request built from the live form, recipient spellings, verbatim strings and the coordinator's hold.

  • TEST_PLAN: new row DOC-19 mirroring Swift DOC-19. DC-02 and DOC-17 now point to it, and the layer index is updated. The summary matrix counts include the new row (Uncommon 54, Shielded 31 after merging v5.1-dev, whose own recount this keeps).

  • Parity manifest: the Kotlin host of documents.private_document_entry_create moves to sdk partial, example_app partial, restart required (the same as Swift), with Kotlin and JNI verifications. PARITY_SUMMARY.md is regenerated.

No rule moved into Rust. The Swift view decides nothing beyond UI state, so there was nothing to move.

Differences from Swift:

  • The hold is stricter. Swift lifts the hold after an unconfirmed create as soon as any input changes. Android compares the request that would be sent: an edit that sends the same thing, or another create or refusal in between, does not lift it.
  • The hold lasts for the life of the app process. It is not tied to the screen. Across process death, the wallet's own redrive of the saved transition covers it. Moving this decision into rs-platform-wallet, keyed by a durable attempt identity, is tracked in platform-wallet: refuse to create again a private document entry whose earlier create may have gone through #6193.

Known limitation (tracked in #6185): a property declared through $ref cannot be entered with its resolved type. This applies to the shared document form on both platforms, not only this screen.

Public interface changes

Kotlin SDK (org.dashfoundation.dashsdk.wallet, new)

  • enum class PrivateDocumentSenderAuth { ANONYMOUS, DENIABLE_MAC }: each carries the FFI byte (0, 1) internally. There is no signed mode.
  • data class PrivateDocumentRecipientKey(keyId: Long, purpose: Int):
    • keyId is the u32 key id as a Long;
    • purpose is 1 ENCRYPTION or 2 DECRYPTION;
    • purposeName gives "Encryption", "Decryption" or "Purpose n".
  • class PrivateDocumentEntryCreated(commitment: ByteArray /* 32 */, senderKeyId: Long).
  • suspend fun PlatformWalletManager.privateDocumentRecipientKeys(identityId: ByteArray): List<PrivateDocumentRecipientKey>: the identity's keys an entry may be sealed to, as the network proves the identity now. An unknown identity throws DashSdkError.NotFound.
  • suspend fun PlatformWalletManager.privateDocumentCreateFee(contractId: ByteArray, documentTypeName: String, entryCount: Int = 1): Long: the fee in credits at two Orchard actions, the least the spend pays. Below protocol version 15 it throws ProtocolVersionNotActive.
  • suspend fun PlatformWalletManager.createPrivateDocumentEntry(walletId, account = 0, contractId, documentTypeName, senderIdentityId, recipientIdentityId, recipientKeyId: Long, auth: PrivateDocumentSenderAuth, propertiesJson: String): PrivateDocumentEntryCreated:
    • seals with the sender's encryption key inside the manager's mnemonic resolver, which also supplies the spend authority;
    • throws Rust's refusals before anything is paid;
    • throws ProtocolVersionNotActive below protocol version 15;
    • throws ShieldedSpendUnconfirmed when the entry may already be in the store. Do not create it again.
    • On a build without shielded support it throws DashSdkError.InvalidState before calling native code.
    • Runs under opReturningCompletedResult: a create that completes after its caller was cancelled is returned, not dropped.

The recipient-key and fee calls run inside the manager's teardown gate.

JNI (org.dashfoundation.dashsdk.ffi.PrivateDocumentCreateNative, internal, new)

  • recipientKeys(managerHandle: Long, identityId: ByteArray): LongArray?: flattened [keyId, purpose] pairs.
  • createFee(managerHandle: Long, contractId: ByteArray, documentTypeName: String, entryCount: Int): Long.
  • createEntry(managerHandle, walletId, resolverHandle, account: Int, contractId, documentTypeName, senderIdentityId, recipientIdentityId, recipientKeyId: Long, authMode: Int, propertiesJson: String): ByteArray?: returns 36 bytes, the commitment followed by the sender key id as a little-endian u32. Shielded builds only.

Errors throw DashSDKException. A value the JNI layer cannot marshal, including a string with an unpaired surrogate, uses code 1. Platform-wallet results use their code plus 1000.

KotlinExampleApp (internal)

  • PrivateTypeSection(schema, canCreateEntries, onReadEntries, onCreateEntry).
  • New route PrivateDocumentEntryCreate(contractIdHex, typeName).
  • AppContainer.privateDocumentEntryCreateCoordinator.
  • buildPropertiesJson(..., trimStrings = true).
  • PrivacyCover(text, testTag) is now shared by both private screens.

No Rust public API, FFI or Swift change.

How Has This Been Tested?

  • CARGO_INCREMENTAL=0 cargo test -p rs-unified-sdk-jni --lib private_document: 11 passed. The new tests cover the key pair flattening, the created-entry byte layout, and strict UTF-16 decoding (surrogate pair accepted; lone surrogates and a NUL beside an emoji refused with their real cause).
  • cargo clippy -p rs-unified-sdk-jni --all-targets --all-features --locked -- -D warnings: clean. cargo fmt --all was run before each commit.
  • ./gradlew :sdk:testDebugUnitTest :app:testDebugUnitTest :sdk:compileDebugAndroidTestKotlin (Homebrew openjdk@17): build successful.
    • PrivateDocumentCreateDecodingTest: 7 passed;
    • PrivateDocumentEntryCreateTest: 8 passed;
    • PrivateDocumentEntryCreateCoordinatorTest: 3 passed.
  • python3 scripts/check_sdk_parity_manifest.py --write-summary: OK, 51 capabilities.
  • CI emulator run on the first commit: PrivateDocumentsFfiTest passed there. The job's one failure, MasternodeVotingKeySigningTest ("User not authenticated"), is in code this PR does not touch.

Not yet verified

  • No native build (build_android.sh) was run locally, so the new instrumented checks (surrogate and split shielded checks) have only run on CI's emulator from the next run.
  • The screen has not been opened on an emulator, and the create has not run against a protocol version 15 network. That is TEST_PLAN DOC-19, for the QA pass.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 101ec81

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Build running
  • Approvals
    • sdk-parity — you own it
    • kotlin-sdk (packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/di/AppContainer.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt and 17 more) — HashEngineering

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

…e from the shielded pool (type 29)

Port of SwiftExampleApp's private document create (#6130) to the Kotlin SDK
and KotlinExampleApp. rs-unified-sdk-jni bridges
platform_wallet_manager_private_document_recipient_keys (and its free),
platform_wallet_manager_private_document_create_fee and
platform_wallet_manager_create_private_document_entry; the Kotlin SDK wraps
them as PlatformWalletManager extensions; the app adds a Create Entry
screen on a private type's detail screen with Swift's accessibility ids as
test tags. A create that may have gone through is shown as such and holds
Create while the form is unchanged. TEST_PLAN DOC-19 and the Kotlin side of
documents.private_document_entry_create are added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ca53428 and 101ec81.

Files selected for processing: 21

  • docs/sdk/sdk-parity-manifest.json
  • packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/di/AppContainer.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/Routes.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/PrivateDocumentEntryCreateCoordinator.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/CreateDocumentScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/DocumentTypeDetailsScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntriesScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentTypes.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/services/shielded/PrivateDocumentEntryCreateCoordinatorTest.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateTest.kt
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/PrivateDocumentsFfiTest.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/PrivateDocumentCreateNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManagerPrivateDocuments.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/wallet/PrivateDocumentCreateDecodingTest.kt
  • packages/rs-unified-sdk-jni/src/lib.rs
  • packages/rs-unified-sdk-jni/src/private_document_create.rs
  • packages/rs-unified-sdk-jni/src/private_documents.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added this to the v5.1.0 milestone Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 23, 2026
@thepastaclaw

thepastaclaw commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress (commit 101ec81) · live progress

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 2 only (queue backlog)

Changes requested: 7 blockers

  • Going back or rotating during Create Entry can hide a spend that still completes — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:256-285 (new)
    Impact: A sender who leaves or rotates the screen during proving can lose both the receipt and the do-not-retry warning, then pay for a second entry after reopening the form.
  • Formatting edits or a refused second request can unlock a duplicate paid entry — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:200-215 (new)
    Impact: A sender whose first create may already have landed can pay another fee for the same entry without changing what is sent.
  • Submitting Create Entry crashes the app on Android builds without shielded support — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt:564-567 (new)
    Impact: Users of the supported --no-shielded build can load recipient keys and fill out the form, then hit an uncaught linkage error when they submit.
  • Android screen captures can expose private drafts and their participants — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:288-306 (new)
    Impact: A sender drafting or confirming a private entry can expose its plaintext and sender–recipient relationship in a screenshot, recording, screen share, or Recents preview.
  • Create Entry can charge for a different string than the sender entered — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:250-254 (new)
    Impact: A sender entering a valid string with meaningful leading or trailing whitespace can pay for an immutable entry whose decrypted text no longer matches the form.
  • A submit event handled before recomposition can send the entry to the previous recipient — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:244-251 (new)
    Impact: A sender who edits the recipient and submits before the button refreshes can disclose the entry to whoever owns the previously loaded key.
  • The form cannot create a private type whose required integer is declared through a schema reference — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:246-254 (new)
    Impact: A sender can enter a valid number for a required referenced integer and still be unable to create the entry because the form always sends a JSON string.

This PR adds a Kotlin SDK binding and an Android example-app form for creating private document entries with protocol-15 shielded payments. Key lookup, validation, encryption, fee calculation, and spending still use the existing Rust wallet APIs. At the time of this static review, the Rust workspace tests and Kotlin x86_64 emulator check were pending, no code check had failed, and a protocol-15 end-to-end create had not been verified.

🔴 7 blocking | 🟡 3 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 10: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The change spans Android UI, Kotlin SDK, and JNI, but it exposes an existing shielded spend path without changing spend rules, cryptography, key validation, or consensus.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-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/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:256-285: Going back or rotating during Create Entry can hide a spend that still completes
  Impact: A sender who leaves or rotates the screen during proving can lose both the receipt and the do-not-retry warning, then pay for a second entry after reopening the form.
  The wallet can finish a paid create after the screen has lost all record of it. The submit job runs in `rememberCoroutineScope()`, and the in-flight flag, outcome, and retry hold are all `remember` state. Disabling the toolbar arrow does not intercept system Back or prevent activity recreation. Once the blocking JNI call starts, cancelling the coroutine does not stop the Rust spend. Independently, the SDK wrapper uses `teardownGate.op`, whose `withContext(Dispatchers.IO)` can discard a completed success when returning to a cancelled caller. Keep the in-flight operation and its outcome in a wallet-keyed owner that outlives the screen, following `ShieldedIdentityPaymentCoordinator`. At the SDK boundary, use the completed-result handoff pattern and preserve the typed unconfirmed outcome too. Test cancellation after native work starts and verify that a recreated screen still observes the same operation and outcome.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:200-215: Formatting edits or a refused second request can unlock a duplicate paid entry
  Impact: A sender whose first create may already have landed can pay another fee for the same entry without changing what is sent.
  The retry hold can disappear while the original spend is still unresolved. `keysApply` compares decoded bytes, but `heldInputs` compares raw recipient text and editor state. Adding a space or switching between base58 and hex keeps the same recipient and selected key but re-enables Create; property edits that leave the encoded JSON unchanged have the same effect. Separately, line 259 clears the hold as soon as a different request starts, even if Rust refuses it before spending. The Rust wallet can redrive the saved transition, but a fresh create seals a new entry and can select other notes. Check unresolved attempts against the effective request at submit time, and keep each attempt pending until its own outcome is reconciled. Use the wallet's saved operation for durable reconciliation rather than treating form edits as evidence that the original spend failed. Cover equivalent recipient spellings and the sequence unconfirmed A, refused B, then back to A.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:288-306: Android screen captures can expose private drafts and their participants
  Impact: A sender drafting or confirming a private entry can expose its plaintext and sender–recipient relationship in a screenshot, recording, screen share, or Recents preview.
  The draft and identity choices are visible before Rust encrypts the entry, and the form remains visible beside the public commitment after success. `MainActivity` enables `FLAG_SECURE` only for screens that request it; this destination never does. The sibling Read Entries screen already uses `HoldSecureWindow()` and covers private content when it goes off foreground. Apply the same protections to the create form and result, and verify that protection is maintained when opening Read Entries from the result.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:250-254: Create Entry can charge for a different string than the sender entered
  Impact: A sender entering a valid string with meaningful leading or trailing whitespace can pay for an immutable entry whose decrypted text no longer matches the form.
  The recipient can read altered text even though the app reports success. The editor displays the value verbatim, but the reused `buildPropertiesJson` fallback in `CreateDocumentScreen.kt:695–698` trims scalar strings and omits a property if the trimmed value is empty. If the schema accepts both `"  hello  "` and `"hello"`, Rust sees only the latter and can validly seal it; a whitespace-only optional value can disappear altogether. Marshal literal strings unchanged, distinguish an unset field from an explicitly empty value, and leave schema acceptance to Rust. Add a regression test for the actual JSON sent by the form.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:244-251: A submit event handled before recomposition can send the entry to the previous recipient
  Impact: A sender who edits the recipient and submits before the button refreshes can disclose the entry to whoever owns the previously loaded key.
  The recipient field can change before the payment handler stops accepting the old recipient. The edit callback updates `recipientText` but leaves `recipientKeysFor` and `selectedRecipientKeyId` intact. `keysApply` disables the button only when the composable updates; a click handled before that update enters `submit()`, which reads the cached recipient and key and never checks the live field. Rust correctly validates the cached recipient it was passed, so it cannot detect the mismatch. In `submit()`, decode the current recipient, require an exact match with the loaded key list and require the selected key to be in that list, then snapshot the checked arguments for JNI.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:246-254: The form cannot create a private type whose required integer is declared through a schema reference
  Impact: A sender can enter a valid number for a required referenced integer and still be unable to create the entry because the form always sends a JSON string.
  The form cannot express a valid payload for this supported private schema. `ParsedContract` expands type shorthands, not references, and `buildPropertiesJson` dispatches on the inline `type`. For a required property declared with `"$ref": "#/$defs/count"` and `"position": 0`, with `count` defined as an integer in the contract, entering `7` takes the string fallback and sends `"7"`. DPP resolves the reference, its sanitizer does not coerce text to an integer, and Rust refuses the payload. Drive the editor from a Rust projection of the resolved property types or provide a raw properties JSON input that preserves value types; do not add a second schema resolver to the app.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/navigation/AppNavHost.kt:564-567: Submitting Create Entry crashes the app on Android builds without shielded support
  Impact: Users of the supported `--no-shielded` build can load recipient keys and fill out the form, then hit an uncaught linkage error when they submit.
  The app offers a paid action the installed native library cannot execute. The route opens unconditionally, and both recipient-key lookup and fee preview are exported without `shielded`. The submit predicate does not check that capability, but `private_document_create.rs:218` compiles out `createEntry`. The resulting `UnsatisfiedLinkError` escapes both `mapNativeErrors` and the screen's `catch (Exception)`. Gate the destination on the existing `Sdk.hasShielded()` capability, leaving Read Entries available, and make the public SDK call fail with a controlled unsupported-build error instead of invoking an absent symbol. Split the instrumentation so key and fee checks still run without shielded support.

In `packages/rs-unified-sdk-jni/src/private_document_create.rs`:
- [SUGGESTION] packages/rs-unified-sdk-jni/src/private_document_create.rs:75-83: JNI can silently replace an unpaired surrogate before sealing a private entry
  Impact: A Kotlin SDK caller that passes a raw unpaired UTF-16 surrogate in a JSON string property can pay to store replacement characters instead of receiving an input error.
  Rust can receive altered but otherwise valid JSON. In the pinned `jni` 0.21.1, `JavaStr` conversion through `.into()` falls back to `String::from_utf8_lossy` when Modified UTF-8 decoding fails, including for an isolated surrogate. `CString::new` and the C FFI's UTF-8 check then accept the replacement text. Decode Java UTF-16 strictly at JNI, return `InvalidParameter` on malformed input, and retain the embedded-NUL check. Cover an isolated surrogate, a valid supplementary character, and an embedded NUL.
- [SUGGESTION] packages/rs-unified-sdk-jni/src/private_document_create.rs:293-298: A Java allocation failure after a paid create can hide its commitment
  Impact: If the JVM cannot allocate the result array after the spend succeeds, the caller sees an allocation error instead of the commitment.
  This binding has an avoidable allocation after funds have moved. Once the wallet FFI reports success, `byte_array_from_slice` calls `NewByteArray`; an allocation failure can leave an `OutOfMemoryError` pending while JNI returns null. Allocate the fixed 36-byte Java array before calling the wallet, then copy the bytes into that array on success. The paid decision-proposal binding already uses a validated output array for the same reason.
- [SUGGESTION] packages/rs-unified-sdk-jni/src/private_document_create.rs:41-65: Private-entry reads and creates duplicate the same JNI ID decoder
  Impact: A future fix to fixed-width ID marshalling or error handling can reach one private-entry operation but not the other.
  The new `read_32` duplicates `private_documents.rs:69–93`, including the null check, JNI exception clearing, width check, and messages. Share the helper within the JNI layer so both paths keep the same pointer-boundary checks. This is marshalling, so it belongs in JNI rather than in the wallet.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • The existing type-29 wallet result does not prove that the reported entry was appended — The unchanged Rust wallet accepts an affected-state proof of spent nullifiers and then returns a locally computed commitment. The verifier explicitly classifies that proof as non-binding: a competing transition that spent the same notes leaves the same nullifier evidence. This limitation is shared by the existing Rust and Swift paths and is not introduced by the Android binding.
    • Follow-up: File a wallet follow-up to distinguish a proved spend snapshot from confirmation of the requested entry, and report a confirmed append only when there is evidence tied to its commitment.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 23, 2026
…and never send a held one again

Review fixes for the private document entry create:

- The create runs in PrivateDocumentEntryCreateCoordinator on the
  application scope, so going back or a rotation keeps it and its outcome;
  the SDK call returns a completed result to a cancelled caller.
- A request whose create may have gone through is compared by what it sends
  (ids as hex, key, auth, encoded properties) and not sent again in the
  process, also after another create or refusal in between.
- A tap is judged on the live form: a recipient edited after Load Keys sends
  nothing.
- The screen holds a secure window and is covered off the foreground.
- String properties go exactly as typed.
- Create Entry is offered only on a build with shielded support, and the SDK
  call refuses on one without it.
- JNI: Java strings are decoded strictly (an unpaired surrogate is refused,
  not replaced), the result array is allocated before the spend, and the
  32-byte id reader is shared with the read export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 2026
…le-private-document-create

# Conflicts:
#	packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 1 blocker

  • Formatting edits or a refused second request can unlock a duplicate paid entry — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/PrivateDocumentEntryCreateCoordinator.kt:77-85 (carried)
    Impact: After a create lands without confirmation, a sender with another spendable shielded note can paste the same binary property in a different hex case and pay a second fee for an entry with the same contents.

New on this head: This revision moves KotlinExampleApp’s paid private-document create into an application-scoped coordinator and updates JNI to share ID decoding, reject malformed Java strings, and allocate the receipt before the wallet call. The Rust workspace tests and Kotlin emulator build and tests were pending at review time; no completed code check had failed on this head.

🔴 1 blocking | 🟡 3 suggestion(s)

Still open from earlier rounds (1)

  • 🟡 Suggestion: Android screen captures can expose private drafts and their participants — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The Kotlin UI, submission coordinator, and JNI bridge make this a substantial integration change, but the diff controls when the app submits a request without changing the underlying shielded spend, key-selection, cryptographic, or consensus rules.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-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/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/PrivateDocumentEntryCreateCoordinator.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/PrivateDocumentEntryCreateCoordinator.kt:77-85: Formatting edits or a refused second request can unlock a duplicate paid entry
  Impact: After a create lands without confirmation, a sender with another spendable shielded note can paste the same binary property in a different hex case and pay a second fee for an entry with the same contents.
  A sender can still pay twice for the same entry after a lost confirmation. The new coordinator keeps a hold across intervening refusals and equivalent recipient spellings, but `Request` compares the raw `propertiesJson`. The Hex bytes editor sends `deadbeef` and `DEADBEEF` as different strings, so the second Create tap passes the hold even though DPP decodes both to the same bytes. The Rust wallet seals a fresh commitment and can fund it with other spendable notes. Redrive only replays the original signed transition; it does not match a fresh create to that attempt, so it also cannot protect an unchanged retry after a restart clears the app’s hold. Keep the pending-attempt decision in `rs-platform-wallet`, keyed by a durable operation identity or Rust-normalized inputs, and let the app display the existing attempt rather than decide whether to send again.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/CreateDocumentScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/CreateDocumentScreen.kt:701-704: Create Entry can charge for a different string than the sender entered
  Impact: A sender cannot submit an explicit empty string: an optional property is omitted from the paid entry, and a required property is refused as missing even if its schema allows empty text.
  The form cannot send a present-but-empty scalar string. The whitespace fix preserves nonempty text, but the editor records a cleared field as an empty map value and `orEmpty()` followed by `isNotEmpty()` makes it indistinguishable from an untouched field. The new regression test explicitly expects the empty value to be omitted. Give the private form a way to distinguish unset from explicitly empty, pass the latter as `""`, and leave schema acceptance to Rust.

In `packages/rs-unified-sdk-jni/src/private_document_create.rs`:
- [SUGGESTION] packages/rs-unified-sdk-jni/src/private_document_create.rs:47-50: Android reports an unpaired surrogate when a string contains an emoji and a NUL
  Impact: A Kotlin SDK caller who passes an argument containing both a valid supplementary character and a literal NUL gets the right rejection code but is told to fix a surrogate that is already paired.
  The diagnostic points to the wrong character. Android ART’s `GetStringUTFChars` emits a supplementary character as four-byte UTF-8 but encodes NUL as `C0 80`. That NUL bypasses `cesu8` 1.1.0’s valid-UTF-8 fast path, and the fallback rejects the four-byte sequence before `CString::new` can report the NUL. Check for encoded NUL first or decode the original UTF-16 strictly, and cover the Android byte sequence with a regression case.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568: Android screen captures can expose private drafts and their participants
  (carried; thread: https://github.com/dashpay/platform/pull/6169#discussion_r4673457323)

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 24, 2026
…entry create

GetStringUTFChars output differs between VMs (ART writes a supplementary
character as four-byte UTF-8 but NUL as C0 80), so decoding it reported a
string with an emoji and a NUL as an unpaired surrogate. The JNI layer now
reads the UTF-16 code units with GetStringLength / GetStringRegion and
decodes them with String::from_utf16, so each refusal names its real cause.
The cesu8 dependency goes away.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 24, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 1 blocker

  • Reading a private-entry type name borrows past Android’s JNI table — packages/rs-unified-sdk-jni/src/private_document_create.rs:56-63 (new)
    Impact: On Android 15 and 16, an ordinary private-entry fee preview or create enters undefined behavior before the wallet can return a fee or receipt.

New on this head: This revision reads Java strings as UTF-16 code units in the private-entry JNI bridge, so it can distinguish an embedded NUL from an unpaired surrogate without relying on Modified UTF-8. The Kotlin SDK emulator check passed on this head; Rust workspace tests were still pending.

🔴 1 blocking | 🟡 2 suggestion(s)

Still open from earlier rounds (1)

  • 🟡 Suggestion: Android screen captures can expose private drafts and their participants — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The diff adds substantial UI, JNI marshalling, and submission coordination, but leaves spend execution, coin selection, key validation, cryptography, and consensus rules in the existing Rust implementation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • New since the last final review (6f3ecd6c): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-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-unified-sdk-jni/src/private_document_create.rs`:
- [BLOCKING] packages/rs-unified-sdk-jni/src/private_document_create.rs:56-63: Reading a private-entry type name borrows past Android’s JNI table
  Impact: On Android 15 and 16, an ordinary private-entry fee preview or create enters undefined behavior before the wallet can return a fee or receipt.
  The JNI bridge creates an invalid Rust reference on the normal SDK path. Opening Create Entry with an active manager calls `privateDocumentCreateFee` with the contract's 32-byte ID and a non-null type name; both that export and the paid create export pass the name to `java_string_units`, where `&**raw` borrows the whole table. The locked `jni-sys` 0.3.1 struct ends with `GetModule`, but the Android 15 and 16 ART tables end with `GetObjectRefType`. The reference therefore extends one pointer slot beyond the table. Both string functions are present, so the emulator can pass without making the reference valid. Keep the table as a raw pointer and copy only the two function-pointer fields, as `jni` 0.21.1 does in its dispatch macro.

  _Confirmed by an independent pass: On Android 15 or 16, opening Create Entry with an active manager requests a fee preview using the selected contract’s 32-byte ID, its non-null type name, and an entry count of one. Those inputs pass the JNI guards and reach `java_string_units`, where `&**raw` creates a reference one pointer slot past the end of ART’s table, triggering undefined behavior in the native SDK before any network request._
- [SUGGESTION] packages/rs-unified-sdk-jni/src/private_document_create.rs:354-357: Android tests miss the wrong diagnostic for an emoji beside a NUL
  Impact: A Kotlin caller could again be told to fix a valid surrogate pair instead of the literal NUL without the emulator suite detecting the regression.
  The Rust test checks the exact NUL diagnostic, but it supplies UTF-16 units directly to `c_string_from_utf16`, bypassing the new JNI calls. `PrivateDocumentsFfiTest.kt:86–93` crosses the VM boundary but sends NUL and a lone surrogate separately and checks only their shared error code. Add a `createFee` device case with a valid supplementary character beside a literal NUL and assert code 1 and `holds a NUL character`. With the existing unknown-manager fixture, an emoji-only companion case can assert code 1001 to confirm that marshalling reached the wallet FFI without contacting the network.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568: Android screen captures can expose private drafts and their participants
  (carried; thread: https://github.com/dashpay/platform/pull/6169#discussion_r4673457323)

…le-private-document-create

# Conflicts:
#	packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
#	packages/kotlin-sdk/PARITY_SUMMARY.md
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 24, 2026
`&**raw` made a reference to the whole JNI function table, which is shorter
on Android than jni-sys's struct. Only the GetStringLength and
GetStringRegion slots are now read through the raw pointer, as jni's own
dispatch does. PrivateDocumentsFfiTest gains a device case for a
supplementary character beside a NUL (refused as a NUL) and alone (reaches
the wallet FFI).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 24, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This revision reads the two JNI string functions directly from the table pointer and adds an Android regression test for a supplementary character beside a literal NUL. The Kotlin SDK emulator check passed on the reviewed head, Rust workspace tests were still running, and the end-to-end protocol 15 create flow remains unverified on device.

🟡 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.

Still open from earlier rounds (1)

  • 🟡 Suggestion: Android screen captures can expose private drafts and their participants — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The diff adds substantial UI, request coordination, and JNI marshalling, but delegates spend execution, fee calculation, key validation, and encryption to existing Rust code.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-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/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/contracts/PrivateDocumentEntryCreateScreen.kt:565-568: Android screen captures can expose private drafts and their participants
  (carried; thread: https://github.com/dashpay/platform/pull/6169#discussion_r4673457323)

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 24, 2026
…le-private-document-create

# Conflicts:
#	packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
#	packages/kotlin-sdk/PARITY_SUMMARY.md
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 24, 2026
@QuantumExplorer
QuantumExplorer merged commit 9aa9b5e into v5.1-dev Nov 24, 2026
22 of 24 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/kotlin-example-private-document-create branch November 24, 2026 01:33
HashEngineering added a commit that referenced this pull request Nov 26, 2026
…boundary

`env.get_string(..).into()` in jni 0.21.1 falls back to lossy decoding
when Java's modified UTF-8 does not decode, so a string with an unpaired
surrogate reached Rust as different text (U+FFFD in its place). A paid
memo or token note could reach the recipient as text the caller never
supplied.

Every string argument now goes through `support::read_jstring`. It
copies the UTF-16 code units with `GetStringRegion`, validates them
before decoding into an exactly sized buffer, and zeroes the copy (one
argument is a mnemonic). An unpaired surrogate is an error and
supplementary characters cross intact. After a failed read it makes no
further JNI call, so CheckJNI cannot abort on a pending exception; the
mnemonic signer now short-circuits its two reads for the same reason.
`funding.rs::read_cstring_exact` (#6192) and the private-document
reader (#6169) use it instead of their own decoders, and it covers the
TXO classification batch and test-hook reads #5767 added.

Helpers that treated an unreadable string as absent now throw code 1
naming the field and the reason: token notes and memos, the wallet
manager's user agent and devnet name, query filters and cursors, SDK
config strings, the vote contender id and the DPNS search prefix. Their
interior-NUL cases throw too rather than dropping the argument. A
malformed peer entry fails `spvStart` like an unreadable one.

`ManagedPlatformWallet.signMessage` no longer scans for unpaired
surrogates in Kotlin: the native boundary rejects them, as
`DashSdkError.InvalidParameter`.

Fixes #6154.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HashEngineering added a commit that referenced this pull request Nov 27, 2026
…boundary

`env.get_string(..).into()` in jni 0.21.1 falls back to lossy decoding
when Java's modified UTF-8 does not decode, so a string with an unpaired
surrogate reached Rust as different text (U+FFFD in its place). A paid
memo or token note could reach the recipient as text the caller never
supplied.

Every string argument now goes through `support::read_jstring`. It
copies the UTF-16 code units with `GetStringRegion`, validates them
before decoding into an exactly sized buffer, and zeroes the copy (one
argument is a mnemonic). An unpaired surrogate is an error and
supplementary characters cross intact. After a failed read it makes no
further JNI call, so CheckJNI cannot abort on a pending exception; the
mnemonic signer now short-circuits its two reads for the same reason.
`funding.rs::read_cstring_exact` (#6192) and the private-document
reader (#6169) use it instead of their own decoders, and it covers the
TXO classification batch and test-hook reads #5767 added.

Helpers that treated an unreadable string as absent now throw code 1
naming the field and the reason: token notes and memos, the wallet
manager's user agent and devnet name, query filters and cursors, SDK
config strings, the vote contender id and the DPNS search prefix. Their
interior-NUL cases throw too rather than dropping the argument. A
malformed peer entry fails `spvStart` like an unreadable one.

`ManagedPlatformWallet.signMessage` no longer scans for unpaired
surrogates in Kotlin: the native boundary rejects them, as
`DashSdkError.InvalidParameter`.

Fixes #6154.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HashEngineering added a commit that referenced this pull request Dec 1, 2026
…boundary

`env.get_string(..).into()` in jni 0.21.1 falls back to lossy decoding
when Java's modified UTF-8 does not decode, so a string with an unpaired
surrogate reached Rust as different text (U+FFFD in its place). A paid
memo or token note could reach the recipient as text the caller never
supplied.

Every string argument now goes through `support::read_jstring`. It
copies the UTF-16 code units with `GetStringRegion`, validates them
before decoding into an exactly sized buffer, and zeroes the copy (one
argument is a mnemonic). An unpaired surrogate is an error and
supplementary characters cross intact. After a failed read it makes no
further JNI call, so CheckJNI cannot abort on a pending exception; the
mnemonic signer now short-circuits its two reads for the same reason.
`funding.rs::read_cstring_exact` (#6192) and the private-document
reader (#6169) use it instead of their own decoders, and it covers the
TXO classification batch and test-hook reads #5767 added.

Helpers that treated an unreadable string as absent now throw code 1
naming the field and the reason: token notes and memos, the wallet
manager's user agent and devnet name, query filters and cursors, SDK
config strings, the vote contender id and the DPNS search prefix. Their
interior-NUL cases throw too rather than dropping the argument. A
malformed peer entry fails `spvStart` like an unreadable one.

`ManagedPlatformWallet.signMessage` no longer scans for unpaired
surrogates in Kotlin: the native boundary rejects them, as
`DashSdkError.InvalidParameter`.

Fixes #6154.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants