Пример #1
0
 def test_generate_signature(self):
     raw_hex_data = '523c5fcf74823831756f0bcb3634234f10b3beb1c05595058534577752ad2d9f'
     account = Account(raw_hex_data, SignatureScheme.SHA256withECDSA)
     msg = 'test'.encode('utf-8')
     signature = account.generate_signature(msg)
     result = account.verify_signature(msg, signature)
     self.assertEqual(True, result)
Пример #2
0
 def test_signature(self):
     for strength in self.strengths:
         master_key = HDPrivateKey.master_key_from_mnemonic(
             self.mnemonic.generate(strength))
         acct = Account(master_key.hex())
         signature = acct.generate_signature(self.msg)
         self.assertTrue(acct.verify_signature(self.msg, signature))
         root_sk = HDPrivateKey.from_path(master_key)[-1]
         root_pk = root_sk.public_key
         bip32_root_pk = root_pk.b58encode()
         for index in range(10):
             child_sk = HDPrivateKey.from_path(root_sk, f'0/{index}')[-1]
             child_pk = HDPublicKey.from_path(
                 HDPublicKey.b58decode(bip32_root_pk), f'0/{index}')[-1]
             child_acct = Account(child_sk.hex())
             signature = child_acct.generate_signature(self.msg)
             handler = SignatureHandler(SignatureScheme.SHA256withECDSA)
             handler.verify_signature(child_pk.hex(), self.msg, signature)