+251 93 757 3707

Bitcoin: given an address format, return the derivation path or BIP used

Deciphering the Derivation Path of a Bitcoin Address

Hello, fellow Bitcoiners.

While studying Bitcoin, I came across a problem that I wanted to ask: how can I determine which derivation path a specific Bitcoin address 1xxxxxxxxxxx was created with? In this article, I will provide insights on how to infer the derivation path of a given address.

Understanding the Bitcoin Address Format

Before diving into the derivation path, let’s quickly review how Bitcoin addresses are structured. A Bitcoin address consists of eight hexadecimal characters, divided into three parts:

  • Version: The first four characters represent the version of the Bitcoin protocol.
  • Checksum: The next two characters are a checksum, which is used to verify the integrity of the transaction data.
  • Index: The last four characters represent the index in the blockchain.

Diversion Paths

Bitcoin uses a cryptographic technique called Elliptic Curve Diffie-Hellman (ECDH) to derive private keys from public keys. The derivation path is based on the following rules:

  • For each derivation step, we need two shares:

+
Public Key: x

+
Shared Secret: the

Inferring Derivation Path from Address

Now, let’s apply these rules to infer the derivation path of a given address.

  • Check if the first four characters are a version number (0x…). If not, it is unlikely that the address is valid.
  • Extract the checksum (the last two characters) and verify its integrity using tools like the gethash command in the terminal or by checking with your local Bitcoin client.

If both checks pass, we can proceed to extract the index of the next four characters:

  • Take the last four characters (xxxxxxxxx) as an input to our ECDH derivation.
  • Calculate the corresponding shared secret y using a keygen such as secp256k1-gen.

Once you have y, you can derive its public key x by performing modular exponentiation with p-1 (where p is the maximum block weight of the network). This will produce another random number.

Step-by-Step Example

Suppose we have a valid address 1234567890abcdef, where:

  • The first four characters are not a version number.
  • The checksum is correct.
  • We have extracted the index of xxxxxxxxxxxx.

Here’s how we can calculate the shared secret and public key using Python code:

import hashlib


Set ECDH parameters

p = 1_000_000_007

Maximum block weight of the network (256 bits)

q = p * p

n = q - 1

e = 65537

d = e ** (-1)


Derive shared secret using BLS signature scheme

y = hashlib.blake2b((p, n) + ((hashlib.sha256(b'') + bytes([x])).digest(),)).digest()[:32]


Calculate public key x by modular exponentiation with p-1

public_key_x = pow(y, d, p - 1)


The derived private key y is our input to further derivation

Conclusion

In conclusion, deciphering the derivation path of a Bitcoin address requires knowledge of the ECDH algorithm and tools like `gethash’ to verify the checksum. By following these steps, you can infer the derivation path of a given address, which can be useful in various applications such as wallet verification or private key management.

However, please note that this is just a step-by-step example and may not cover all possible scenarios or edge cases. Always consult experts or use reliable sources when dealing with cryptographic systems.

I hope this article was helpful! Do you have any questions or would like to learn more about Bitcoin?

Leave a Reply

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

Contact Info

© 2024 Created by Meisour