hex cases added
This commit is contained in:
parent
a338c764be
commit
cedb7765d9
@ -50,9 +50,15 @@ class BIPEntropy(object):
|
||||
raise ValueError('ERROR: Invalid xprv')
|
||||
return self.__hmac_sha512(self.__derive_k(path, xprv))
|
||||
|
||||
def bip32_xprv_to_hex(self, index, width, xprv_string):
|
||||
# export entropy as hex
|
||||
path = f"83696968p/128169p/{width}p/{index}p"
|
||||
ent = self.bip32_xprv_to_entropy(path, xprv_string)
|
||||
return ent[0:width].hex()
|
||||
|
||||
def bip32_xprv_to_xprv(self, index, xprv_string):
|
||||
# app_no = 32 => XPRV to XPRV
|
||||
path = "83696968p/32p/{index}p".format(index=index)
|
||||
path = f"83696968p/32p/{index}p"
|
||||
node = BTC.parse.bip32_prv(xprv_string).subkey_for_path(path)
|
||||
|
||||
# if API to pycoin hadn't been shitcoined:
|
||||
|
||||
@ -84,7 +84,15 @@ def test_xprv_application():
|
||||
result = e.bip32_xprv_to_xprv(0, XPRV)
|
||||
assert result == 'xprv9s21ZrQH143K3KJoGoKpsDsWdDNDBKs1wqFymBpCGJtrYXrfKzykGDBadZq5SrNde22F83X9qhFZr4uyV9TptTgLqCBc6XFN9tssphdxVeg'
|
||||
|
||||
@pytest.mark.parametrize('index, width, expect', [
|
||||
(0, 32, '4f4ea2ef43af14e51f2453221d50762fc3767e2287dc524ca58f10e5225a6ead'),
|
||||
(0, 64, '4fc6759ef9c0e12aed757ad874706a3955ef125c8f8eabb3909aeda028f5e285bf496a23265bac09f537f4cc5e1efa689f5625ded2cd996c042b2657263c6816'),
|
||||
(1234, 64, 'e1a35aeae27cb3c93b0d437e94b64a891cdff9ac250537ec675d0e6a2680f1d2edf9927f4c5233b19b15fdea4063a8b62f85ff8666176d226741ed192075a8db'),
|
||||
])
|
||||
def test_hex_application(index, width, expect):
|
||||
e = bipentropy.BIPEntropy()
|
||||
assert e.bip32_xprv_to_hex(index, width, XPRV) == expect
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user