Skip to content

fix(dashpay): report the Keystore lock-gate refusal for what it is - #1565

Merged
HashEngineering merged 2 commits into
feat/kotlin-sdk-phase-1from
fix/wallet-keystore-lock-gate-reporting
Sep 30, 2026
Merged

HashEngineering merged 2 commits into
feat/kotlin-sdk-phase-1from
fix/wallet-keystore-lock-gate-reporting

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1564 (fix/contested-username-restore-identity). Review that one first; this PR's diff is the single commit on top.

Issue being fixed or feature implemented

MO-972. DashPay username creation fails outright on a HONOR PTP-N49 (MagicOS, Android 16). Signing dies pre-broadcast with Protocol error: Generic Error: User not authenticated, one second after a successful biometric, reproducibly — and we reported it as "Keystore auth window expired".

There is no window to expire. This app has run KeySecurityPolicy.DEVICE_BOUND since 7e7d53485, and that alias carries no authentication gate. Android puts two independent gates on a Keystore key and reports both failures with the identical UserNotAuthenticatedException:

gate what it means on our alias?
setUserAuthenticationRequired authenticated within ~30 s no — that is the point of DEVICE_BOUND
setUnlockedDeviceRequired device unlocked right now yes — the SDK stamps it on every alias

The second one is what fails, on OEM builds whose lock-state tracking is defective (Google confirmed the same on Fairphone 5/6, Issue Tracker 506989112; AOSP ties this to how the device was unlocked). Our own comment in DashSdkServiceImpl asserted that DEVICE_BOUND keys "never throw UserNotAuthenticatedException" — that claim is what made the real cause invisible for weeks, so it is corrected here rather than merely softened.

Related PR's and Dependencies

What changed

  • SdkDashPayWrites.classifyBroadcastFailure gains an arm for the typed device-locked denial — reports that Keystore considers the device locked, and carries the alias into the log.
  • The existing "User not authenticated" arm stays, for AAR lines older than #4643 and for the genuinely auth-gated paths that survive on an install predating the DEVICE_BOUND switch (blobs still under the legacy auth-gated alias, reached through the SDK's migration fallback). Its wording no longer implies a timeout on a policy that has none.
  • DashSdkServiceImpl: the false "never throw UserNotAuthenticatedException" claim corrected, plus its stale reference to platform #4060 (that PR proposed the policy but was closed unmerged; it landed as #4183).

Not done here: wiring a BiometricGate into WalletManagerStore. It cannot affect this bug — under DEVICE_BOUND the gate is unreachable — and its only beneficiaries are legacy auth-gated blobs, which the SDK can recover by silently re-deriving from the seed rather than prompting the user. It would also need new foreground-Activity plumbing the app does not have today. Happy to do it separately if wanted.

How Has This Been Tested?

./gradlew :wallet:testProdDebugUnitTest --tests '*SdkDashPayWritesTest*'

SdkDashPayWritesTest 30/30 green, including a new case pinning the typed device-locked shape end to end: NotBroadcast, names the gate, carries the alias, and does not blame a window. Two existing test docs corrected — they blamed the auth gate.

Run against a locally published AAR (0.1.0-v42int11-mo972-SNAPSHOT) built from platform integration/v42int11 plus the #4643 stack, since the currently pinned 0.1.0-v42int5 does not contain startWalletSubsystems and the base branch will not compile against it.

Pre-existing failures elsewhere in the module, not from this change: SendCoinsTaskRunner{BIP70,SdkRouting,SelfSpendGrace} and GetUsernameVotingResultOperationTest — a leaked bitcoinj network context, and date-dependent assertions that have aged out. Re-running each class with these three files reverted reproduces the identical failure sets.

  • QA (Mobile Team) — needs the HONOR PTP-N49. Emulators cannot reproduce this defect class: AOSP classifies every denial as genuinely locked, so the defective-OEM branch is unreachable. Expected result: username creation succeeds, or fails with a message naming the alias and the KeyguardManager state — never "auth window expired" again.

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of transaction signing failures when device-lock or authentication requirements are not met. These failures are now identified as occurring before broadcast, with messages that distinguish device-lock restrictions from authentication issues.
    • Updated handling also covers wallets using older authentication-gated signing paths.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: dashpay/dash-wallet/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: dbc942a3-a41d-49f1-8277-88694a37071e

📥 Commits

Reviewing files that changed from the base of the PR and between e80f260 and d9a3f71.

📒 Files selected for processing (3)
  • wallet/src/de/schildbach/wallet/service/platform/sdk/DashSdkServiceImpl.kt
  • wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt
  • wallet/test/de/schildbach/wallet/service/platform/sdk/SdkDashPayWritesTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The SDK write-failure classifier now recognizes device-locked denials as pre-broadcast failures. Its unauthenticated-error explanation covers authentication and device-lock gates. Tests cover device-bound errors and legacy auth-gated paths.

Changes

Keystore failure classification

Layer / File(s) Summary
Signing failure classification and coverage
wallet/src/de/schildbach/wallet/service/platform/sdk/DashSdkServiceImpl.kt, wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt, wallet/test/de/schildbach/wallet/service/platform/sdk/SdkDashPayWritesTest.kt
The bootstrap comment distinguishes authentication gating from device-lock gating. The classifier returns NotBroadcast for device-locked errors and updates its unauthenticated-error explanation. Tests cover device-bound denials, legacy auth-gated aliases, and preservation of the original error cause.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: thepastaclaw, bfoss765

Merge Risk: ⚪ Minimal · up to d9a3f

The change improves Keystore failure reporting without changing broadcast behavior. No merge-blocking issue is established; SDK artifact validation and HONOR device QA remain normal validation tasks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d9a3f

The change does not visibly weaken wallet-access controls. However, treating this error as safe to retry depends on an ordering guarantee that could not be independently verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is on writes made through the existing bound-wallet path, including contact requests and profiles. Broader asset or cross-wallet exposure was not established; the unavailable SDK implementation limits that assessment.

Trust Boundaries and Controls

  • observed — The SDK write path retains feature gating, bound-wallet lookup, and managed-identity checks. The inspected contact-request entrypoint obtains the encrypted wallet’s key through SecurityGuard before routing the write. The new classifier does not modify those controls.

Resilience and Maintainability Implications

  • observed — Cancellation is propagated rather than converted into fallback. Unmatched failures remain Ambiguous. The new message match nevertheless treats free-form exception text as evidence of non-submission; the producer-side guarantee remains unverified.

Hardening Proposals

  • proposed — Prefer an SDK outcome that explicitly guarantees non-submission over message matching. Establish its signing, submission, and recovery contract before relying on it to authorize alternate broadcasting.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reporting Keystore lock-gate refusals accurately.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Comment @coderabbitai help to get the list of available commands.

@HashEngineering

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 34 minutes.

@HashEngineering
HashEngineering force-pushed the fix/contested-username-restore-identity branch from f4f086a to 291cecf Compare September 14, 2026 16:43
@thepastaclaw

thepastaclaw commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Final review complete — no blockers (commit d9a3f71) · triage: low

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

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)

