Skip to content

Instantly share code, notes, and snippets.

@jhoenicke
Created August 26, 2018 10:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhoenicke/939e58e26bc54ef46616a680eadcc368 to your computer and use it in GitHub Desktop.
Save jhoenicke/939e58e26bc54ef46616a680eadcc368 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import hashlib
import binascii
import os
from trezorlib import log
from trezorlib.client import TrezorClient
from trezorlib.transport import get_transport
from trezorlib.tools import parse_path
class TrezorEntropySender(TrezorClient):
def __init__(self, transport):
super(TrezorClient, self).__init__(transport=transport)
def _get_local_entropy(self):
entropy = input("Enter Entropy: ")
entropy = entropy.encode()
return entropy
def main():
passphrase_protection = False
pin_protection = True
# 128 = 12 words, 192 = 18 words, 256 = 24 words.
strength = 256
label = input("Label: ")
path = os.environ.get('TREZOR_PATH')
transport = get_transport(path)
client = TrezorEntropySender(transport)
client.reset_device(True, strength, passphrase_protection, pin_protection, label, 'english');
client.close()
if __name__ == '__main__':
main()
import binascii
import hashlib
from mnemonic import Mnemonic
def main():
entropy_int = input("Internal Entropy: ")
entropy_ext = input("External Entropy: ")
entropy_int = binascii.unhexlify(entropy_int)
entropy_ext = entropy_ext.encode()
entropy = hashlib.sha256(entropy_int + entropy_ext).digest()
print("Raw entropy: ", binascii.hexlify(entropy))
mnemo = Mnemonic("english")
print(mnemo.to_mnemonic(entropy))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment