How to use the iroha.helper.crypto 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 / helper / test_ed25519.py View on Github external
def test_crypt_js(self):
        print("test_crypt_js")
        js_pubkey = b"IuoWmTU/dG7Q7O2mSEIQKnXbMTEJcko45gFqcu0tEWs="
        js_signature = b"+F6d6gKexVhzk0LUK6hkKuu76nc0Nt9RakrT4hu2Hkve8qzsz8jNvCuCuKvQN37OUNKqUh9lTMfBYPDFu2KGDQ=="
        js_message = b"dfc27cdbd6ec86613185e00afb27b11af2b8e2e8fc1573f80722a6e537cb06ab"
        self.assertTrue(ed25519.verify(
            js_message,
            js_signature,
            js_pubkey
        ))
        self.assertTrue(crypto.verify(
            js_pubkey,
            js_signature,
            js_message
        ))
github hyperledger / iroha-python / tests / primitive / test_signatories.py View on Github external
def test_signatories(self):
        signatories = Signatories()

        keypairs = []
        keypairs.append(crypto.create_key_pair())
        keypairs.append(crypto.create_key_pair())
        keypairs.append(crypto.create_key_pair())

        for key in keypairs:
            signatories.append(key)

        self.assertTrue(signatories.size() == 3)


        tx = Transaction(
            payload = Transaction.Payload(
                creator_account_id = "test@test"
            ),
            signatures = []
        )
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
)
        payload = Transaction.Payload(
            commands = [
                Command(create_account = create_ac)
            ],
            creator_account_id = self.creator,
            tx_counter = self.tx_counter,
            created_time = crypto.now()
        )
        payload2 = Transaction.Payload(
            commands = [
                Command(create_account = create_ac)
            ],
            creator_account_id = self.creator,
            tx_counter = self.tx_counter,
            created_time = crypto.now()+1
        )
        tx = Transaction(
            payload = payload,
            signatures = [
                Signature(
                    pubkey = self.keypair.public_key,
                    signature = crypto.sign(self.keypair,crypto.sign_hash(payload2))
                )
            ]
        )
        self.assertFalse(stateless_validator.verify(tx))
github hyperledger / iroha-python / iroha / helper / stateless_validator.py View on Github external
def verify_pubkey(pubkey):
    try:
        key = crypto.b64decode(pubkey)
    except:
        logger.info("Stateless Public Key not Base64 Encode")
        return False
    if len(key) == 32:
        return True
    logger.info("Stateless Public Key Length Failed: " + key.decode())
    return False
github hyperledger / iroha-python / iroha / helper / stateless_validator.py View on Github external
def verify(transaction):
    logger.info("Transaction Stateless Verify")
    payload = transaction.payload
    for cmd in transaction.payload.commands:
        if not command(cmd):
            logger.info("Stateless Command Failed")
            return False

    for signature in transaction.signatures:
        if not crypto.verify(signature.pubkey,
                             signature.signature,
                             crypto.sign_hash(payload)):
            logger.info("Stateless Signature Verify Failed")
            return False

    if verify_created_time(payload.created_time):
        return True
    return False
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)
        )