What is the difference between (1) enabling the passphrase option when creating the wallet from the beginning, and (2) creating a standard wallet first and only adding the passphrase later when importing the seed?
Nothing much in its keystore derivation process, it just the result that will obviously be different since the data you input are different.
Under the hood, Electrum does the same to the seed phrase and passphrase or seed phrase w/o a passphrase:
When creating the binary seed, it takes the seed phrase (
mnemonic) and "
electrum+<passphrase>" as salt; in case there's no passphrase, the salt is just "
electrum"
And pass those to 2048 rounds of PBKDF2 HMAC-SHA512 algorithm.
Here's how it looks in the code:
spesmilo/electrum/mnemonic.py#L170-L175Just to stretch this a bit for OP.
PBKDF2 algorithm requires two inputs.One of those is 'mnemonic' while the other is 'salt'. In the case of OP when he prefered not to set the passphrase, 'salt'equals to string "mnemonic". However, if OP provided the passphrase, let's say "bla_bla_bla", the salt becomes the concatenation of "mnemonic" and the passphrase, resulting in "mnemonicbla_bla_bla". Essentially, the passphrase is appended to the "mnemonic" string to form the salt.