mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 15:08:25 +00:00
bip85 child seeds via embit.bip85.derive_mnemonic()
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
embit==0.6.1
|
||||
embit==0.7.0
|
||||
numpy==1.21.1
|
||||
picamera==1.13
|
||||
Pillow==8.2.0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import unicodedata
|
||||
|
||||
from binascii import hexlify
|
||||
from embit import bip39, bip32
|
||||
from embit import bip39, bip32, bip85
|
||||
from embit.networks import NETWORKS
|
||||
from typing import List
|
||||
|
||||
@@ -121,25 +121,8 @@ class Seed:
|
||||
root = bip32.HDKey.from_seed(self.seed_bytes, version=NETWORKS[SettingsConstants.map_network_to_embit(network)]["xprv"])
|
||||
|
||||
# TODO: Support other bip-39 wordlist languages!
|
||||
# As per the BIP85 spec, 39 is the application number used for bip39 mnemonic,
|
||||
# we use the selected word count and the index to form the full path.
|
||||
path = "m/83696968'/39'/0'/{bip85_num_words}'/{bip85_index}'".format(
|
||||
bip85_num_words=bip85_num_words,
|
||||
bip85_index=bip85_index)
|
||||
|
||||
# Derive the child xprv (HDKey) using the path format defined above
|
||||
xprv = root.derive(path)
|
||||
|
||||
# The xprv.secret plus the BIP85 key is hashed together using hmac sha512.
|
||||
entropy = hmac.new(key=b'bip-entropy-from-k', msg=xprv.secret, digestmod=hashlib.sha512).digest()
|
||||
|
||||
# Calculate number of bytes to retain for the entropy
|
||||
# 24 words the width is 32bytes (256bits)
|
||||
# 12 words the width is 16bytes (128bits)
|
||||
width = round(bip85_num_words / 12 * 16)
|
||||
|
||||
# Return the derived BIP85 child mnemonic using the truncated derived entropy
|
||||
return bip39.mnemonic_from_bytes(entropy[:width])
|
||||
return bip85.derive_mnemonic(root, bip85_num_words, bip85_index)
|
||||
|
||||
|
||||
### override operators
|
||||
|
||||
Reference in New Issue
Block a user