The PR correctly adds handling for the SDK’s typed device-lock failure and preserves compatibility with older AAR error messages. However, the legacy fallback still reports a DEVICE_BOUND-specific “no auth window” diagnosis even though this classifier also handles genuinely authentication-gated legacy identity blobs, so the reported cause can remain misleading on those installations.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: normal by gpt-6-astra (effort low) — This is a substantial, cross-cutting DashPay restore, synchronization, transaction-walking, dependency, and error-classification change with tests, but the diff does not itself alter consensus rules, funds movement, cryptographic primitives, signing/key handling, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: not run (skipped for throughput: 19 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt:193-197: Do not claim that legacy Keystore failures have no auth window
  This fallback arm is intentionally retained for both older AARs and legacy identity blobs still wrapped under the authentication-gated alias, as described in the preceding comment. For those paths, the message incorrectly says that the app’s DEVICE_BOUND policy has no authentication window, even though the rejected key may still require authentication. That can reproduce the misleading diagnosis this PR is intended to remove. Keep the unclassified `User not authenticated` message neutral; only the typed device-locked arm should make a device-lock-specific statement.

Comment on lines +193 to +197
t.message?.contains("User not authenticated") == true ->
// MO-972: this used to read "Keystore auth window expired", which
// ASSERTS a timeout nobody measured. Field log (2026-09-10, testnet
// 12000007, HONOR PTP-N49) — biometric at 11:49:16, this at 11:49:17.
// One second. The window had not expired; the Keystore simply refused
// to treat the auth as satisfying the identity key's gate, which on
// that OEM is the same defect family as the false-locked master alias
// (dashpay/platform#4643 fixes that one and explicitly does NOT cover
// the auth-gated identity alias; #4060's DEVICE_BOUND policy is the
// remedy). Report what Keystore said, not a cause we inferred.
SdkWriteResult.NotBroadcast(
"signing failure (pre-broadcast): Keystore refused the identity key as " +
"unauthenticated (auth window may have expired, or the device's " +
"auth-bound Keystore gate is defective) — ${t.message}",
"signing failure (pre-broadcast): Keystore refused the signing key as " +
"unauthenticated (the device's Keystore gate rejected it; on this app's " +
"DEVICE_BOUND policy there is no auth window to expire) — ${t.message}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Do not claim that legacy Keystore failures have no auth window

This fallback arm is intentionally retained for both older AARs and legacy identity blobs still wrapped under the authentication-gated alias, as described in the preceding comment. For those paths, the message incorrectly says that the app’s DEVICE_BOUND policy has no authentication window, even though the rejected key may still require authentication. That can reproduce the misleading diagnosis this PR is intended to remove. Keep the unclassified User not authenticated message neutral; only the typed device-locked arm should make a device-lock-specific statement.

Suggested change
t.message?.contains("User not authenticated") == true ->
// MO-972: this used to read "Keystore auth window expired", which
// ASSERTS a timeout nobody measured. Field log (2026-09-10, testnet
// 12000007, HONOR PTP-N49) — biometric at 11:49:16, this at 11:49:17.
// One second. The window had not expired; the Keystore simply refused
// to treat the auth as satisfying the identity key's gate, which on
// that OEM is the same defect family as the false-locked master alias
// (dashpay/platform#4643 fixes that one and explicitly does NOT cover
// the auth-gated identity alias; #4060's DEVICE_BOUND policy is the
// remedy). Report what Keystore said, not a cause we inferred.
SdkWriteResult.NotBroadcast(
"signing failure (pre-broadcast): Keystore refused the identity key as " +
"unauthenticated (auth window may have expired, or the device's " +
"auth-bound Keystore gate is defective) — ${t.message}",
"signing failure (pre-broadcast): Keystore refused the signing key as " +
"unauthenticated (the device's Keystore gate rejected it; on this app's " +
"DEVICE_BOUND policy there is no auth window to expire) — ${t.message}",
"signing failure (pre-broadcast): Keystore refused the signing key as " +
"unauthenticated (the device's Keystore authentication or lock gate rejected it) — ${t.message}",

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 5c7ace1. You were right: this arm also handles identity-key blobs that are still under the legacy auth-gated alias, and for those the auth window is real. So "no auth window" was the same kind of unproven claim this PR removes, just pointing the other way. The message now says only "the device's Keystore authentication or lock gate rejected it". The shared comment above no longer says the app never uses setUserAuthenticationRequired, and classify_userNotAuthenticated_doesNotClaimTheWindowExpired now checks that the message contains neither "expired" nor "no auth window". Only the typed as device-locked arm makes a lock-specific statement. SdkDashPayWritesTest: 30/30.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Resolved (re-reviewed at 5c7ace1c): Verified your change in 5c7ace1: the fallback now reports only authentication or lock-gate rejection, so it remains accurate for legacy auth-gated blobs without denying their authentication window. The regression assertions exclude both 'expired' and 'no auth window', and I reexecuted all 30 focused tests successfully.

@HashEngineering
HashEngineering force-pushed the fix/contested-username-restore-identity branch 2 times, most recently from f17003b to b7e09a9 Compare September 19, 2026 16:09
@HashEngineering
HashEngineering changed the base branch from fix/contested-username-restore-identity to feat/kotlin-sdk-phase-1 September 22, 2026 23:18
@HashEngineering
HashEngineering force-pushed the fix/wallet-keystore-lock-gate-reporting branch from 6f38a1a to 8285a1d Compare September 22, 2026 23:18
@HashEngineering
HashEngineering changed the base branch from feat/kotlin-sdk-phase-1 to fix/sync-process-stalls September 22, 2026 23:25
@HashEngineering
HashEngineering force-pushed the fix/wallet-keystore-lock-gate-reporting branch from 8285a1d to 1788a4c Compare September 22, 2026 23:25

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

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 2 only (queue backlog)

The actual base-to-head diff changes only the Keystore classifier, its documentation, and its tests; the reported synchronization, alarm, and logcat changes are already present in the supplied base. One nonblocking diagnostic-wording finding remains valid, while the pre-existing credential-export issue merits a separate security follow-up. Static verification and diff whitespace checks completed; no runtime tests were executed.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — The supplied diff includes substantial new cryptography and key handling in KeyExchangeCrypto.kt and LoginKeyDerivation.kt implementing ECDH, HKDF, AES-GCM, and identity-derived login keys, meeting both the intricacy and critical-surface criteria despite the narrowly described Keystore fix.
  • Phase 1 reviewers: not run (skipped for throughput: 31 PRs queued, above the 10 limit)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt:195-197: Do not claim that legacy Keystore failures have no auth window
  (existing thread: https://github.com/dashpay/dash-wallet/pull/1565#discussion_r4010620079)
  This generic branch covers both unclassified device-lock denials and failures involving legacy auth-gated identity-key blobs, as documented immediately above it. Matching "User not authenticated" does not establish which alias or gate failed, so the added statement that there is no authentication window can misdirect diagnosis of a genuine legacy authentication-window expiry. DEVICE_BOUND describes the policy selected for new keys, not necessarily the existing blob involved in this failure. Keep this branch gate-neutral and reserve the device-locked explanation for the separately classified denial.
Out-of-scope follow-up suggestions (6)

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.

  • Existing support-report logcat export can disclose Coinbase credentials — TokenAuthenticator.getUpdatedToken() prints both the stored Coinbase access token and refresh token, and ContactSupportViewModel.collectLogcat() copies this process's logcat into an attachment without redaction. This provides a concrete credential-disclosure path when the token lines remain in the captured buffer and the user shares a report. Both files are byte-identical between the supplied base and head; this PR neither introduces nor expands that export path.
    • Follow-up: Track a separate security fix to remove credential logging and prevent sensitive logcat content from entering support attachments, with regression coverage for token redaction.
  • Track the bring-up job before awaiting its budget — Outside this PR's scope. The application-scoped async task and timeout-only assignment to detachedBringUp already exist in base 2e3e351. L1ShadowSyncService.kt has identical base/head blob 155a6312d97d2dc23c033a34b8f2279b10712814, and the classifier change does not introduce or expose this cancellation behavior.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • Prevent the watchdog restart from undoing an external stop — Outside this PR's scope. The application-scoped watchdog stop/start sequence is already present in the supplied base. L1ShadowSyncService.kt is byte-identical between base and head, and none of the changed code alters engine shutdown or restart ownership.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • Cancel the independent restart alarm when recovery is finished — Outside this PR's scope. The separate restart PendingIntent identity and repeating 15-minute alarm already exist in the supplied base. BlockchainServiceImpl.kt has identical base/head blob 97f7f5bf8076119e94f5d99e25c04532c54a0f98; this PR changes no alarm scheduling or cancellation.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • Apply the logcat deadline while draining its output — Outside this PR's scope. The synchronous input.read() loop preceding the timed process wait already exists in the supplied base. ContactSupportViewModel.kt has identical base/head blob 0666078f754c81db87a655aab74a2bb6df9a418b, and this PR does not change support-report collection.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • Start the L1 engine when a deferred first bind succeeds — Outside this PR's scope. The bind-success handler is unchanged: SdkBindRetryService.kt has identical base/head blob 04db9ab99486c68d180d475326dfbb25ad273595. The complete diff changes neither binding, service startup, nor replay idle handling, so this claim cannot block the current Keystore classification PR.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@HashEngineering
HashEngineering force-pushed the fix/sync-process-stalls branch 9 times, most recently from bc798f6 to c7fe51b Compare September 28, 2026 02:47
@HashEngineering
HashEngineering force-pushed the fix/wallet-keystore-lock-gate-reporting branch from 1788a4c to c8a36c1 Compare September 28, 2026 16:50

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

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

Reviewed the complete three-file diff at c8a36c1, the classifier's callers, regression tests, and relevant definitions in the cached pinned SDK. The new device-locked classification has focused coverage, but the prior diagnostic-wording suggestion remains valid for legacy auth-gated keys; no blocking defect was confirmed. Validation was static; tests were not executed.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: low by gpt-6-astra (effort low) — The diff adds one contained pre-broadcast error-classification arm in classifyBroadcastFailure, updates diagnostic wording and comments, and adds focused tests without changing cryptography, key handling, or transaction construction.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — security-auditor (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 97% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 13% left, 5h 100% left)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort medium); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort medium); agent phase2-reviewer, gpt-6-astra — general (completed, effort medium); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt`:
- [SUGGESTION] wallet/src/de/schildbach/wallet/service/platform/sdk/SdkDashPayWrites.kt:195-197: Do not claim that legacy Keystore failures have no auth window
  (existing thread: https://github.com/dashpay/dash-wallet/pull/1565#discussion_r4010620079)
  This fallback also handles legacy AUTH_GATED identity-key blobs, as the preceding comment and retained auth-window regression test explicitly acknowledge. Selecting DEVICE_BOUND for current storage does not establish which alias rejected an existing blob during migration, so invoking that policy's lack of an authentication window can incorrectly steer diagnosis away from a genuine legacy authentication-window expiry. The NotBroadcast classification remains appropriate; keep its explanation neutral about the rejecting gate, or explicitly distinguish current DEVICE_BOUND keys from legacy AUTH_GATED keys.
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.

  • Correct the remaining "Keystore auth window expired" claims outside SdkDashPayWrites — These references are pre-existing comments and documentation outside the three-file change, not newly introduced diagnostics. Updating them is routine adjacent cleanup, and the claim does not establish an exceptional high-value follow-up that should expand this review.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@HashEngineering HashEngineering changed the title fix(dashpay): report the Keystore lock-gate refusal for what it is (MO-972) fix(dashpay): report the Keystore lock-gate refusal for what it is Sep 28, 2026
HashEngineering and others added 2 commits September 30, 2026 09:12
…O-972)

Username creation on a HONOR PTP-N49 failed pre-broadcast and was
reported as "Keystore auth window expired" one second after a successful
biometric. There was no window to expire: this app has run
KeySecurityPolicy.DEVICE_BOUND since 7e7d534, and that alias carries no
authentication gate.

What it does carry is setUnlockedDeviceRequired, and Android reports a
denial of THAT gate with the identical UserNotAuthenticatedException. The
comment in DashSdkServiceImpl asserting DEVICE_BOUND keys "never throw
UserNotAuthenticatedException" is what made the real cause invisible, so
it is corrected here rather than merely softened, along with its stale
reference to platform #4060 (proposed the policy, closed unmerged; it
landed as #4183).

dashpay/platform#4643 now classifies that denial SDK-side into
KeystoreDeviceLockedException, whose message names the alias and the
KeyguardManager state at throw time — and therefore no longer contains
"User not authenticated". Without a matching arm the failure would fall
through to the generic handling and become LESS legible than before the
SDK fix, so classifyBroadcastFailure gains one: it reports that Keystore
considers the device locked and carries the alias through to the log.

The existing "User not authenticated" arm stays for AAR lines older than
#4643 and for the genuinely auth-gated paths that survive on an install
predating the DEVICE_BOUND switch (blobs still under the legacy
auth-gated alias, reached via the SDK's migration fallback). Its wording
no longer implies a timeout on a policy that has none.

Not done here: wiring a BiometricGate into WalletManagerStore. It cannot
affect this bug — under DEVICE_BOUND the gate is unreachable — and its
only beneficiaries are legacy auth-gated blobs, which the SDK can recover
by silently re-deriving from the seed rather than prompting. It would
also need new foreground-Activity plumbing the app does not have today.

Tests: one new case pinning the typed device-locked shape end to end
(NotBroadcast, names the gate, carries the alias, does not blame a
window). Two existing test docs corrected — they blamed the auth gate.
SdkDashPayWritesTest is 30/30 green.

Verified against an AAR built from platform integration/v42int11 plus the
#4643 stack (published locally as 0.1.0-v42int11-mo972-SNAPSHOT); the pin
in build.gradle is deliberately left at 0.1.0-v42int5 for the team's own
AAR bump. The module's remaining failures — SendCoinsTaskRunner{BIP70,
SdkRouting,SelfSpendGrace} and GetUsernameVotingResultOperationTest — are
pre-existing on the base branch: a leaked bitcoinj network context and
date-dependent assertions. Re-running each class with these three files
reverted reproduces the identical failure sets.

Co-Authored-By: Claude Opus 5 <[email protected]>
…tral

The "User not authenticated" arm of classifyBroadcastFailure claimed that
on the DEVICE_BOUND policy "there is no auth window to expire". That arm
also serves identity-key blobs still wrapped under the legacy auth-gated
alias (installs predating the DEVICE_BOUND switch, reached through
WalletStorage.retrievePrivateKey's migration fallback), where the auth
window is real. A bare "User not authenticated" does not say which gate or
alias refused, so the message now asserts neither an expiry nor its
absence. Only the typed "as device-locked" arm names the lock gate.

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

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

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

Verified the complete PR diff at 5c7ace1. The device-locked matcher agrees with the pinned SDK's exception template, preserves its diagnostic, and retains the pre-broadcast fallback contract; the unclassified refusal is now gate-neutral, resolving the prior finding. All 30 focused SdkDashPayWritesTest tests passed on reexecution, and git diff --check passed; affected-OEM hardware validation remains outstanding.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: security-auditor); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.1-sol (effort low) — The diff adds a contained pre-broadcast Keystore error-classification arm and updates diagnostic wording, comments, and focused tests without changing key handling, signing, or broadcast implementation.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — security-auditor (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 79% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 13% left, 5h 100% left)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@HashEngineering
HashEngineering force-pushed the fix/wallet-keystore-lock-gate-reporting branch from 5c7ace1 to d9a3f71 Compare September 30, 2026 17:35
@HashEngineering
HashEngineering changed the base branch from fix/sync-process-stalls to feat/kotlin-sdk-phase-1 September 30, 2026 17:35

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

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

Verified the complete diff at d9a3f71. The new device-lock classifier matches the pinned AAR's exception message, preserves the diagnostic and cause, and leaves the unclassified refusal gate-neutral; the prior finding is fixed. No actionable in-scope findings remain; diff whitespace validation passed, and regression assertions were inspected but not executed during this verification.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: security-auditor); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.1-sol (effort low) — The diff adds one contained pre-broadcast error-classification arm, adjusts diagnostic wording and comments, and adds focused tests without changing signing, key handling, or broadcast implementation.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — security-auditor (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 98% left, weekly 79% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 13% left, 5h 100% left)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@HashEngineering
HashEngineering merged commit e0bacc4 into feat/kotlin-sdk-phase-1 Sep 30, 2026
3 checks passed
@HashEngineering
HashEngineering deleted the fix/wallet-keystore-lock-gate-reporting branch September 30, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants