Skip to content

Instantly share code, notes, and snippets.

@abom
Created July 16, 2021 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abom/82d3146cf855315589c82407731dcfd3 to your computer and use it in GitHub Desktop.
Save abom/82d3146cf855315589c82407731dcfd3 to your computer and use it in GitHub Desktop.
Get bytes from ed25519 key seed
import sys
from jumpscale.loader import j
def from_seed(seed):
seed = seed.strip()
if seed.startswith("0x"):
seed = seed[2:]
seed_bytes = bytes.fromhex(seed)
return j.data.nacl.SigningKey(seed_bytes)
def print_key(key):
pub_key_bytes = [b for b in key.verify_key.encode()]
priv_key_bytes = [b for b in key.encode()]
print("public key: ", pub_key_bytes)
print("private key: ", priv_key_bytes)
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <seed as hex>")
else:
try:
print_key(from_seed(sys.argv[1]))
except Exception as e:
print(f"Error while loading key: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment