Skip to content

Instantly share code, notes, and snippets.

@hypefi
Created February 24, 2022 08:50
Show Gist options
  • Save hypefi/e6c39192a5762a1275328937778c7ff4 to your computer and use it in GitHub Desktop.
Save hypefi/e6c39192a5762a1275328937778c7ff4 to your computer and use it in GitHub Desktop.
Solana Keypair from Solana CLI keypair.json
require "base58-alphabets"
def bytes_to_base58(bytes)
hex = bytes.pack("C*").unpack("H*").first
# puts hex
Base58.encode_hex(hex)
end
keypair_bytes = [14,243,24,200,213,51,37,191,44,30,242,109,48,162,226,114,108,22,1,200,234,13,47,150,230,200,67,72,253,38,46,182,39,131,0,213,85,248,100,98,187,187,62,244,30,242,237,146,4,137,168,1,10,189,202,223,200,4,61,9,115,85,101,167]
private_key_bytes = keypair_bytes[0, 32]
public_key_bytes = keypair_bytes[32..-1]
puts "Keypair:", bytes_to_base58(keypair_bytes)
puts "\nPublic Key:", bytes_to_base58(public_key_bytes)
puts "\nPrivate Key:", bytes_to_base58(private_key_bytes)
@hypefi
Copy link
Author

hypefi commented Feb 24, 2022

keypair_bytes are dummy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment