1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-29 17:48:10 +00:00
trezor-firmware/mocks/trezor/crypto/bip39.py

38 lines
1.0 KiB
Python
Raw Normal View History

2016-09-27 14:48:21 +00:00
2017-04-08 16:43:26 +00:00
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
def find_word(prefix: str) -> str:
'''
Return the first word from the wordlist starting with prefix
'''
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
def complete_word(prefix: str) -> int:
'''
Return possible 1-letter suffixes for given word prefix
Result is a bitmask, with 'a' on the lowest bit, 'b' on the second lowest, etc.
'''
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
2016-09-27 14:48:21 +00:00
def generate(strength: int) -> str:
'''
Generate a mnemonic of given strength (128, 160, 192, 224 and 256 bits)
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
2016-09-27 14:48:21 +00:00
def from_data(data: bytes) -> str:
'''
Generate a mnemonic from given data (of 16, 20, 24, 28 and 32 bytes)
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
2016-09-27 14:48:21 +00:00
def check(mnemonic: str) -> bool:
'''
Check whether given mnemonic is valid
'''
2017-04-08 16:43:26 +00:00
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
2016-09-27 14:48:21 +00:00
def seed(mnemonic: str, passphrase: str) -> bytes:
'''
Generate seed from mnemonic and passphrase
'''