Exemplo n.º 1
0
 def test_verify_message_vectors(self) -> None:
     for vector in load_test_vectors('signmessage.json'):
         message = BitcoinMessage(vector['address'])
         self.assertTrue(VerifyMessage(
             P2PKHCoinAddress(vector['address']),
             message,
             vector['signature']
         ))
Exemplo n.º 2
0
    def test_verify_message_simple(self):
        address = "1F26pNMrywyZJdr22jErtKcjF8R3Ttt55G"
        message = address
        signature = "H85WKpqtNZDrajOnYDgUY+abh0KCAcOsAIOQwx2PftAbLEPRA7mzXA/CjXRxzz0MC225pR/hx02Vf2Ag2x33kU4="

        message = BitcoinMessage(message)

        self.assertTrue(VerifyMessage(address, message, signature))
Exemplo n.º 3
0
    def test_verify_message_simple(self) -> None:
        address = P2PKHCoinAddress("1F26pNMrywyZJdr22jErtKcjF8R3Ttt55G")
        message = str(address)
        signature = ("H85WKpqtNZDrajOnYDgUY+abh0KCAcOsAIOQwx2PftAbLEPRA7mzXA"
                     "/CjXRxzz0MC225pR/hx02Vf2Ag2x33kU4=")

        message_to_verify = BitcoinMessage(message)

        self.assertTrue(VerifyMessage(address, message_to_verify, signature))
Exemplo n.º 4
0
def print_verbose(signature, key, msg):
    secret = CBitcoinSecret(key)
    address = P2PKHBitcoinAddress.from_pubkey(secret.pub)
    message = BitcoinMessage(msg)
    print('Address: %s' % address)
    print('Message: %s' % msg)
    print('Signature: %s' % signature)
    print('Verified: %s' % VerifyMessage(address, message, signature))
    print('\nTo verify using bitcoin core:')
    print('\n`bitcoin-cli verifymessage %s \'%s\' \'%s\'`\n' % (address, signature.decode('ascii'), msg))
Exemplo n.º 5
0
    def test_sign_message_simple(self):
        key = CBitcoinSecret(
            "L4vB5fomsK8L95wQ7GFzvErYGht49JsCPJyJMHpB4xGM6xgi2jvG")
        address = "1F26pNMrywyZJdr22jErtKcjF8R3Ttt55G"
        message = address

        message = BitcoinMessage(message)
        signature = SignMessage(key, message)

        self.assertTrue(signature)
        self.assertTrue(VerifyMessage(address, message, signature))
Exemplo n.º 6
0
def print_verbose(signature: bytes, key: str, msg: str) -> None:
    secret = CCoinKey(key)
    address = P2PKHCoinAddress.from_pubkey(secret.pub)
    message = BitcoinMessage(msg)
    print('Address: %s' % str(address))
    print('Message: %s' % msg)
    print('Signature: %s' % signature.decode('ascii'))
    print('Verified: %s' % VerifyMessage(address, message, signature))
    print('\nTo verify using bitcoin core:')
    print('\n`bitcoin-cli verifymessage %s \'%s\' \'%s\'`\n'
          % (str(address), signature.decode('ascii'), msg))
Exemplo n.º 7
0
    def test_sign_message_simple(self) -> None:

        key = CBitcoinKey(
            "L4vB5fomsK8L95wQ7GFzvErYGht49JsCPJyJMHpB4xGM6xgi2jvG")
        address = P2PKHCoinAddress("1F26pNMrywyZJdr22jErtKcjF8R3Ttt55G")
        message = str(address)

        message_to_sign = BitcoinMessage(message)
        signature = SignMessage(key, message_to_sign)

        self.assertTrue(signature)
        self.assertTrue(VerifyMessage(address, message_to_sign, signature))
Exemplo n.º 8
0
    def test_sign_message_vectors(self):
        for vector in load_test_vectors('signmessage.json'):
            key = CBitcoinSecret(vector['wif'])
            message = BitcoinMessage(vector['address'])

            signature = SignMessage(key, message)

            self.assertTrue(signature,
                            "Failed to sign for [%s]" % vector['address'])
            self.assertTrue(
                VerifyMessage(vector['address'], message, vector['signature']),
                "Failed to verify signature for [%s]" % vector['address'])