Skip to content

feat(core): sign with a wallet-granted ECDSA_HASH160 key - #658

Merged
PastaPastaPasta merged 1 commit into
masterfrom
feat/sign-with-hash160-keys
Nov 22, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
feat/sign-with-hash160-keys

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Released Dash wallets grant App Connect v2 keys of type ECDSA_HASH160, where the on-chain data is hash160 of the compressed public key. I checked this on testnet: the grant from DashPay Wallet for Android 11.9.2 is key #6, ECDSA_HASH160, and forge-web signed with it fine. In Rust, though, select_matching_key (crates/forge-core/src/platform/mod.rs) only picks ECDSA_SECP256K1 keys, so dg and git-remote-dash could never sign with a wallet grant. Plan items 8 and 9 in docs/design/wallet-primary.md (dg auth login --wallet) depend on this.

SingleKeySigner already handles HASH160 keys for both can_sign_with and sign (simple-signer at the pinned platform tag). This PR lets the selection accept them too. Nothing else changes: the key must still be enabled, unexpired, AUTHENTICATION, and HIGH or CRITICAL.

Test: a_wallet_granted_hash160_key_signs checks four cases:

  • a HASH160 key the signer controls is picked;
  • a SECP256K1 key still is;
  • a disabled HASH160 key gives the "disabled" error;
  • a HASH160 key with someone else's hash isn't matched.

cargo clippy -p forge-core --all-targets -D warnings is clean.

Related: forge-notify also accepts only SECP256K1 keys, so a wallet-signed-in browser can't use notifications yet. A separate PR is in progress for that.

🤖 Generated with Claude Code

Released Dash wallets grant App Connect keys of type ECDSA_HASH160 (the
key's data is the public key's hash160). The write engine only picked
ECDSA_SECP256K1 keys, so dg could not sign with a wallet grant. The
signer already matches and signs with HASH160 keys; the selection now
accepts them too.

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

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

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 17 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6786708-a4fa-4441-9f1c-953d1b221486
Commits

Reviewing files that changed from the base of the PR and between 2728289 and 59ec196.

Files selected for processing: 1

  • crates/forge-core/src/platform/mod.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

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: approve

I checked this against the pinned platform tag (v5.0.0-rc.8, 78d494f) and ran it locally on head 59ec196.

What I checked

  1. Signer: SingleKeySigner::can_sign_with matches an ECDSA_HASH160 key when the key data equals hash160 of the signer's compressed public key. sign handles ECDSA_SECP256K1 | ECDSA_HASH160 the same way, with a recoverable compact ECDSA signature (simple-signer/src/single_key_signer.rs:107-182).
  2. Platform: drive-abci's validate_state_transition_identity_signed lists ECDSA_HASH160 in SUPPORTED_KEY_TYPES. rs-dpp verify_identity_signed_signature checks HASH160 with verify_ecdsa_hash_160_signature_by_public_key_hash, which recovers the public key and compares its hash. Purpose and security-level requirements for batch transitions don't depend on key type, so a HIGH/CRITICAL AUTHENTICATION HASH160 key can sign document creates, replaces and deletes. This agrees with the testnet write forge-web made.
  3. Write path: WriteEngine::new → signer_from_key → select_matching_key is the only key-type gate between doc_op_key() and broadcast. doc_op_key filters on purpose and level only, and fetch_signer filters on identity id only. Nothing else on the write path in forge-core, dg or git-remote-dash checks key type.
  4. Security: the change doesn't widen what a key file can sign as.
    • The identity still comes from the key file's identity_id. It is never looked up from the key.
    • A key matches only when its data is hash160 of the file's own compressed public key, so the same private key holds the same authority as before.
    • Platform re-verifies the signature independently.
    • The enabled, unexpired, AUTHENTICATION and HIGH/CRITICAL requirements are unchanged.
  5. Test: cargo test -p forge-core --lib a_wallet_granted_hash160_key_signs passes, and cargo clippy -p forge-core --all-targets -- -D warnings is clean. I also put the matches! back to SECP256K1-only, and the test fails on the first assertion (mod.rs:6737), so it does guard the change. The disabled and other-hash cases would pass without the change too. That's fine: they guard against regressions.

Follow-ups (not blocking)

  • Key reporting doesn't recognise HASH160 keys yet. LoadedIdentity::key_id_for, signing_key_id and signing_key_standing (platform/identity.rs) compare only the compressed public key hex with the key data. For a key file that holds a wallet-granted HASH160 key, writes succeed but:

    • dg auth status / key_report shows no key id, limits or budget;
    • git-remote-dash Funds::budgeted_key is None, so the push cost guard never reads the remaining budget of the grant, even though wallet grants carry a total_budget;
    • check_budgeted_key would report "does not control it".

    This should be fixed before dg auth login --wallet (plan items 8 and 9) ships.

  • Nit: ECDSA_HASH160 is not a unique key type, so one identity could hold a SECP256K1 key and a HASH160 key for the same public key. Selection would then take the lower id, and the first loop's disabled/expired early return would hide a live duplicate. This is contrived for wallet grants, which are fresh derivations, and has no security effect.

  • Nit: the test name says "signs", but it only covers key selection. Signing is covered by rs-dpp itself, so that's fine.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit 3662b6e into master Nov 22, 2026
17 checks passed
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.

1 participant