def test_zprv(self):
    (mnemonic, priv) = HDPrivateKey.generate(entropy=(1 << 128))
    for word in mnemonic.split():
        self.assertTrue((word in WORD_LIST))
    zprv = priv.zprv()
    self.assertTrue(zprv.startswith('zprv'))
    zpub = priv.pub.zpub()
    self.assertTrue(zpub.startswith('zpub'))
    derived = HDPrivateKey.parse(zprv)
    self.assertEqual(zprv, derived.zprv())
    (mnemonic, priv) = HDPrivateKey.generate(testnet=True)
    zprv = priv.zprv()
    self.assertTrue(zprv.startswith('vprv'))
    zpub = priv.pub.zpub()
    self.assertTrue(zpub.startswith('vpub'))
    xpub = priv.pub.xpub()
    self.assertTrue(xpub.startswith('tpub'))
    derived = HDPrivateKey.parse(zprv)
    self.assertEqual(zprv, derived.zprv())
    derived_pub = HDPublicKey.parse(zpub)
    self.assertEqual(zpub, derived_pub.zpub())
    with self.assertRaises(ValueError):
        bad_zprv = encode_base58_checksum((b'\x00' * 78))
        HDPrivateKey.parse(bad_zprv)
    with self.assertRaises(ValueError):
        bad_zpub = encode_base58_checksum((b'\x00' * 78))
        HDPublicKey.parse(bad_zpub)
    with self.assertRaises(ValueError):
        derived_pub.child((1 << 31))
def test_zprv(self):
    (mnemonic, priv) = HDPrivateKey.generate(entropy=(1 << 128))
    for word in mnemonic.split():
        self.assertTrue((word in WORD_LIST))
    zprv = priv.zprv()
    self.assertTrue(zprv.startswith('zprv'))
    zpub = priv.pub.zpub()
    self.assertTrue(zpub.startswith('zpub'))
    derived = HDPrivateKey.parse(zprv)
    self.assertEqual(zprv, derived.zprv())
    (mnemonic, priv) = HDPrivateKey.generate(testnet=True)
    zprv = priv.zprv()
    self.assertTrue(zprv.startswith('vprv'))
    zpub = priv.pub.zpub()
    self.assertTrue(zpub.startswith('vpub'))
    xpub = priv.pub.xpub()
    self.assertTrue(xpub.startswith('tpub'))
    derived = HDPrivateKey.parse(zprv)
    self.assertEqual(zprv, derived.zprv())
    derived_pub = HDPublicKey.parse(zpub)
    self.assertEqual(zpub, derived_pub.zpub())
    with self.assertRaises(ValueError):
        bad_zprv = encode_base58_checksum((b'\x00' * 78))
        HDPrivateKey.parse(bad_zprv)
    with self.assertRaises(ValueError):
        bad_zpub = encode_base58_checksum((b'\x00' * 78))
        HDPublicKey.parse(bad_zpub)
    with self.assertRaises(ValueError):
        derived_pub.child((1 << 31))