We would like to encode ECDSA Public Key specifically keys generated using the ed25519 for storage .

What is the best and less error prone method , for now we think about using Hex strings or Base64 are there other encoding schemes that can be used ?

  • $\begingroup$ Hey can you make a sample for education purpose how to encode a bitcoin public key to base64 or hex by python ? TY $\endgroup$
    – Odermatt
    Dec 21, 2020 at 17:50

2 Answers 2


Sure, there are many ways. For instance, if you need to enter key manually, you may even prefer to split text representation into groups of 4 or more characters.

But I'd suggest you choose between SSH2 (RFC 4716) and OpenSSH format. Both use Base64 for key representation. Both have an advantage that they are supported by standard tools like ssh-keygen.

If you have multiple keys and want to more reliably distinguish them, I'd suggest SSH2 (RFC 4716), because it provides slightly better possibilities to comment.


There are a lot of different ways you could encode, but unless you are really sensitive to the length of the encoding, in my experience just going with Base64 is a good idea. Support for Base64 is pretty ubiquitous. However, there are different variants of Base64 (URL-safe vs. standard), which complicates things if you are exchanging the encoded keys with someone else. Make sure you specify your choice (like URL-safe base64 without padding - RFC7515).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.