Repository navigation
feat(core): sign with a wallet-granted ECDSA_HASH160 key - #658
Conversation
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]>
|
Warning Review limit reachedYou'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. View limit details
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. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
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
- Signer:
SingleKeySigner::can_sign_withmatches anECDSA_HASH160key when the key data equals hash160 of the signer's compressed public key.signhandlesECDSA_SECP256K1 | ECDSA_HASH160the same way, with a recoverable compact ECDSA signature (simple-signer/src/single_key_signer.rs:107-182). - Platform: drive-abci's
validate_state_transition_identity_signedlistsECDSA_HASH160inSUPPORTED_KEY_TYPES. rs-dppverify_identity_signed_signaturechecks HASH160 withverify_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. - Write path:
WriteEngine::new→signer_from_key→select_matching_keyis the only key-type gate betweendoc_op_key()and broadcast.doc_op_keyfilters on purpose and level only, andfetch_signerfilters on identity id only. Nothing else on the write path in forge-core, dg or git-remote-dash checks key type. - 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.
- The identity still comes from the key file's
- Test:
cargo test -p forge-core --lib a_wallet_granted_hash160_key_signspasses, andcargo clippy -p forge-core --all-targets -- -D warningsis clean. I also put thematches!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_idandsigning_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_reportshows no key id, limits or budget;- git-remote-dash
Funds::budgeted_keyisNone, so the push cost guard never reads the remaining budget of the grant, even though wallet grants carry atotal_budget; check_budgeted_keywould report "does not control it".
This should be fixed before
dg auth login --wallet(plan items 8 and 9) ships. -
Nit:
ECDSA_HASH160is 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.
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 picksECDSA_SECP256K1keys, so dg and git-remote-dash could never sign with a wallet grant. Plan items 8 and 9 indocs/design/wallet-primary.md(dg auth login --wallet) depend on this.SingleKeySigneralready handles HASH160 keys for bothcan_sign_withandsign(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_signschecks four cases:cargo clippy -p forge-core --all-targets -D warningsis 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