How to use the iroha.helper.crypto.verify function in iroha

To help you get started, we’ve selected a few iroha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / iroha-python / tests / primitive / test_signatories.py View on Github external
tx = Transaction(
            payload = Transaction.Payload(
                creator_account_id = "test@test"
            ),
            signatures = []
        )

        signatories.sign(tx)

        self.assertEqual(len(tx.signatures),3)
        for i in range(0,3):
            sig = tx.signatures[i]
            self.assertTrue(
                crypto.verify(
                    sig.pubkey,
                    sig.signature,
                    crypto.sign_hash(tx.payload)
                )
            )

            self.assertEqual(
                sig.signature,
                crypto.sign(
                    keypairs[i],
                    crypto.sign_hash(tx.payload)
                )
            )

        signatories.clean()
        self.assertEqual(signatories.size(),0)
github hyperledger / iroha-python / tests / helper / test_ed25519.py View on Github external
signature,
            message
        ))

        go_pubkey = b"ZipcethJh6X7GCeYSPsD/FQLo5gbqcDU1S+yG8JKVJ0="
        # go_privkey = b"lP7Z+eyg91OEyS1T0QvZHk95eaoW5inOIhNLz/jRlUFmKlx62EmHpfsYJ5hI+wP8VAujmBupwNTVL7IbwkpUnQ=="
        go_signature = b"d1B8kLk7i+aUMWJsvkrOvuHwTdvB0HtQPhQiB44QoXgGHaTPOL4+kagobPhWvF61hGezzLn6qukv2UYV5R1/CQ=="
        go_message = b"charinko_locked_sate"


        self.assertTrue(ed25519.verify(
            go_message,
            go_signature,
            go_pubkey))

        self.assertTrue(crypto.verify(
            go_pubkey,
            go_signature,
            go_message
        ))
github hyperledger / iroha-python / tests / helper / test_cipher.py View on Github external
def test_sha3_sign(self):
        key_pair = crypto.create_key_pair()
        message = crypto.sha3_256(bytes(b'a031b'))
        dummy_message = crypto.sha3_256(bytes(b'a032b'))
        sign = crypto.sign(key_pair,message)
        self.assertTrue(crypto.verify(key_pair.public_key,sign,message))
        self.assertFalse(crypto.verify(key_pair.public_key,sign,dummy_message))
github hyperledger / iroha-python / tests / helper / test_crypt.py View on Github external
def test_sign_hash(self):
        hash = crypto.sign_hash(self.tx.payload)

        logger.info(hash)
        logger.info(crypto.b64encode(hash))

        sign = crypto.sign(self.keypair,hash)

        logger.info(sign)

        is_verify = crypto.verify(self.keypair.public_key,sign,hash)

        logger.info(is_verify)
        self.assertTrue(is_verify)
github hyperledger / iroha-python / tests / helper / test_cipher.py View on Github external
def test_sha3_sign(self):
        key_pair = crypto.create_key_pair()
        message = crypto.sha3_256(bytes(b'a031b'))
        dummy_message = crypto.sha3_256(bytes(b'a032b'))
        sign = crypto.sign(key_pair,message)
        self.assertTrue(crypto.verify(key_pair.public_key,sign,message))
        self.assertFalse(crypto.verify(key_pair.public_key,sign,dummy_message))
github hyperledger / iroha-python / tests / helper / test_ed25519.py View on Github external
def test_crypt_ed25519(self):
        key_pair = crypto.create_key_pair()
        message = b"c0a5cca43b8aa79eb50e3464bc839dd6fd414fae0ddf928ca23dcebf8a8b8dd0"

        signature = crypto.sign(key_pair,message)
        sig_2 = ed25519.sign(message,key_pair.public_key,key_pair.private_key)
        self.assertEqual(signature,sig_2)

        self.assertTrue(crypto.verify(
            key_pair.public_key,
            signature,
            message
        ))

        go_pubkey = b"ZipcethJh6X7GCeYSPsD/FQLo5gbqcDU1S+yG8JKVJ0="
        # go_privkey = b"lP7Z+eyg91OEyS1T0QvZHk95eaoW5inOIhNLz/jRlUFmKlx62EmHpfsYJ5hI+wP8VAujmBupwNTVL7IbwkpUnQ=="
        go_signature = b"d1B8kLk7i+aUMWJsvkrOvuHwTdvB0HtQPhQiB44QoXgGHaTPOL4+kagobPhWvF61hGezzLn6qukv2UYV5R1/CQ=="
        go_message = b"charinko_locked_sate"


        self.assertTrue(ed25519.verify(
            go_message,
            go_signature,
            go_pubkey))
github hyperledger / iroha-python / iroha / query / response.py View on Github external
def verify(self):
        logger.debug("Response.verify")
        return crypto.verify(
            self.response.signature.pubkey,
            self.response.signature.signature,
            crypto.sign_hash(self.response.payload)
        )