Welcome to BlockDAG Dashboard! πŸ‘‹

notification0
Notifications
logout

Dev Release 39

May 27, 2024

Greetings BlockDAG Community,

 

Understanding Address Formats in BlockDAG

 

In the dynamic world of blockchain, you will encounter various address formats, particularly when dealing with Directed Acyclic Graphs (DAGs) and hierarchical deterministic wallets (BIP32). This post aims to demystify these address formats, elucidate their functionality within respective blockchain systems, and provide insights into the underlying algorithms and mathematical formulas.

Address Formats in BlockDAG

The address format in BlockDAG systems can vary based on specific implementations. However, some common features include:

 

Base58 Encoding

Many BlockDAG systems utilize Base58 encoding to create user-friendly addresses, avoiding ambiguous characters.

Example: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
 

Checksum
Addresses often include a checksum to detect errors, ensuring the validity of the address.

 

Prefix
Different types of addresses (e.g., standard, multi-signature) may have distinct prefixes.
Example: Bitcoin addresses starting with 1 for P2PKH, 3 for P2SH, and bc1 for Bech32.

 

BIP32: Hierarchical Deterministic Wallets

BIP32 (Bitcoin Improvement Proposal 32) introduced hierarchical deterministic (HD) wallets, which allow for the generation of a tree of keys from a single seed. This innovation simplifies wallet backup and enhances security.

 

  1. Master Seed

A random seed is generated, typically from a mnemonic phrase.
Example: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about

 

2. Master Key Derivation
From the seed, a master private key and master chain code are derived using HMAC-SHA512.
(π‘˜π‘š,π‘π‘š)=π»π‘€π΄πΆβˆ’π‘†π»π΄512(𝑏,𝑆)
where 𝑏  is the constant "Bitcoin seed".

 

3. Child Key Derivation
Child keys are derived from the master key using a deterministic algorithm. Each child key pair (private key, chain code) is generated using:
(π‘˜π‘–,𝑐𝑖)=𝐢𝐾𝐷(π‘˜π‘,𝑐𝑝,𝑖)where π‘˜ 𝑝 k p ​ is the parent private key, 𝑐 𝑝 c p ​ is the parent chain code, and 𝑖 i is the index of the child key.
 

4. Child Key Derivation Function (CKD)
For normal child keys:
𝐢𝐾𝐷(π‘˜π‘,𝑐𝑝,𝑖)=π»π‘€π΄πΆβˆ’π‘†π»π΄512(𝑐𝑝,π‘ π‘’π‘Ÿ(π‘˜π‘)βˆ₯π‘ π‘’π‘Ÿ(𝑖))For hardened child keys (with index 𝑖β‰₯231𝐢𝐾𝐷(π‘˜π‘,𝑐𝑝,𝑖)=π»π‘€π΄πΆβˆ’π‘†π»π΄512(𝑐𝑝,0π‘₯00βˆ₯π‘˜π‘βˆ₯π‘ π‘’π‘Ÿ(𝑖))
 

5. Address Generation
Public keys are derived from private keys:
𝐾𝑖=π‘˜π‘–β‹…πΊwhere G is the generator point on the elliptic curve. Addresses are generated from public keys, often using Base58Check encoding or Bech32 encoding.
 

Mathematical Formulas and AlgorithmsHMAC-SHA512
HMAC-SHA512 is used to derive keys and chain codes:

HMACβˆ’SHA512(key,message)=SHA512((keyβŠ•opad)βˆ₯SHA512((keyβŠ•ipad)βˆ₯message))

 

where opad is the outer padding (0x5c5c...5c5c, repeated to block size) and ipad is the inner padding (0x3636...3636, repeated to block size).

 

Base58Check Encoding
Base58Check Encoding is used for user-friendly addresses:
 

  1. Add version byte in front of the data.
  2. Compute the double SHA-256 hash of the version and data.
  3. Take the first 4 bytes of the hash; this is the checksum.
  4. Append the checksum to the version and data.
  5. Encode the resulting byte string in Base58.

Bech32 Encoding
Bech32 Encoding is used for SegWit addresses:
 

  1. Divide the input data into 5-bit chunks.
  2. Compute the checksum using the polymod algorithm.
  3. Append the checksum to the original data.
  4. Encode the result using the Bech32 character set.

 

 

Conclusion
Understanding the various address formats in BlockDAG systems and BIP32 hierarchical deterministic wallets is crucial for navigating the diverse landscape of blockchain technology. BlockDAG addresses enhance scalability and throughput with their graph-like structure, while BIP32 simplifies key management and backup through its hierarchical design. Each format offers unique benefits, tailored to the specific needs of the blockchain system it supports. Whether you are working with a BlockDAG implementation or managing a BIP32 HD wallet, mastering these details, algorithms, and mathematical formulas will enhance your ability to effectively utilize blockchain technology.

BlockDAG LogoBlockDAG Logo