-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmnem_test.py
24 lines (18 loc) · 1.46 KB
/
mnem_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from libs.mnemonic import Mnemonic
code = 'skate woman tank knee helmet cook business rhythm erase today kite chronic hire leisure fuel'
mnemo = Mnemonic('english')
print(mnemo.check(code))
# test vectors
# https://github.com/tyler-smith/go-bip39/blob/master/bip39_test.go
entropy = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
print(mnemo.to_mnemonic(entropy))
print(mnemo.to_entropy("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"))
entropy = bytearray([0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f])
print(mnemo.to_mnemonic(entropy))
print(mnemo.to_entropy("legal winner thank year wave sausage worth useful legal winner thank yellow"))
entropy = bytearray([0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80])
print(mnemo.to_mnemonic(entropy))
print(mnemo.to_entropy("letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless"))
entropy = bytearray([0x18, 0xab, 0x19, 0xa9, 0xf5, 0x4a, 0x92, 0x74, 0xf0, 0x3e, 0x52, 0x09, 0xa2, 0xac, 0x8a, 0x91])
print(mnemo.to_mnemonic(entropy))
print(mnemo.to_entropy("board flee heavy tunnel powder denial science ski answer betray cargo cat"))