How to use the iroha.helper.crypto.now 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_stateless_validator.py View on Github external
def test_stateless_validator_true(self):
        logger.debug("test_create_account")
        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        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
def test_stateless_get_transactions(self):
        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        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
        )

        get_txs = GetTransactions(
            tx_hashes = [
                crypto.sign_hash(payload)
            ]
        )
        self.assertTrue(stateless_validator.get_transactions(get_txs))
        get_txs = GetTransactions(
            tx_hashes = [
                b"aaaaa0000000"
            ]
        )
        self.assertFalse(stateless_validator.get_transactions(get_txs))
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
def test_stateless_validator_created_at_ng(self):
        logger.debug("test_stateless_validator_created_at_ng")
        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        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)
github hyperledger / iroha-python / tests / helper / test_crypt.py View on Github external
def setUp(self):
        self.keypair = crypto.create_key_pair()

        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        self.payload = Transaction.Payload(
            commands = [
                Command(create_account = create_ac)
            ],
            creator_account_id = "rihito@light.wing",
            tx_counter = 0,
            created_time = crypto.now()
        )

        self.tx = Transaction(
            payload = self.payload,
            signatures = [
                Signature(
                    pubkey = self.keypair.public_key,
                    signature = crypto.sign(self.keypair,crypto.sign_hash(self.payload))
                )
github hyperledger / iroha-python / tests / helper / test_stateless_validator.py View on Github external
def test_stateless_validator_signature_ng(self):
        logger.debug("test_stateless_validator_signature_ng")

        create_ac = Command.CreateAccount(
            account_name = "rihito",
            domain_id = "light.wing",
            main_pubkey = self.keypair.public_key
        )
        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))
                )
github hyperledger / iroha-python / iroha / query / query.py View on Github external
def __init__(self):
        logger.debug("Create Query Construct")
        self.query = QuerySchema(
            payload = QuerySchema.Payload(
                created_time = crypto.now()
            )
            # TODO query has signature
        )
        self.signatories = Signatories()
github hyperledger / iroha-python / iroha / helper / stateless_validator.py View on Github external
def verify_created_time(time):
    logger.info("Stateless Check Time")
    logger.info("created time: " + str(time))
    now = crypto.now()
    logger.info("now time    : " + str(now))
    one_second = 1000
    # なんか時間ずれるの5秒ほど許容する。
    if now - MAX_DELAY <= time and time <= now + one_second * 5:
        return True
    logger.info("Stateless Out Range Time Failed")
    return False
github hyperledger / iroha-python / iroha / transaction / transaction.py View on Github external
def __init__(self):
        logger.debug("Create Transaction Construct")
        self.tx = TransactionSchema(
            payload = TransactionSchema.Payload(
                created_time = crypto.now()
            ),
            signatures = []
        )
        self.signatories = Signatories()