feat(offline-keys): add ZHTLC offline key export support for ARRR#2549
Merged
ca333 merged 5 commits intooffline_key_exportfrom Jul 27, 2025
Merged
feat(offline-keys): add ZHTLC offline key export support for ARRR#2549ca333 merged 5 commits intooffline_key_exportfrom
ca333 merged 5 commits intooffline_key_exportfrom
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
43b0df2 to
ec7215b
Compare
|
Confirmed in HD mode, test seed provides:
Error testing: With
{
"mmrpc": "2.0",
"error": "Failed to derive keys for ARRR: Iguana key derivation requires Iguana mode",
"error_path": "offline_keys",
"error_trace": "offline_keys:548]",
"error_type": "KeyDerivationFailed",
"error_data": {
"ticker": "ARRR",
"error": "Iguana key derivation requires Iguana mode"
},
"id": null
}Is there any reason we can't offer offline output in both modes for all coins? |
|
Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it. |
shamardy
pushed a commit
that referenced
this pull request
Jul 28, 2025
) * feat(offline-keys): add ZHTLC offline key export support for ARRR * fix(offline-keys): apply cargo fmt formatting fixes * feat(offline-keys): implement actual ZHTLC key derivation for ARRR * fix(offline-keys): apply cargo fmt formatting fixes * fix(offline-keys): resolve compilation warnings by renaming unused variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(offline-keys): implement actual ZHTLC key derivation for ARRR
Summary
This PR implements offline key export functionality for ARRR (ZHTLC protocol) coins in the komodo-defi-framework. The implementation adds support for both HD and Iguana key derivation modes, enabling users to export ARRR private keys, addresses, and viewing keys offline.
Key Changes:
Zhtlcvariant toPrefixValuesenum with ZHTLC-specific key derivation logicz_derivation_pathparsingExtendedSpendingKey::mastertest_arrr_hd_key_derivationwith user-provided seed dataTechnical Details:
z_coin.rsfor cryptographic operationsindex > 0, usesdefault_address()forindex = 0z_derivation_pathfrom coin configuration (e.g., "m/32'/141'")zs1addresses,secret-extended-key-mainprivate keys,zxviewsviewing keysReview & Testing Checklist for Human
🔴 HIGH RISK - Cryptocurrency key derivation requires thorough validation:
zs1, private keys withsecret-extended-key-main, viewing keys withzxviewsRecommended Test Plan:
test_arrr_hd_key_derivationand verify the exact expected addresses/keys are generatedDiagram
%%{ init : { "theme" : "default" }}%% graph TD OfflineKeysRS["mm2src/coins/rpc_command/<br/>offline_keys.rs"]:::major-edit ZCoinRS["mm2src/coins/z_coin.rs"]:::context TestHelpers["mm2src/mm2_test_helpers/<br/>for_tests.rs"]:::context OfflineKeysRS --> |"uses ZHTLC encoding<br/>functions"| ZCoinRS OfflineKeysRS --> |"imports pirate_conf<br/>for testing"| TestHelpers subgraph "Key Implementation Areas" HDDerivation["HD Key Derivation<br/>(ZIP32 from root seed)"]:::major-edit IguanaDerivation["Iguana Key Derivation<br/>(ExtendedSpendingKey::master)"]:::major-edit TestCase["test_arrr_hd_key_derivation<br/>(comprehensive test)"]:::major-edit end OfflineKeysRS --> HDDerivation OfflineKeysRS --> IguanaDerivation OfflineKeysRS --> TestCase subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Cryptographic Implementation: This PR handles sensitive cryptocurrency key derivation. The implementation reuses existing, battle-tested ZHTLC functions from
z_coin.rswhere possible to minimize risk.Derivation Logic Complexity: The most complex part is the derivation path logic - for
index = 0, we only derive to account level and usedefault_address(), but forindex > 0, we derive additional change/index levels. This was debugged extensively during implementation.Testing Coverage: Added comprehensive test with exact expected values provided by the user, but testing is limited to indices 0 and 1. Higher indices and edge cases need human validation.
Integration Approach: Some logic had to be inlined from
z_coin.rsdue to function privacy constraints, which introduces potential for subtle differences from the original implementation.Session Info: