Former End User Consultant, Current Software Developer, and a Master's degree holder in Data Science and Engineering.
The sequence of steps to generate a bitcoin address are:
bcoin.HDPrivateKey.generate()
method."use strict"
const { base58 } = require("bstring")
const bcoin = require("bcoin")
const bcrypto = require("bcrypto")
// Generate public key using bcoin
const publicKey = bcoin.HDPrivateKey.generate().publicKey
// Generate publicKeyHash
const publicKeyHash = bcrypto.RIPEMD160.digest(bcrypto.SHA256.digest(publicKey))
// Base58 check encoding
const addressVersionByte = Buffer.concat([Buffer.alloc(1), publicKeyHash])
const addressVersionByteHash = bcrypto.SHA256.digest(
bcrypto.SHA256.digest(addressVersionByte)
)
const checksum = addressVersionByteHash.slice(0, 4)
const address25Byte = Buffer.concat([addressVersionByte, checksum])
// Base58 encoded bitcoin address, starts with '1'
const addressBase58Encoded = base58.encode(address25Byte)
console.log(`Public key: ${publicKey.toString("hex")}`)
console.log(`Address: ${addressBase58Encoded}`)