Skip to content

Instantly share code, notes, and snippets.

Created November 19, 2021 18:18
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
require_relative "base58"
def bytes_to_base58(bytes)
hex = bytes.pack("C*").unpack("H*").first
keypair = "6Tyktf6mEqUMEKm2ZpLn3srEwk9zsT5jiE54EgPgToikMFYww1LGFUXgwgr6hvc9CikpaNaBH2vmkmqN3Usrxpd"
keypair_hex = Base58.decode(keypair).rjust(128, "0")
keypair_bytes = [keypair_hex].pack('H*').bytes.to_a
private_key_bytes = keypair_bytes[0, 32]
public_key_bytes = keypair_bytes[32..-1]
puts "Public Key:", bytes_to_base58(public_key_bytes)
puts "\nPrivate Key:", bytes_to_base58(private_key_bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment