示例#1
0
 def test_derivation_from_raw_keys(self):
     public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
     private_keychain = PrivateKeychain.from_private_key(
         self.private_key_hex)
     public_keychain_2 = private_keychain.public_keychain()
     self.assertEqual(str(public_keychain), str(public_keychain_2))
     self.assertEqual(str(public_keychain), self.reference_public_keychain)
class KeychainDescendantTest(unittest.TestCase):
    def setUp(self):
        self.public_keychain_string = 'xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ'
        self.public_keychain = PublicKeychain(self.public_keychain_string)
        self.chain_path = 'bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39'
        self.reference_public_key = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'

    def tearDown(self):
        pass

    def test_descendant(self):
        descendant_public_keychain = self.public_keychain.descendant(self.chain_path)
        descendant_public_key = descendant_public_keychain.public_key()
        self.assertEqual(descendant_public_key, self.reference_public_key)
class KeychainDescendantTest(unittest.TestCase):
    def setUp(self):
        self.public_keychain_string = 'xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ'
        self.public_keychain = PublicKeychain(self.public_keychain_string)
        self.chain_path = 'bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39'
        self.reference_public_key = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'

    def tearDown(self):
        pass

    def test_descendant(self):
        descendant_public_keychain = self.public_keychain.descendant(self.chain_path)
        descendant_public_key = descendant_public_keychain.public_key()
        self.assertEqual(descendant_public_key, self.reference_public_key)
    def test_high_volume_derivation(self):
        number_of_keys = 10
        public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
        private_keychain = PrivateKeychain.from_private_key(self.private_key_hex)
        keypairs = []
        print ""
        for i in range(number_of_keys):
            print "making key %i of %i" % (i+1, number_of_keys)
            public_key = public_keychain.child(i).public_key()
            private_key = private_keychain.child(i).private_key()
            keypairs.append({ 'public': public_key, 'private': private_key })

        for i in range(len(keypairs)):
            keypair = keypairs[i]
            print "checking key %i of %i" % (i+1, number_of_keys)
            self.assertEqual(privkey_to_pubkey(keypair['private']), keypair['public'])
    def test_high_volume_derivation(self):
        number_of_keys = 10
        public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
        private_keychain = PrivateKeychain.from_private_key(self.private_key_hex)
        keypairs = []
        print ""
        for i in range(number_of_keys):
            print "making key %i of %i" % (i+1, number_of_keys)
            public_key = public_keychain.child(i).public_key()
            private_key = private_keychain.child(i).private_key()
            keypairs.append({ 'public': public_key, 'private': private_key })

        for i in range(len(keypairs)):
            keypair = keypairs[i]
            print "checking key %i of %i" % (i+1, number_of_keys)
            # self.assertEqual(privkey_to_pubkey(keypair['private']), keypair['public'])
            self.assertEqual(keylib.ECPrivateKey(keypair['private']).public_key().to_hex(), keylib.ECPublicKey(keypair['public']).to_hex())
 def test_derivation_from_raw_keys(self):
     public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
     private_keychain = PrivateKeychain.from_private_key(self.private_key_hex)
     public_keychain_2 = private_keychain.public_keychain()
     self.assertEqual(str(public_keychain), str(public_keychain_2))
     self.assertEqual(str(public_keychain), self.reference_public_keychain)
 def setUp(self):
     self.public_keychain_string = 'xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ'
     self.public_keychain = PublicKeychain(self.public_keychain_string)
     self.chain_path = 'bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39'
     self.reference_public_key = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'
 def test_child_generation(self):
     public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
     public_keychain_child = public_keychain.child(0)
     keychain_parts = bip32_deserialize(str(public_keychain_child))
     self.assertEqual(keychain_parts[4], self.reference_child_0_chaincode)
示例#9
0
 def setUp(self):
     self.public_keychain_string = 'xpub661MyMwAqRbcFQVrQr4Q4kPjaP4JjWaf39fBVKjPdK6oGBayE46GAmKzo5UDPQdLSM9DufZiP8eauy56XNuHicBySvZp7J5wsyQVpi2axzZ'
     self.public_keychain = PublicKeychain(self.public_keychain_string)
     self.chain_path = 'bd62885ec3f0e3838043115f4ce25eedd22cc86711803fb0c19601eeef185e39'
     self.reference_public_key = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'
示例#10
0
 def test_child_generation(self):
     public_keychain = PublicKeychain.from_public_key(self.public_key_hex)
     public_keychain_child = public_keychain.child(0)
     keychain_parts = bip32_deserialize(str(public_keychain_child))
     self.assertEqual(keychain_parts[4], self.reference_child_0_chaincode)