Ethereum: How does Electrum make a keypair out of a seed?

Understanding Ethereum’s Hierarchical Arbitrarily Deep Key Exchange (HA-DPKG) System with Electrum

Ethereum: How does Electrum make a keypair out of a seed?

As the primary wallet for the Ethereum blockchain, Electrum provides users with a secure way to store and manage their private keys. One of the key features that sets Electrum apart from other wallets is its Hierarchical Arbitrarily Deep Key Exchange (HA-DPKG) system, which generates a unique public-private key pair from a seed, allowing users to create multiple addresses on the blockchain. In this article, we will delve into how Electrum generates a keypair out of a seed and explore the inner workings of HA-DPKG.

Generating a Keypair from a Seed

To generate a keypair with Electrum, you need to provide it with a seed, which is a 12-word phrase used as the first part of your public-private key. The seed serves as a password or passphrase that controls access to your Ethereum account. When you create an Electrum wallet, Electrum asks for your seed in a specific format:

M/0'/0 /M/0'/1 *2^20'/0 /M/0'/12

In this example, the first part /M/0 represents the initial data of the seed (a mix of bytes), and M/0' denotes the second byte. The rest of the string follows a specific format:

M/0'/n1 *2^n /M/n

The *2^n indicates that this is an index 2 raised to the power of n. For example, if you provide a seed like “G4pBQx8Hj9fRtVwLqyL3ZgT2vDf” with n=1, Electrum will generate a keypair as follows:

M/0'/0 /M/0'/1 *2^20'/0 /M/0'/12

The resulting public-private key pair consists of 36 bytes.

Hierarchical Address Generation

Once you have generated your keypair, Electrum uses it to create a hierarchy of addresses that can be used for transactions on the Ethereum network. To do this, Electrum takes each byte of the seed and assigns it a specific role in creating a hierarchical address (HA). The roles are:

  • M/0: This represents the initial data of the seed.

  • n1: The second byte is assigned to n1.

2^n: Each subsequent byte is assigned to n1, with n1 being one more than the previous value.

Using this hierarchical approach, Electrum generates a sequence of HA addresses from your keypair. For example:

0x00 01 02 03 ... (M/0)

*2^20'00 = 00101010101010

*2^21'00 = 011110111100

*2^22'00 = 000101101000

*2^23'00 = 1000000000000

1x... (n1, n1+1, ...)

Address 0: 0x01 02 03 *2^20'

Address 1: 0x11 12 13 *2^21'

...

These HA addresses can be used for various purposes on the Ethereum network, such as creating a wallet address or generating a contract address.

Conclusion

In conclusion, Electrum’s use of a seed to generate a keypair allows users to create multiple addresses on the Ethereum blockchain. By understanding how Electrum generates these keypairs and hierarchically extracts addresses from them, you can better grasp the inner workings of HA-DPKG and improve your overall experience with this popular wallet.

DASH DASH MINING MOVEMENT MOVE

Leave a Reply

Your email address will not be published. Required fields are marked *