crypto-lite Gem Update - New Examples / Cookbook - Bitcoin (Base58) Address Generation form the (Elliptic Curve) Public Key Made Easy - Inside the Magic Bubble Machine


  I've added a new examples / cookbook section to the little
crypto-lite gem / library [1].

  The first example is a look inside the magic bubble machine
  and shows you how to generate / calculate the bitcoin (base58) address
  form the (elliptic curve) public key in 1-2-3 steps. [2]

From the readme:

Let's try again with the shortcut helpers:

- `HASH160 - RMD160(SHA256(X))`
- `BASE58CHECK - BASE58(X || SHA256(SHA256(X))[:4])`

# Lets start with the public key ("raw" hex string encoded)
pk = "0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352"

# 1. Perform HASH-160 hashing on the public key
#    a) Perform SHA-256 hashing on the public key
#    b) Perform RIPEMD-160 hashing on the result of SHA-256
step1 = hash160( pk )
#=> "f54a5851e9372b87810a8e60cdd2e7cfd80b6e31"

# 2. Add version byte in front of RIPEMD-160 hash (0x00 for Main Network)
step2 = "00" + step1
#=> "00f54a5851e9372b87810a8e60cdd2e7cfd80b6e31"

# 3. Encode with BASE58CHECK
#    a) Perform SHA-256 hash on the extended RIPEMD-160 result
#    b) Perform SHA-256 hash on the result of the previous SHA-256 hash
#    c) Take the first 4 bytes of the second SHA-256 hash. This is the
address checksum
#    d) Add the 4 checksum bytes at the end of
#       extended RIPEMD-160 hash from step 2.
#       This is the 25-byte binary Bitcoin Address.
#    e) Convert the result from a byte string into a base58 string
#       using Base58 encoding.
#       This is the most commonly used Bitcoin Address format.
addr  = base58check( step2 )
#=> "1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs"

  Cheers. Prosit 2021!

PS: Bitcon Tip - How to Buy Bitcoin (The CO₂-Friendly Way)

1. Take one $50 bill, five $10 bills, or ten $5 bills (I wouldn't
recommend change - stay with paper money).
2. Go to the bathroom.
3. Lift the lid of the loo.
4. Throw money in.
5. Flush down water.

Congrats! You just purchased $50 worth of Bitcoin - without fucking
the planet!

  -- Trolly McTrollface, Bitcon Greater Fool Court Jester