Bitcoin Forum
March 28, 2024, 09:42:53 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Features of the formation of BIP39 in electrum above version 2.0  (Read 98 times)
Sanka555 (OP)
Member
**
Offline Offline

Activity: 96
Merit: 36


View Profile
September 21, 2021, 05:58:31 AM
Merited by o_e_l_e_o (4), ABCbits (3), pooya87 (1), Pmalek (1), NotATether (1)
 #1

I have a simple Javacode to create bip39 standard:
https://github.com/NovaCrypto/BIP39/blob/master/src/main/java/io/github/novacrypto/bip39/MnemonicGenerator.java
But it does not create what electrum needs above version 2
Having dug up the documents, it was found out that:
Quote
Electrum 2.0 derives keys and addresses from a hash of the UTF8 normalized seed phrase with no dependency on a fixed wordlist. This means that the wordlist can differ between wallets while the seed remains portable, and that future wallet implementations will not need today’s wordlists in order to be able to decode the seeds created today. This reduces the cost of forward compatibility.
https://electrum.readthedocs.io/en/latest/seedphrase.html#version-number

you just need to add the version number while calculating the phrase.
it should be very simple. But how?
How exactly do I need to change 'this code to get a new kind of seeds?

I will be very grateful for any help.
1711618973
Hero Member
*
Offline Offline

Posts: 1711618973

View Profile Personal Message (Offline)

Ignore
1711618973
Reply with quote  #2

1711618973
Report to moderator
1711618973
Hero Member
*
Offline Offline

Posts: 1711618973

View Profile Personal Message (Offline)

Ignore
1711618973
Reply with quote  #2

1711618973
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1711618973
Hero Member
*
Offline Offline

Posts: 1711618973

View Profile Personal Message (Offline)

Ignore
1711618973
Reply with quote  #2

1711618973
Report to moderator
1711618973
Hero Member
*
Offline Offline

Posts: 1711618973

View Profile Personal Message (Offline)

Ignore
1711618973
Reply with quote  #2

1711618973
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3402
Merit: 10433



View Profile
September 21, 2021, 07:00:23 AM
Last edit: September 22, 2021, 09:03:00 AM by pooya87
Merited by ABCbits (6), o_e_l_e_o (4), Pmalek (2), NotATether (2), hosseinimr93 (1)
 #2

Start by looking at the open source code here: https://github.com/spesmilo/electrum/blob/master/electrum/mnemonic.py

The differences between BIP39 and Electrum mnemonic algorithm from the top of my head are:
1. String normalization
BIP39 uses a very simple normalization while Electrum significantly modifies the mnemonic (and passphrases) before converting them to bytes to be hashed.
2. Checksum
BIP39 computes SHA256 hash of the entropy and appends enough bits as padding to make the entropy divisible by 11. Electrum uses a bigger entropy (132 bits by default but it can be anything which will affect the word length and can use different word-lists of any length) and computes its HMACSHA512 and checks if the starting bits are what the wallet type demands.
3. Conversion of words to BIP32 seed
BIP39 uses PBKDF2 with the word "mnemonic" added before passphrase but Electrum uses the same PBKDF2 using the word "electrum" added before passphrase.

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
NotATether
Legendary
*
Offline Offline

Activity: 1554
Merit: 6532


bitcoincleanup.com / bitmixlist.org


View Profile WWW
September 22, 2021, 07:37:56 AM
Last edit: September 22, 2021, 06:00:29 PM by NotATether
Merited by o_e_l_e_o (4), pooya87 (2), ABCbits (1), nc50lc (1), hosseinimr93 (1)
 #3

you just need to add the version number while calculating the phrase.
it should be very simple. But how?
How exactly do I need to change 'this code to get a new kind of seeds?

BIP39 seeds don't have a version number, so you shouldn't be trying to generate both kinds of phrases in the same class/method.

The first "nibble" (groups of 4 bits) of an Electrum version, plus 2, tells you how many nibbles are in the version hex.

i.e. 0x01 version is (0+2) nibbles long = 8 bits,
and 0x100 version is (1+2) nibbles long = 12 bits (same as 0x101).

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18497


View Profile
September 22, 2021, 09:00:34 AM
Merited by pooya87 (1), hosseinimr93 (1), NotATether (1)
 #4

If you are using that script to generate a mnemonic, then you can import it in to Electrum and check the box labelled "BIP39 seed" under "Options" on the page you enter the seed phrase. Electrum will then generate the same addresses (given the same derivation path) as your script.

BIP39 uses PBKDF2 with the word "mnemonic" appended to passphrase but Electrum  uses the same PBKDF2 using the word "electrum" appended to the passphrase.
The passphrase (or an empty string) is appended to "mnemonic"/"electrum", not the other way around.

The first bit of an Electrum version
The first four bits.
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!