Created
November 19, 2021 18:18
-
-
Save mattm/cbc93312213e291c541a610d89920524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative "base58" | |
def bytes_to_base58(bytes) | |
hex = bytes.pack("C*").unpack("H*").first | |
Base58.encode(hex) | |
end | |
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