-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(crypto): allow non bip39 mnemonics storage #2312
Conversation
…oPlatform/komodo-defi-framework into remove-unnecessary-mnemonic-checks
for my money, we should do it the other way around. i.e. not allow a non bip-39 seed. and not support iguana in seed storage. |
we can't deprecate support for iguana seed phrases ever, imo a user from last year can come back in 2030 and expect their seed phrase to work. I think we need to support at least wallet operations with iguana seed phrases forever. maybe put iguana support behind a special flag/config option? and have the strict checks for valid bip39/bip44 seed phrases |
Yeah we could required an additional flag for This is out of scope for this PR anyways. |
i would say such a user should dig up the internet for old clients that support iguana (or possibly build the old version themselves from source) to access their funds and send it over to an HD capable client, i.e. they self-migrate. |
While this won't be really helpful for most users who don't know what code is, this is still a good idea too. |
Please don't. I want to be able to use my passphrase and also be able to import privkeys (WIFs), which now work fine, from all supported coins. I also don't want to move funds for 300 coins to some new addresses. |
I guess making KDF generate bip39 mnemonics only is enough and for external seeds anything can be allowed. Allowing custom seeds with a config flag is a good idea but it's a breaking change. |
mm2src/crypto/src/mnemonic.rs
Outdated
cross_test!(test_mnemonic_with_last_byte_zero, { | ||
let mnemonic = "tank abandon bind salon remove wisdom net size aspect direct source fossil\0".to_string(); | ||
let password = "password"; | ||
cross_test!(test_encrypt_decrypt_words, { | ||
let mnemonic = "Helloworld"; | ||
let password = "Helloworld"; | ||
|
||
// Encrypt the mnemonic | ||
let encrypted_data = encrypt_mnemonic(&mnemonic, password); | ||
let encrypted_data = encrypt_mnemonic(mnemonic, password); | ||
assert!(encrypted_data.is_ok()); | ||
let encrypted_data = encrypted_data.unwrap(); | ||
|
||
// Decrypt the mnemonic | ||
let decrypted_mnemonic = decrypt_mnemonic(&encrypted_data, password); | ||
assert!(decrypted_mnemonic.is_err()); | ||
assert!(decrypted_mnemonic.is_ok()); | ||
let decrypted_mnemonic = decrypted_mnemonic.unwrap(); | ||
|
||
// Verify that the error is due to parsing and not padding | ||
assert!(decrypted_mnemonic | ||
.unwrap_err() | ||
.to_string() | ||
.contains("mnemonic contains an unknown word (word 11)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep this test as it was as it covers the case of making sure padding works fine. You can use Mnemonic::parse_normalized
to make it work as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some discussions with @mariocynicys , we should do that and also enable HD wallet by default even if it's a breaking change. We don't want new iguana users in the future. We can work on that on another PR. |
Do we have export priv key rpc and such feature in mobile/web apps? |
We don't have it when hd wallet is enabled, we should add it as any number of custom addresses unrelated to the HD tree of accounts and addresses. Can you please open an issue for it @laruh? |
Could you tell methods which export-import privkey for Iguana please? I cant find it in dispatcher files. |
There is no per coin import of private keys since iguana only supports one address per coin from the seed mm2 started with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Only one nit.
* dev: (35 commits) fix(crypto): allow non bip39 mnemonics storage (KomodoPlatform#2312) fix(legacy_swap): check for existing maker/taker payment before timeout (KomodoPlatform#2283) feat(tendermint): validators RPC (KomodoPlatform#2310) chore(CI): validate Cargo lock file (KomodoPlatform#2309) test(P2P): add test for peer time sync validation (KomodoPlatform#2304) fix mm2_p2p dev build (KomodoPlatform#2311) update Cargo.lock (KomodoPlatform#2308) chore(CI): unlock wasm-pack version (KomodoPlatform#2307) add `wasm` feature on WASM for timed-map (KomodoPlatform#2306) replace broken rpc link (KomodoPlatform#2305) chore(eth-websocket): remove some unnecessary wrappers (KomodoPlatform#2291) improvement(CI): switch to proper rust caching (KomodoPlatform#2303) fix(wasm): add test-ext-api feature to mm2_main and mm2_bin_lib tomls (KomodoPlatform#2295) chore(ci): Update docker build for wasm (KomodoPlatform#2294) chore(p2p): follow-up nits (KomodoPlatform#2302) feat(p2p): ensure time synchronization in the network (KomodoPlatform#2255) bump libp2p (KomodoPlatform#2296) chore(adex-cli): use "Komodo DeFi Framework" name in adex_cli (KomodoPlatform#2290) chore(ctx): replace gstuff constructible with oncelock (KomodoPlatform#2267) don't rely on core (KomodoPlatform#2289) ...
Fixes an issue where passphrases were incorrectly validated as BIP39 mnemonics during storage decryption. Now, passphrases no longer require mnemonic validation.