Created
August 26, 2018 10:44
-
-
Save jhoenicke/939e58e26bc54ef46616a680eadcc368 to your computer and use it in GitHub Desktop.
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
#!/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() |
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 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