Bitcoin Forum
September 22, 2026, 10:30:11 AM *
News: Latest Bitcoin Core release: 31.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: The Electrum passphrase is not compatible with the modified iancoleman script  (Read 73 times)
Forsyth Jones (OP)
Legendary
*
Offline

Activity: 2030
Merit: 2269


I love Bitcoin!


View Profile WWW
September 20, 2026, 11:41:38 PM
Merited by pooya87 (5)
 #1

I had already done such an experiment with iancoleman, modifying some lines of code following the instruction in this post at the time I imported my Electrum wallet (electrum seed version) into Bitcoin Core via descriptors. During the tests, I noticed that such a modification works well, until it came time to test a passphrase, iancoleman doesn't recognize it and creates another wallet instead, with different extended private keys, WIF keys, and addresses...

I had to dump the extended private key from Electrum console, convert it from the p2wpkh format (zpriv) to standard (xpriv) to build the descriptor and import it into Bitcoin Core. This can be done directly in the Electrum console via convert_xkey or Python tools.

These days I was reconstructing the steps again, testing new Electrum test seeds, and I remembered that only when you insert a passphrase with special characters into the modified iancoleman does it not derive that specific Electrum + passphrase wallet the same way that electrum does.

Does anyone know why there is this difference between BIP39 passphrase and Electrum passphrase?

How does each version handle the bytes, resulting in different wallets?

test of an Electrum seed without passphrase:

         

test of an Electrum seed with passphrase: DYIlv7UOM/hX/GSJQt9Ti


nc50lc
Legendary
*
Offline

Activity: 3276
Merit: 9182


Self-proclaimed Genius


View Profile
September 21, 2026, 04:42:29 AM
Last edit: September 21, 2026, 04:55:36 AM by nc50lc
Merited by pooya87 (7), Forsyth Jones (5), hosemary (2), notocactus (1)
 #2

Does anyone know why there is this difference between BIP39 passphrase and Electrum passphrase?
Hmm, replacing "mnemonic" into "electrum" should've done the trick.

What I've found so far:
  • It seems to be working on alpha-numeric characters like "abc123" but not with some special characters like your example passphrase.
  • IanColeman's tool, on the other hand, supports such passphrase and working without issue with BIP39 seed.
  • I've tested and compared HCP's and IanColeman's code and it's only the default/prepended passphrase "electrum" that's changed.

I'm thinking that it may have been a special normalization done by Electrum that's not present in BIP39 standard.
For that, Electrum's code should be checked instead. (I'll check it real quick)

-update-

Okay, so it's indeed the difference between the two standard's normalization, not the special characters:

In IanColeman's tool: passphrase = self.normalizeString(passphrase)
whereas normalizeString is purely based on NFKD.

In Electrum: The passphrase is normalized via normalize_text which includes turning all characters into lower-case.
Ref:
/spesmilo/electrum/blob/master/electrum/mnemonic.py#L175
/spesmilo/electrum/blob/master/electrum/mnemonic.py#L81

Now, to reproduce the correct keys/addresses: simply convert the passphrase's upper-case letters into lower-case before entering it to the modified tool.
In your case, from DYIlv7UOM/hX/GSJQt9Ti into dyilv7uom/hx/gsjqt9ti

Or, adapt Electrum's normalization to your modified IanColeman BIP39 tool.

Forsyth Jones (OP)
Legendary
*
Offline

Activity: 2030
Merit: 2269


I love Bitcoin!


View Profile WWW
September 21, 2026, 07:58:01 PM
 #3

-snip-
Okay, so it's indeed the difference between the two standard's normalization, not the special characters:

In IanColeman's tool: passphrase = self.normalizeString(passphrase)
whereas normalizeString is purely based on NFKD.

In Electrum: The passphrase is normalized via normalize_text which includes turning all characters into lower-case.
Ref:
/spesmilo/electrum/blob/master/electrum/mnemonic.py#L175
/spesmilo/electrum/blob/master/electrum/mnemonic.py#L81

Now, to reproduce the correct keys/addresses: simply convert the passphrase's upper-case letters into lower-case before entering it to the modified tool.
In your case, from DYIlv7UOM/hX/GSJQt9Ti into dyilv7uom/hx/gsjqt9ti

Or, adapt Electrum's normalization to your modified IanColeman BIP39 tool.
I did it, that's right.



So that was it, Electrum isn't differentiates between uppercase and lowercase letters, while BIP39 is case-sensitive. I thought the problem was with special characters.

The script with the modified lines also supports characters with words normally, even with spaces, for instance: truck bulb food... but if there are uppercase characters, compatibility is broken.

It seems that the iancoleman tool, even with the modified lines, when there is a passphrase with uppercase and lowercase letters, it doesn't transform all the typed characters into lowercase letters like the Electrum software does...

That's great, let it be recorded here then, in case anyone needs it, just convert all the uppercase letters of the passphrase to lowercase.

nc50lc
Legendary
*
Offline

Activity: 3276
Merit: 9182


Self-proclaimed Genius


View Profile
Today at 04:51:01 AM
 #4

That's great, let it be recorded here then, in case anyone needs it, just convert all the uppercase letters of the passphrase to lowercase.
I though you'd update your modified IanColeman tool with the references I've linked.

If it's just the extra steps after normalization;
Just add another function that'll be used exclusively to normalize the passphrase. (originally, mnemonic and passphrase use the same function)

First, add this below "normalizeString" function (or write a better alternative):
Code:
    self.normalizePassphrase = function(str) {
var normalized = str.normalize("NFKD");
var removeaccent = normalized.replace(/[\u0300-\u036f]/g, "");
return removeaccent.toLowerCase();
    }
Ref: Accents normalization (the third line) is based from: stackoverflow.com/a/37511463

And then; in "toSeed" function, add this above "passphrase = self.normalizeString(passphrase)":
Code:
		passphrase = self.joinWords(self.splitWords(passphrase));
That'll use BIP39 tool's existing whitespace normalization code. (Electrum strips extra whitespaces if there's more then one)
However, Electrum also covers CJK (Chinese/Japanese/Korean) but IanColeman's only supports Japanese among the three.

And lastly, below it, replace:
passphrase = self.normalizeString(passphrase)
with that newly added function:
passphrase = self.normalizePassphrase(passphrase)

Note: I haven't done more extensive tests, just a few variations of your passphrase like "DáIlv7  UOM/hX/GôSJQ   t9Tiç" for quick testing (address matched)

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!