Created
July 16, 2021 14:48
-
-
Save abom/82d3146cf855315589c82407731dcfd3 to your computer and use it in GitHub Desktop.
Get bytes from ed25519 key seed
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
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