コード例 #1
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Get local verkey of 'my_did' from wallet
        # and store it into 'returned_verkey'.
        self.steps.add_step("Get local verkey of 'my_did' from wallet and "
                            "store it into 'returned_verkey'")
        returned_verkey = await utils.perform(self.steps,
                                              signus.key_for_local_did,
                                              self.wallet_handle, my_did)

        # 5. Check 'returned_verkey'.
        self.steps.add_step("Check 'returned_verkey'")
        err_msd = "Returned verkey mismatches with stored verkey"
        utils.check(self.steps,
                    error_message=err_msd,
                    condition=lambda: returned_verkey == my_verkey)
コード例 #2
0
    async def test(self):
        # 1. Create pool ledger config.
        self.steps.add_step("Create pool ledger config")
        await utils.perform(self.steps, common.create_pool_ledger_config,
                            self.pool_name, constant.pool_genesis_txn_file)
        # 2. Open pool ledger.
        self.steps.add_step("Open pool ledger")
        self.pool_handle = await \
            utils.perform(self.steps, pool.open_pool_ledger,
                          self.pool_name, None)

        # 3. Delete opened pool ledger
        # and verify that a opened pool ledger cannot be deleted.
        self.steps.add_step("Delete opened pool ledger and verify that"
                            " opened pool ledger cannot be deleted")
        error_code = ErrorCode.CommonInvalidState
        await utils.perform_with_expected_code(self.steps,
                                               pool.delete_pool_ledger_config,
                                               self.pool_name,
                                               expected_code=error_code)
        # Check pool config folder still exists.
        error_message = "Pool config folder does not exists"
        utils.check(self.steps,
                    error_message,
                    condition=lambda: utils.check_pool_exist(self.pool_name))
コード例 #3
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Get verkey of 'my_did' from wallet.
        self.steps.add_step("Get local verkey of 'my_did' from wallet")
        returned_verkey = await utils.perform(self.steps, did.key_for_did, -1,
                                              self.wallet_handle, my_did)

        # 5. Check returned verkey.
        self.steps.add_step("Check returned verkey")
        error_msg = "Returned verkey mismatch with 'my_verkey'"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: returned_verkey == my_verkey)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with valid seed.
        self.steps.add_step("Create did and verkey with valid seed")
        did_json = json.dumps({"seed": constant.seed_my1})
        my_verkey = await \
            utils.perform(self.steps, crypto.create_key,
                          self.wallet_handle, did_json)

        # 4. Use created did to sign.
        self.steps.add_step("Use created did to sign")
        signature = await utils.perform(self.steps, crypto.crypto_sign,
                                        self.wallet_handle, my_verkey,
                                        self.message)

        # 5. Check created signature.
        self.steps.add_step("Check created signature")
        utils.check(self.steps, error_message="Created signature is invalid",
                    condition=lambda: signature == self.expected_signature)
コード例 #5
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Prepare new verkey with empty json.
        self.steps.add_step("Prepare new verkey with empty json")
        new_verkey = await utils.perform(self.steps, signus.replace_keys_start,
                                         self.wallet_handle, my_did, "{}")

        # 5. Replace old verkey.
        self.steps.add_step("Replace old verkey")
        await utils.perform(self.steps, signus.replace_keys_apply,
                            self.wallet_handle, my_did)

        # 6. Get verkey of 'my_did'.
        self.steps.add_step("Get verkey of 'my_did'")
        updated_verkey = await utils.perform(self.steps, signus.key_for_did,
                                             -1, self.wallet_handle, my_did)

        # 7. Check updated verkey.
        self.steps.add_step("Check updated verkey")
        error_msg = "Updated verkey is different from verkey " \
                    "that returned by 'signus.replace_keys_start'"
        utils.check(self.steps, error_message=error_msg,
                    condition=lambda: new_verkey == updated_verkey)
コード例 #6
0
    async def test(self):
        # 1. Create and open pool.
        self.pool_handle = await common.create_and_open_pool_ledger_for_steps(
            self.steps, self.pool_name, self.pool_genesis_txn_file)

        # 2. Create and open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Get stored claims in wallet.
        self.steps.add_step("Get stored claims in wallet")
        lst_claims = await utils.perform(self.steps,
                                         anoncreds.prover_get_credentials,
                                         self.wallet_handle, '{}')

        lst_claims = json.loads(lst_claims)

        # 4. Check returned list claims.
        self.steps.add_step("Check returned list claims")
        err_msg = "Returned list claims is not empty"
        utils.check(self.steps,
                    error_message=err_msg,
                    condition=lambda: not lst_claims)
    async def test(self):
        await pool.set_protocol_version(2)

        # 1. Prepare pool and wallet. Get pool_handle, wallet_handle
        self.steps.add_step("Prepare pool and wallet")
        self.pool_handle, self.wallet_handle = await \
            perform(self.steps, common.prepare_pool_and_wallet, self.pool_name,
                    self.wallet_name, self.wallet_credentials, self.pool_genesis_txn_file)

        # 2. Create and store did
        self.steps.add_step("Create DIDs")
        (submitter_did,
         _) = await perform(self.steps, did.create_and_store_my_did,
                            self.wallet_handle,
                            json.dumps({"seed": seed_default_trustee}))

        # 3. build attrib request
        self.steps.add_step("Create DIDs")
        raw = '{"endpoint":{"ha":"127.0.0.1:5555"}}'
        attrib_req = json.loads(await perform(self.steps,
                                              ledger.build_attrib_request,
                                              submitter_did, submitter_did,
                                              None, raw, None))

        # 4. Verifying build_attrib_request json.
        self.steps.add_step("Verifying get_nym_request json")
        err_msg = "Invalid request type"
        utils.check(self.steps,
                    error_message=err_msg,
                    condition=lambda: attrib_req['operation']['type'] == '100')
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps, self.wallet_name, self.pool_name)

        # 3. Create verkey.
        self.steps.add_step("Create verkey")
        my_verkey = await utils.perform(self.steps, crypto.create_key,
                                        self.wallet_handle, "{}")

        # 4. Create sealed crypto box and verify that
        # there is no exception raised.
        self.steps.add_step("Create sealed crypto box and verify that "
                            "there is no exception raised")
        msg = "Test crypto".encode()
        encrypted_msg = await utils.perform(self.steps,
                                            crypto.crypto_box_seal,
                                            my_verkey,
                                            msg,
                                            ignore_exception=False)

        # 5. Open sealed crypto box.
        self.steps.add_step("Open sealed crypto box")
        decrypted_msg = await utils.perform(self.steps,
                                            crypto.crypto_box_seal_open,
                                            self.wallet_handle, my_verkey,
                                            encrypted_msg)

        # 6. Check decrypted message.
        self.steps.add_step("Check encrypted message")
        error_msg = "Decrypted message mismatches"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: decrypted_msg == msg)
コード例 #9
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Store 'their_did' and 'their_verkey' into wallet.
        self.steps.add_step("Store 'their_did' and 'their_verkey' into wallet")
        their_did, their_verkey = constant.did_my2, constant.verkey_my2
        await utils.perform(
            self.steps, did.store_their_did, self.wallet_handle,
            json.dumps({
                "did": their_did,
                "verkey": their_verkey
            }))

        # 4. Get local verkey of 'their_did' from wallet
        # and store it into 'returned_verkey'.
        self.steps.add_step("Get local verkey of 'my_did' from wallet and "
                            "store it into 'returned_verkey'")
        returned_verkey = await utils.perform(self.steps,
                                              did.key_for_local_did,
                                              self.wallet_handle, their_did)

        # 5. Check 'returned_verkey'.
        self.steps.add_step("Check 'returned_verkey'")
        err_msd = "Returned verkey mismatches with stored verkey"
        utils.check(self.steps,
                    error_message=err_msd,
                    condition=lambda: returned_verkey == their_verkey)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (their_did, _) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Store created did into wallet.
        self.steps.add_step("Store created did into wallet")
        result = await utils.perform(self.steps, did.store_their_did,
                                     self.wallet_handle,
                                     json.dumps({"did": their_did}))

        # 5. Verify that did is stored successfully.
        self.steps.add_step("Verify that did is stored successfully")
        utils.check(self.steps,
                    error_message="Cannot store created did",
                    condition=lambda: result is None)
コード例 #11
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Prepare new verkey with empty json.
        self.steps.add_step("Prepare new verkey with empty json")
        new_verkey = await utils.perform(self.steps, did.replace_keys_start,
                                         self.wallet_handle, my_did, "{}")

        # 5. Check format of new verkey.
        self.steps.add_step("Check format of new verkey")
        error_msg = "Format of new verkey is incorrect"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: len(base58.b58decode(new_verkey)) ==
                    constant.decoded_verkey_length)

        # 6. Verify that new verkey is different from old verkey.
        self.steps.add_step("Verify that new verkey is "
                            "different form old verkey")
        error_msg = "New verkey is the same with old verkey"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: new_verkey != my_verkey)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Store 'their_did' and 'their_verkey' into wallet.
        self.steps.add_step("Store 'their_did' and 'their_verkey' into wallet")
        their_did_json = {
            "did": constant.did_my2,
            "verkey": constant.verkey_my2
        }
        await utils.perform(self.steps, did.store_their_did,
                            self.wallet_handle, json.dumps(their_did_json))

        # 4 Get verkey for 'their_did" from wallet.
        self.steps.add_step("Get local verkey of 'their_did' from wallet")
        returned_verkey = await utils.perform(self.steps, did.key_for_did, -1,
                                              self.wallet_handle,
                                              constant.did_my2)

        # 5. Check returned verkey.
        self.steps.add_step("Check returned verkey")
        error_msg = "Returned verkey mismatch with 'their_verkey'"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: returned_verkey == constant.verkey_my2)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps, self.wallet_name, self.pool_name)

        # 3. Create verkey with seed my1.
        self.steps.add_step("Create verkey with seed my1")
        my_verkey = await utils.perform(self.steps, crypto.create_key,
                                        self.wallet_handle, "{}")

        # 4. Use 'crypto.crypto_sign' to sign.
        self.steps.add_step("Use 'crypto.crypto_sign' to sign")
        message = "Test crypto".encode()
        signature = await utils.perform(self.steps, crypto.crypto_sign,
                                        self.wallet_handle, my_verkey, message)

        # 5. Verify signed signature.
        self.steps.add_step("Verify signed signature")
        result = await utils.perform(self.steps, crypto.crypto_verify,
                                     my_verkey, message, signature)

        error_msg = "'crypto.crypto_verify' return False instead of True"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: result is True)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, _) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Set metadata for 'my_did' and verify that
        # there is no exception raised
        self.steps.add_step("Set metadata for 'my_did' and verify that "
                            "there is no exception raised")
        metadata = "Test did"
        await utils.perform(self.steps, did.set_did_metadata,
                            self.wallet_handle, my_did, metadata,
                            ignore_exception=False)

        # 5. Get metadata of 'my_did'.
        self.steps.add_step("Get metadata of 'my_did'")
        returned_metadata = await utils.perform(self.steps,
                                                did.get_did_metadata,
                                                self.wallet_handle, my_did)

        # 6. Check returned metadata.
        self.steps.add_step("Check returned metadata")
        error_msg = "Returned metadata mismatches with original metadata"
        utils.check(self.steps, error_message=error_msg,
                    condition=lambda: returned_metadata == metadata)
コード例 #15
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps,
            self.wallet_name,
            self.pool_name,
            credentials=self.wallet_credentials)

        # 3. Create verkey with seed my1.
        self.steps.add_step("Create verkey with seed my1")
        my_verkey = await utils.perform(
            self.steps, crypto.create_key, self.wallet_handle,
            json.dumps({"seed": constant.seed_my1}))

        # 4. Use 'crypto.crypto_sign' to sign.
        self.steps.add_step("Use 'crypto.crypto_sign' to sign")
        signature = await utils.perform(self.steps, crypto.crypto_sign,
                                        self.wallet_handle, my_verkey,
                                        self.message)

        # 5. Check created signature.
        self.steps.add_step("Check created signature")
        error_msg = "Created signature is incorrect"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: self.expected_signature == signature)
コード例 #16
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps,
            self.wallet_name,
            self.pool_name,
            credentials=self.wallet_credentials)

        # 3. Create verkey.
        self.steps.add_step("Create verkey")
        crypto_verkey = await utils.perform(self.steps, crypto.create_key,
                                            self.wallet_handle, "{}")

        # 4. Crypto sign the message.
        self.steps.add_step("Crypto sign the message")
        message = "Test crypto".encode()
        signature = await utils.perform(self.steps, crypto.crypto_sign,
                                        self.wallet_handle, crypto_verkey,
                                        message)

        # 5. Verify signed signature with crypto type.
        self.steps.add_step("Verify signed signature with crypto type")
        crypto_type = ":ed25519"
        result = await utils.perform(self.steps, crypto.crypto_verify,
                                     crypto_verkey + crypto_type, message,
                                     signature)

        error_msg = "Verifying fail when using crypto type"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: result is True)
コード例 #17
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Prepare new verkey with valid seed.
        self.steps.add_step("Prepare new verkey with valid seed")
        new_verkey = await utils.perform(
            self.steps, signus.replace_keys_start, self.wallet_handle, my_did,
            json.dumps({"seed": constant.seed_my1}))

        # 5. Check new verkey.
        self.steps.add_step("Verify that new verkey is correspond with seed")
        error_msg = "New verkey is no correspond with seed"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: new_verkey == constant.verkey_my1)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with cid.
        self.steps.add_step("Create did and verkey with cid")
        (my_did, my_verkey) = await \
            utils.perform(self.steps,
                          signus.create_and_store_my_did, self.wallet_handle,
                          json.dumps({"seed": constant.seed_my1, "cid": True}))

        # 4. Check created did.
        self.steps.add_step("Check created did")
        utils.check(self.steps,
                    error_message="Created did is invalid",
                    condition=lambda: my_did == constant.verkey_my1)

        # 5. Check created verkey.
        self.steps.add_step("Check created verkey")
        utils.check(self.steps,
                    error_message="Created verkey is invalid",
                    condition=lambda: my_verkey == constant.verkey_my1)
コード例 #19
0
    async def test(self):
        await pool.set_protocol_version(2)

        # 1. Prepare pool and wallet. Get pool_handle, wallet_handle
        self.steps.add_step("Prepare pool and wallet")
        self.pool_handle, self.wallet_handle = await perform(
            self.steps, common.prepare_pool_and_wallet, self.pool_name,
            self.wallet_name, self.wallet_credentials,
            self.pool_genesis_txn_file)

        # 2. Create and store did
        self.steps.add_step("Create DID")
        (submitter_did,
         _) = await perform(self.steps, did.create_and_store_my_did,
                            self.wallet_handle,
                            json.dumps({"seed": seed_default_trustee}))

        # 3. build get_txn request
        self.steps.add_step("build get_txn request")
        data = 1
        get_txn_req = json.loads(await perform(self.steps,
                                               ledger.build_get_txn_request,
                                               submitter_did, None, data))

        # 4. verify json response
        self.steps.add_step("Verify json get_txn request is correct.")
        err_msg = "Invalid request type"
        utils.check(self.steps,
                    error_message=err_msg,
                    condition=lambda: get_txn_req['operation']['type'] == '3')
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 3. Create did and verkey with valid seed.
        self.steps.add_step("Create did and verkey with valid seed")
        did_json = json.dumps({"seed": constant.seed_default_trustee})
        (my_did, my_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, did_json)

        # 4. Check created did.
        self.steps.add_step("Check created did")
        utils.check(self.steps,
                    error_message="Created did is invalid",
                    condition=lambda: len(base58.b58decode(my_did)) == 16)

        # 5. Check created verkey.
        self.steps.add_step("Check created verkey")
        utils.check(self.steps,
                    error_message="Created verkey is invalid",
                    condition=lambda: len(base58.b58decode(my_verkey)) == 32)
コード例 #21
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Create did and verkey with valid crypto type.
        self.steps.add_step("Create did and verkey with valid crypto type")
        did_json = json.dumps({"seed": constant.seed_my1,
                               "crypto_type": "ed25519"})
        (my_did, my_verkey) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, did_json)

        # 4. Check created did.
        self.steps.add_step("Check created did")
        utils.check(self.steps, error_message="Created did is invalid",
                    condition=lambda: my_did == constant.did_my1)

        # 5. Check created verkey.
        self.steps.add_step("Check created verkey")
        utils.check(self.steps, error_message="Created verkey is invalid",
                    condition=lambda: my_verkey == constant.verkey_my1)
コード例 #22
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps,
            self.wallet_name,
            self.pool_name,
            credentials=self.wallet_credentials)

        # 3. Create verkey.
        self.steps.add_step("Create verkey")
        my_verkey = await utils.perform(self.steps, crypto.create_key,
                                        self.wallet_handle, "{}")

        # 4. Create sealed crypto box.
        self.steps.add_step("Create sealed crypto box")
        msg = "Test crypto".encode()
        encrypted_msg = await utils.perform(self.steps, crypto.anon_crypt,
                                            my_verkey, msg)

        # 5. Open sealed crypto box.
        self.steps.add_step("Open sealed crypto box")
        decrypted_msg = await utils.perform(self.steps, crypto.anon_decrypt,
                                            self.wallet_handle, my_verkey,
                                            encrypted_msg)

        # 6. Check decrypted message.
        self.steps.add_step("Check encrypted message")
        error_msg = "Decrypted message mismatches"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: decrypted_msg == msg)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps, self.wallet_name, self.pool_name)

        # 3. Create verkey with seed my1.
        self.steps.add_step("Create verkey with seed my1")
        my_verkey = await utils.perform(
                                     self.steps, crypto.create_key,
                                     self.wallet_handle,
                                     json.dumps({"seed": constant.seed_my1}))

        # 4. Create the other verkey with empty json.
        self.steps.add_step("Create the other verkey")
        other_verkey = await utils.perform(self.steps, crypto.create_key,
                                           self.wallet_handle, "{}")

        # 5. Crypto sign the message.
        self.steps.add_step("Crypto sign the message")
        message = "Test crypto".encode()
        signature = await utils.perform(self.steps, crypto.crypto_sign,
                                        self.wallet_handle, my_verkey,
                                        message)

        # 5. Verify signed signature with other signer.
        self.steps.add_step("Verify signed signature with other signer")
        result = await utils.perform(self.steps, crypto.crypto_verify,
                                     other_verkey, message,
                                     signature)

        error_msg = "Return True although we use other verkey"
        utils.check(self.steps, error_message=error_msg,
                    condition=lambda: result is False)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps,
            self.wallet_name,
            self.pool_name,
            credentials=self.wallet_credentials)

        # 3. Create verkey.
        self.steps.add_step("Create verkey")
        my_verkey = await utils.perform(self.steps, crypto.create_key,
                                        self.wallet_handle, "{}")

        # 4. Set metadata for created verkey.
        self.steps.add_step("Set metadata for created verkey")
        metadata = "Test crypto"
        await utils.perform(self.steps, crypto.set_key_metadata,
                            self.wallet_handle, my_verkey, metadata)

        # 5. Get metadata of created verkey.
        self.steps.add_step("Get metadata of created verkey")
        returned_metadata = await utils.perform(self.steps,
                                                crypto.get_key_metadata,
                                                self.wallet_handle, my_verkey)

        # 6. Check returned metadata.
        self.steps.add_step("Check returned metadata")
        error_msg = "Returned metadata mismatches with " \
                    "metadata that is used to set before"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: returned_metadata == metadata)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps,
            self.wallet_name,
            self.pool_name,
            credentials=self.wallet_credentials)

        # 3. Create and "their_did".
        self.steps.add_step("Create 'their_did'")
        (their_did, _) = await utils.perform(self.steps,
                                             did.create_and_store_my_did,
                                             self.wallet_handle, '{}')

        # 4. Store 'their_did'.
        self.steps.add_step("Store 'their_did")
        await utils.perform(self.steps, did.store_their_did,
                            self.wallet_handle, json.dumps({"did": their_did}))

        # 5. Verify that 'is_pairwise_exists' return 'False'.
        self.steps.add_step("Verify that 'is_pairwise_exists' return 'False'")
        pairwise_exists = await utils.perform(self.steps,
                                              pairwise.is_pairwise_exists,
                                              self.wallet_handle, their_did)
        utils.check(self.steps,
                    error_message="'True' is returned instead of 'False'",
                    condition=lambda: pairwise_exists is False)
コード例 #26
0
    def __check_a_field_is_not_empty(self, claim_json_def_primary, key: str):
        self.steps.add_step(
            "Check claim_def['data']['primary']['{}']".format(key))

        error_message = "Claim_def['data']['primary']['{}'] " \
                        "is empty".format(key)

        utils.check(self.steps, error_message,
                    condition=lambda: len(claim_json_def_primary[key]) > 0)
コード例 #27
0
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 3. Create did and verkey with empty json.
        self.steps.add_step("Create did and verkey with empty json")
        (my_did, _) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 4. Set metadata for 'my_did' and verify that
        # there is no exception raised
        self.steps.add_step("Set metadata for 'my_did' and verify that "
                            "there is no exception raised")
        metadata = "Before replacing"
        await utils.perform(self.steps, did.set_did_metadata,
                            self.wallet_handle, my_did, metadata,
                            ignore_exception=False)

        # 5. Get metadata of 'my_did'.
        self.steps.add_step("Get metadata of 'my_did'")
        old_metadata = await utils.perform(self.steps, did.get_did_metadata,
                                           self.wallet_handle, my_did)

        # 6. Check returned metadata.
        self.steps.add_step("Check returned metadata")
        error_msg = "Returned metadata mismatches"
        utils.check(self.steps, error_message=error_msg,
                    condition=lambda: old_metadata == metadata)

        # 7. Set metadata for "my_did" to replace old metadata and
        # verify that there is no exception raised
        self.steps.add_step("Set metadata for 'my_did' to replace old metadata"
                            " and verify that there is no exception raised")
        new_metadata = "After replacing"
        await utils.perform(self.steps, did.set_did_metadata,
                            self.wallet_handle, my_did, new_metadata,
                            ignore_exception=False)

        # 8. Get updated metadata of 'my_did'.
        self.steps.add_step("Get updated metadata of 'my_did'")
        updated_metadata = await utils.perform(self.steps,
                                               did.get_did_metadata,
                                               self.wallet_handle, my_did)

        # 9. Check updated metadata.
        self.steps.add_step("Check returned metadata")
        error_msg = "Updated metadata mismatches"
        utils.check(self.steps, error_message=error_msg,
                    condition=lambda: updated_metadata == new_metadata)
    async def test(self):
        # 1. Create pool ledger config.
        # 2. Open pool ledger.
        self.pool_handle = await \
            common.create_and_open_pool_ledger_for_steps(self.steps,
                                                         self.pool_name,
                                                         constant.
                                                         pool_genesis_txn_file)

        # 3. Create wallet.
        # 4. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name)

        # 5. Create 'my_did' and 'my_verkey'.
        self.steps.add_step("Create 'my_did' and 'my_verkey'")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 6. Create 'their_did' and 'their_verkey'.
        self.steps.add_step("Create 'their_did' and 'their_verkey'")
        (their_did, their_verkey) = await \
            utils.perform(self.steps, signus.create_and_store_my_did,
                          self.wallet_handle, "{}")

        # 7. Store 'their_did' and 'their_verkey' into wallet.
        self.steps.add_step("Store 'their_did' and 'their_verkey' into wallet")
        their_did_json = json.dumps({"did": their_did, "verkey": their_verkey})
        await utils.perform(self.steps, signus.store_their_did,
                            self.wallet_handle, their_did_json)

        # 8. Encrypte message by 'signus.encrypt'
        self.steps.add_step("Encrypte message by 'signus.encrypt'")
        message = "Test signus".encode("utf-8")
        (encrypted_message, nonce) = await \
            utils.perform(self.steps, signus.encrypt, self.wallet_handle,
                          self.pool_handle, my_did, their_did, message)

        # 9. Decrypt message by 'signus.decrypt'.
        self.steps.add_step("Decrypt message by 'signus.decrypt'")
        decrypted_msg = await utils.perform(self.steps, signus.decrypt,
                                            self.wallet_handle,
                                            self.pool_handle, my_did,
                                            their_did, encrypted_message,
                                            nonce)

        # 10. Check returned decrypted message.
        self.steps.add_step("Check returned decrypted message")
        error_message = "Decrypted message mismatches with message in step 8"
        utils.check(self.steps,
                    error_message,
                    condition=lambda: decrypted_msg == message)
