Ethereum: How does the client know the number of keys and coins when recovering from a seed?

How Ethereum Clients Find Out Which Keys and Coins Are Associated with a Seed

Ethereum clients use a process called “seed recovery” to recover the private keys associated with a seed. When you have a seed, it’s a string of characters that uniquely identifies your wallet and allows you to restore its contents. However, recovering from a seed can be challenging because there are an infinite number of possible seeds. This article will explain how Ethereum clients determine which keys and coins are associated with a given seed.

Ethereum: How does the client know the number of keys and coins when recovering from a seed?

Determining the Seed

First, Ethereum clients need to obtain a valid seed for the wallet they want to recover. A valid seed is generated randomly when you create a new wallet or import an existing one. To generate a seed, your wallet provider (such as MetaMask) will use a random number generator to produce a series of numbers that are then combined with a timestamp and other information.

Generating a Seed Hash

The client then uses a cryptographic hash function (such as SHA-256) to combine the seed with the timestamp. This creates a fixed-length string called a “seed hash.” The seed hash is typically around 32-64 characters long.

Recovering the Wallet Address

Once you have obtained the seed hash, your Ethereum client will use it to recover the wallet address associated with your private keys. To do this, your client will:

  • Look up the seed hash in a table or database (known as a “seed table”).

  • Use the seed hash and other information (such as the timestamp) to generate a new public key.

  • Use the new public key to derive the corresponding private key.

Finding Out Which Keys Are Associated with Each Coin

Now that you have recovered your wallet address, you can find out which keys are associated with each coin by using the following steps:

  • Retrieve the list of available coins (known as a “list of coins”).

  • For each coin, check if it exists in the seed table.

  • If the coin exists, add the corresponding public key and private key to your wallet.

Example Walkthrough

Here’s an example walkthrough of how Ethereum clients might recover from a seed:

Let’s say you have a seed hash: 0x1234567890abcdef. Your client has created a new wallet with a private key: 0x1234567890123456.

To recover the wallet address, your client uses the seed hash to generate a new public key and derive the corresponding private key. The new public key is: 0x1abcdef

Your client then checks if this public key exists in the list of coins:

  • Bitcoin (BIP-44): 0x1234567890abcdef

  • Ethereum (EIP-1559): 0x9876543210987654

  • Other coins…

Since the public key does not exist for Bitcoin and Ethereum, your client knows that only the remaining coin exists in the seed table.

Your client adds the corresponding private key to your wallet: 0x1234567890123456.

This is a basic example of how Ethereum clients recover from a seed. The process can be more complex, especially when dealing with multiple coins and advanced cryptographic techniques. However, it should give you an idea of how wallets recover their contents from seeds.

Tags: No tags

Comments are closed.