Commit f032d8f
feat(key-wallet): add DIP-13 identity authentication accounts (ECDSA + BLS)
Add two new `AccountType` variants for DIP-13 sub-feature 0' (per-identity
signing keys the user employs to sign Dash Platform state transitions):
- `IdentityAuthenticationEcdsa { identity_index }` — key_type 0',
backed by a regular `Account` (secp256k1).
- `IdentityAuthenticationBls { identity_index }` — key_type 1',
backed by `BLSAccount`, gated on `#[cfg(feature = "bls")]`.
Both account types use the DIP-13 derivation path
`m/9'/coin_type'/5'/0'/key_type'/identity_index'` with hardened children
for individual keys (`.../identity_index'/key_index'`). Address pools use
`AbsentHardened` since DIP-13 mandates hardened leaves.
### Wiring
- `AccountCollection` gains `identity_authentication_ecdsa:
BTreeMap<u32, Account>` and (under `bls`) `identity_authentication_bls:
BTreeMap<u32, BLSAccount>`, keyed by `identity_index`. All collection
methods (`new`, `insert`, `insert_bls_account`, `contains_account_type`,
`account_of_type[_mut]`, `bls_account_of_type[_mut]`, `all_accounts[_mut]`,
`count`, `is_empty`, `clear`) are updated.
- `ManagedAccountCollection`, `ManagedAccountType`, `CoreAccountTypeMatch`
mirror the new variants and are routed through the usual matchers.
- `AccountTypeToCheck::IdentityAuthentication{Ecdsa,Bls}` variants are
added so conversions from `ManagedAccountType`/`AccountType` stay
total. Identity authentication accounts are **Platform-only**: they are
deliberately absent from every `TransactionType` relevance set
(`TransactionRouter::get_relevant_account_types`), and the
`ManagedAccountCollection::check_account_type` arms return empty
results. Address matching in `ManagedCoreAccount::check_transaction_for_match`
returns `None` for these variants for the same reason.
- `Wallet::add_bls_account` now accepts `IdentityAuthenticationBls` in
addition to `ProviderOperatorKeys`.
- Two new DIP-9 `IndexConstPath<5>` constants per network
(`IDENTITY_AUTHENTICATION_{ECDSA,BLS}_PATH_{MAINNET,TESTNET}`) and the
matching `DerivationPathReference::BlockchainIdentityAuthentication{Ecdsa,Bls}`
variants.
- `asset_lock_builder::resolve_funding_account` is intentionally left
untouched — identity authentication accounts do not fund asset locks.
- `WalletAccountCreationOptions` is unchanged. Identity authentication
accounts are per-identity and come into existence when the user
registers a Platform identity, not at wallet creation. Callers insert
them post-hoc via `Wallet::add_account` (ECDSA) or
`Wallet::add_bls_account` (BLS).
### FFI
`FFIAccountType` gains `IdentityAuthenticationEcdsa = 16` and
`IdentityAuthenticationBls = 17`; `to_account_type` / `from_account_type`
route the `index` parameter as `identity_index`. `FFIAccountMatch`
emission for `CoreAccountTypeMatch::IdentityAuthentication*` reports the
identity index in `account_index` (these variants are never produced by
the L1 transaction router, but the FFI matcher stays exhaustive).
### Tests
New `identity_authentication_tests` module in `account_type.rs` covers:
ECDSA and BLS mainnet/testnet/regtest path derivation, `index()` /
`derivation_path_reference()` / `AccountTypeToCheck` round-trip, and
end-to-end insert / `contains_account_type` / `account_of_type` /
`bls_account_of_type` round-trips through `AccountCollection`. BLS tests
are `#[cfg(feature = "bls")]`-gated. Existing
`test_wrong_account_type_for_bls` message was updated for the broadened
`insert_bls_account` validation.
### Serialization compatibility
Adding enum variants is forward-incompatible for `bincode::Encode`/
`Decode` — wallet blobs serialized by earlier v0.42-dev builds will fail
to decode after this change. This is acceptable given the unstable 0.x
API per `CLAUDE.md`. Serde uses its default (externally tagged)
representation, so new readers still decode old data identically and old
readers will error cleanly on new variants they cannot name.
Verified: `cargo build -p key-wallet --all-features`,
`cargo test -p key-wallet --lib --all-features`,
`cargo clippy -p key-wallet --all-features --all-targets -- -D warnings`,
`cargo fmt -p key-wallet --check`, and downstream `key-wallet-ffi` /
`key-wallet-manager` builds and lib tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ee1ebd9 commit f032d8f
17 files changed
Lines changed: 1114 additions & 72 deletions
File tree
- key-wallet-ffi/src
- key-wallet/src
- account
- managed_account
- transaction_checking
- transaction_router
- wallet
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
93 | 106 | | |
94 | 107 | | |
95 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
101 | 113 | | |
102 | 114 | | |
103 | 115 | | |
| |||
298 | 310 | | |
299 | 311 | | |
300 | 312 | | |
301 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
302 | 327 | | |
303 | 328 | | |
304 | 329 | | |
| |||
404 | 429 | | |
405 | 430 | | |
406 | 431 | | |
407 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
408 | 446 | | |
409 | 447 | | |
410 | 448 | | |
| |||
501 | 539 | | |
502 | 540 | | |
503 | 541 | | |
504 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
505 | 556 | | |
506 | 557 | | |
507 | 558 | | |
| |||
746 | 797 | | |
747 | 798 | | |
748 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
749 | 816 | | |
750 | 817 | | |
751 | 818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
222 | 240 | | |
223 | 241 | | |
224 | 242 | | |
| |||
247 | 265 | | |
248 | 266 | | |
249 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
250 | 274 | | |
251 | 275 | | |
252 | 276 | | |
| |||
564 | 588 | | |
565 | 589 | | |
566 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
567 | 597 | | |
568 | 598 | | |
569 | 599 | | |
| |||
1167 | 1197 | | |
1168 | 1198 | | |
1169 | 1199 | | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1170 | 1208 | | |
1171 | 1209 | | |
1172 | 1210 | | |
| |||
0 commit comments