Skip to content

fix: normalize polyseed passphrases with NFKD - #11

Open
o-mid wants to merge 1 commit into
cake-tech:trunkfrom
o-mid:fix/nfkd-passphrase
Open

o-mid wants to merge 1 commit into
cake-tech:trunkfrom
o-mid:fix/nfkd-passphrase

Conversation

@o-mid

@o-mid o-mid commented Nov 9, 2026 •

Copy link
Copy Markdown

Summary

crypt() hashed the passphrase as raw UTF-8. Monero normalizes it to NFKD first, and keeps at most 575 bytes, before the same KDF. A passphrase that NFKD changes, such as contraseña, encrypts a seed that monero-wallet-cli restores as a different empty wallet. Polyseed has no MAC, so the restore does not fail.

ASCII passphrases are unchanged, including the existing C-suite vector for password. An all-ASCII passphrase longer than 575 bytes now uses the first 575 bytes. A non-ASCII passphrase whose NFKD form does not fit in 575 bytes is rejected, which is what Monero does.

This is cake-tech/cake_wallet#3722. Cake pins polyseed at 1a8280ac2b6f01d202d8bff71527fe1ce498c4ed in pubspec_overrides.yaml, so the wallet picks this up when that ref moves to the merge commit. Version is 0.0.8.

Test plan

  • dart test (84 passed, 7 skipped, the skips were already there)
  • test/polyseed_password_test.dart failed on trunk before this change:
    • contraseña, 비밀번호, パスワード, and pässwörd now encrypt the same phrase as their NFKD form
    • an ASCII passphrase longer than 575 bytes matches its 575-byte prefix
    • 200 ñ characters, whose NFKD form is longer than 575 bytes, throws PasswordTooLongException

Monero normalizes the passphrase to NFKD and keeps at most 575 bytes before the KDF. crypt() was hashing the raw UTF-8, so a passphrase like contraseña encrypted a seed that Monero restores as a different wallet.
@o-mid

o-mid commented Nov 12, 2026

Copy link
Copy Markdown
Author

@OmarHatem28 polyseed passphrases are normalized with NFKD in this one. Open since Nov 9 with no review. Could you look?

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