def test_ckd_pubkeys(): pub = 'xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw' new_pub = btc.bip32_ckd(pub, 4) #how to check it's right? print(new_pub) #try to do on hardened, should fail, that's the idea: with pytest.raises(Exception) as e_info: new_pub = btc.bip32_ckd(pub, 2**31 + 1)
def test_bip32_vector(vector): master = btc.bip32_master_key(vector['seed']) assert master == vector['keys'][0][0], 'failed: master xpriv' masterpub = btc.bip32_privtopub(master) assert masterpub == vector['keys'][0][1], 'failed: master xpub' currentkey = master for i in range(1, len(vector['depths'])): currentkey = btc.bip32_ckd(currentkey, vector['depths'][i]) print(currentkey) print(vector['keys'][i][0]) assert currentkey == vector['keys'][i][ 0], 'failed: child priv key, should be: ' + vector['keys'][i][0] pub = btc.bip32_privtopub(currentkey) print(pub) print(vector['keys'][i][1]) assert pub == vector['keys'][i][ 1], 'failed: child pub key, should be: ' + vector['keys'][i][1]