Metamask: Why does the BIP44 derivation path generate the same address in MetaMask as the Ledger Live derivation path?

Understanding the derivation path in Metamask: a comparison between LED LIVE and BIP44

As a user of the popular Metamask for cryptocurrency, you probably noticed that you will like the same address for Live and Bitcoin Integration Ledger derivation path (Bip44). But why is it so? In this article we will examine the base of Metamask code to understand what happens behind the scenes.

The process of derivation

The entry paths are used in cryptocurrency letters to encode the private key of a user in different addresses. The most common course of derivation is Bip44 (proposal to improve Bitcoin 44), which divides the private keys into six children: `m/44 '/60'/0/,m/44 '/61'/ 1/ //etc. These subordinate addresses can therefore be combined to generate a single address.

The bag for live letters and Metamask has shown several derivation paths, as shown in the following code -Snipper:

`Javascript

Const Ledger_live_path = m/44 '/60'/0 '/0/0;

Const Bip44_path = m/44 '/...

Note thatbip44_pathuses a different prefix ( m/) and a slightly different structure for subordinate addresses.

The metamask code

In the basis of the Metamask code we can see how the derivation paths are codified at an address:

Javascript

Const Generatess = (Path) => {

Const [address] = path.plit (‘/’);

Return $ {address}/$ {Getchildren (address)};

};

Const Getchildren = (address) => {

// We assume for reasons of simplicity, this function extracts the child faces from a bip44 path

// in reality this would include the analysis of the bip44 output and the extraction of individual components of the address

Const Children = [];

For (be i = 1; i

Kinder.push (address.substring (i, i + 8));

}

Return the children;

};

`

This "Getchildren" function takes a bip44 path as input and returns a number of subordinate addresses. These subordinate addresses are therefore divided into the final address.

Because the same path of derivation in both wallets

After understanding how to work, let's see why Metamask generates the same address for Live and Bip44 -Levitung routes:

In the "Generatess" function, we simply take a bip44 path as input and divide it into individual addresses using the Schapers/. We therefore chained the addresses of these children to form the final address.

The main visibility here is that during the coding of a bip44 path we can treat each address for children independently in an address. In other words, if we have a pathm/44 ‘/60’/0/0bip44, corresponds to a single address with four parts: m/44 '/60'/ 0/.

In the basis of the Metamask code, we do not explicitly codify any subordinate address to a single address. Instead, we deal with the entire derivation path as a whole and chain the resulting addresses.

As a result, both the master book and the bip44 removal paths generate the same address in Metamask. This may appear initially against, but in reality it is the result of how Metamask deals with the coding of the bip44 paths in the addresses.

Diploma

If you understand the base of the Metamask code, you can appreciate how the portfolio generates addresses for tachometer and bip44 -Aventorgage. Recognizing the differences in the Bip44_path is Ledder_live_path`, we can see that the implementation of Metamask is actually equivalent, even if it uses a different prefix and structure.

If you work with Metamask or other wallets in the future, you can estimate the underlying mechanics that work perfectly.

decentralised layer bullish

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *