How to use the iroha.helper.crypto.sign 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 / query / test_response.py View on Github external
def helper_make_response(self,payload):
        return Response(
            QueryResponse(
                payload=payload,
                signature=Signature(
                    pubkey=self.keypair.public_key,
                    signature=crypto.sign(self.keypair, crypto.sign_hash(payload))
                )
github hyperledger / iroha-python / tests / test_creator.py View on Github external
Transaction(
                payload = Transaction.Payload(
                    creator_account_id = "test@test",
                    created_time = tx.debug_proto_transaction().payload.created_time
                ),
                signatures = [
                    Signature(
                        pubkey = keypairs[0].public_key,
                        signature = crypto.sign(
                            keypairs[0],
                            crypto.sign_hash(tx.debug_proto_transaction().payload)
                        )
                    ),
                    Signature(
                        pubkey = keypairs[1].public_key,
                        signature = crypto.sign(
                            keypairs[1],
                            crypto.sign_hash(tx.debug_proto_transaction().payload)
                        )
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
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 / 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()
        )

        tx = Transaction(
            payload = payload,
            signatures = [
                Signature(
                    pubkey = self.keypair.public_key,
                    signature = crypto.sign(self.keypair,crypto.sign_hash(payload))
                )
            ]
        )
        self.assertTrue(stateless_validator.verify(tx))
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()-3600*24*1000*10
        )

        tx = Transaction(
            payload = payload,
            signatures = [
                Signature(
                    pubkey = self.keypair.public_key,
                    signature = crypto.sign(self.keypair,crypto.sign_hash(payload))
                )
            ]
        )
        self.assertFalse(stateless_validator.verify(tx))

        payload = Transaction.Payload(
            commands = [
                Command(create_account = create_ac)
            ],
            creator_account_id = self.creator,
            tx_counter = self.tx_counter,
            created_time = crypto.now()+3600*24*1000*10
        )

        tx = Transaction(
            payload = payload,
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 / primitive / test_signatories.py View on Github external
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 / iroha / primitive / signatories.py View on Github external
def sign(self,tx):
        logger.debug("Signatories.sign")
        payload = tx.payload
        for signatory in self.signatories:
            if not [ signature for signature in tx.signatures if signature.pubkey == signatory.public_key ]:
                tx.signatures.extend([
                    Signature(
                        pubkey = signatory.public_key,
                        signature = crypto.sign(signatory, crypto.sign_hash(payload))
                    )