コード例 #29
0
    async def test(self):
        # 1. Create pool ledger config.
        # 2. Open pool ledger
        self.pool_handle = await common.create_and_open_pool_ledger_for_steps(
            self.steps, self.pool_name, constant.pool_genesis_txn_file)

        # 3. Create wallet.
        # 4. Open wallet.
        self.wallet_handle = await \
            common.create_and_open_wallet_for_steps(self.steps,
                                                    self.wallet_name,
                                                    self.pool_name,
                                                    credentials=self.wallet_credentials)

        # 5. Create did and verkey with default trustee seed.
        self.steps.add_step("Create did and verkey with default trustee seed")
        (my_did, my_verkey) = await \
            utils.perform(self.steps, did.create_and_store_my_did,
                          self.wallet_handle,
                          json.dumps({"seed": constant.seed_default_trustee}))

        # 6. Build attribute request.
        self.steps.add_step("Build attribute request")
        ep_json = {"endpoint": {"ha": constant.endpoint, "verkey": my_verkey}}
        attr_req = await utils.perform(self.steps, ledger.build_attrib_request,
                                       my_did, my_did, None,
                                       json.dumps(ep_json), None)

        # 7. Sign and submit request to ledger.
        self.steps.add_step("Sign and submit request to ledger")
        await utils.perform(self.steps, ledger.sign_and_submit_request,
                            self.pool_handle, self.wallet_handle, my_did,
                            attr_req)

        # 8. Get end point of 'my_did'.
        self.steps.add_step("Get end point of 'my_did'")
        (returned_endpoint, returned_verkey) = await utils.perform(
            self.steps, did.get_endpoint_for_did, self.wallet_handle,
            self.pool_handle, my_did)

        # 9. Check returned verkey.
        self.steps.add_step("Check returned verkey")
        error_msg = "Returned verkey mismatches with verkey that is set"
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: returned_verkey == my_verkey)

        # 10. Check returned endpoint.
        self.steps.add_step("Check returned endpoint")
        error_msg = "Returned endpoint mismatches with endpoint that is set"
        expected_ep = ep_json['endpoint']['ha']
        utils.check(self.steps,
                    error_message=error_msg,
                    condition=lambda: returned_endpoint == expected_ep)
    async def test(self):
        # 1. Create wallet.
        # 2. Open wallet.
        self.wallet_handle = await common.create_and_open_wallet_for_steps(
            self.steps, self.wallet_name, self.pool_name)

        # 3. Create 'issuer_did'.
        self.steps.add_step("Create 'issuer_did'")
        (issuer_did, _) = await utils.perform(self.steps,
                                              did.create_and_store_my_did,
                                              self.wallet_handle, "{}")

        # 4. Create 'prover_did'.
        self.steps.add_step("Create 'prover_did'")
        (prover_did, _) = await utils.perform(self.steps,
                                              did.create_and_store_my_did,
                                              self.wallet_handle, "{}")

        # 4. Create and store claim definition.
        self.steps.add_step("Create and store claim definition")
        await utils.perform(self.steps,
                            anoncreds.issuer_create_and_store_claim_def,
                            self.wallet_handle, issuer_did,
                            json.dumps(constant.gvt_schema),
                            constant.signature_type, False)

        # 5. Store claim offer and verify that there is no exception raise.
        self.steps.add_step("Store claim offer and verify that "
                            "there is no exception raise")
        offer_json = await anoncreds.issuer_create_claim_offer(
            self.wallet_handle, json.dumps(constant.gvt_schema), issuer_did,
            prover_did)

        await utils.perform(self.steps,
                            anoncreds.prover_store_claim_offer,
                            self.wallet_handle,
                            offer_json,
                            ignore_exception=False)

        # 6. Get claim offers and store returned value into 'list_claim_offer'.
        self.steps.add_step("Get claim offers and store "
                            "returned value in to 'list_claim_offer'")
        list_claim_offer = await utils.perform(
            self.steps, anoncreds.prover_get_claim_offers, self.wallet_handle,
            '{}')
        list_claim_offer = json.loads(list_claim_offer)

        # 7. Verify that 'offer_json' exists in 'list_claim_offer'.
        self.steps.add_step("Verify that 'offer_json' exists "
                            "in 'list_claim_offer'")
        utils.check(self.steps,
                    error_message="Cannot store a claim offer",
                    condition=lambda: constant.gvt_schema_key ==
                    list_claim_offer[0]['schema_key'])