當前位置: 首頁>>代碼示例>>Python>>正文


Python wallet.create_wallet方法代碼示例

本文整理匯總了Python中indy.wallet.create_wallet方法的典型用法代碼示例。如果您正苦於以下問題:Python wallet.create_wallet方法的具體用法?Python wallet.create_wallet怎麽用?Python wallet.create_wallet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在indy.wallet的用法示例。


在下文中一共展示了wallet.create_wallet方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_wallet_and_pool

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def get_wallet_and_pool():
    pool_name = 'pool' + randomString(3)
    wallet_name = 'wallet' + randomString(10)
    their_wallet_name = 'their_wallet' + randomString(10)
    seed_trustee1 = "000000000000000000000000Trustee1"

    await wallet.create_wallet(pool_name, wallet_name, None, None, None)
    my_wallet_handle = await wallet.open_wallet(wallet_name, None, None)

    await wallet.create_wallet(pool_name, their_wallet_name, None, None, None)
    their_wallet_handle = await wallet.open_wallet(their_wallet_name, None, None)

    await did.create_and_store_my_did(my_wallet_handle, "{}")

    (their_did, their_verkey) = await did.create_and_store_my_did(their_wallet_handle,
                                                                  json.dumps({"seed": seed_trustee1}))

    await did.store_their_did(my_wallet_handle, json.dumps({'did': their_did, 'verkey': their_verkey}))

    return their_wallet_handle, their_did 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:22,代碼來源:generate_txns.py

示例2: init

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def init():
    me = input('Who are you? ').strip()
    wallet_config = '{"id": "%s-wallet"}' % me
    wallet_credentials = '{"key": "%s-wallet-key"}' % me

    try:
        await wallet.create_wallet(wallet_config, wallet_credentials)
    except:
        pass
    wallet_handle = await wallet.open_wallet(wallet_config, wallet_credentials)
    print('wallet = %s' % wallet_handle)

    (my_did, my_vk) = await did.create_and_store_my_did(wallet_handle, "{}")
    print('my_did and verkey = %s %s' % (my_did, my_vk))

    their = input("Other party's DID and verkey? ").strip().split(' ')
    return wallet_handle, my_did, my_vk, their[0], their[1] 
開發者ID:kdenhartog,項目名稱:indy-dev,代碼行數:19,代碼來源:msgme.py

示例3: _gen_wallet_handler

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def _gen_wallet_handler(wallet_data):
    wallet_config, wallet_credentials = wallet_data
    await create_wallet(wallet_config, wallet_credentials)
    wallet_handle = await open_wallet(wallet_config, wallet_credentials)
    return wallet_handle 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:7,代碼來源:conftest.py

示例4: setup

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def setup(self, config):
        if not 'ledger_name' in config:
            raise Exception(
                "The Indy provider requires a 'ledger_name' value in config.toml")
        self.pool_name = config['ledger_name']
        if not 'ledger_url' in config:
            raise Exception(
                "The Indy provider requires a 'ledger_url' value in config.toml")
        self.ledger_url = config['ledger_url']
        if not 'ledger_apts_seed' in config:
            raise Exception(
                "The Indy provider requires a 'ledger_apts_seed' value in config.toml")
        seed = config['ledger_apts_seed']
        id = config.get('name', 'test')
        key = config.get('pass', 'testpw')
        self.cfg = json.dumps({'id': id})
        self.creds = json.dumps({'key': key})
        self.seed = json.dumps({'seed': seed})
        try:
            await wallet.delete_wallet(self.cfg, self.creds)
        except Exception as e:
            pass
        await wallet.create_wallet(self.cfg, self.creds)
        self.wallet = await wallet.open_wallet(self.cfg, self.creds)
        self.master_secret_id = await anoncreds.prover_create_master_secret(self.wallet, None)
        (self.did, self.verkey) = await did.create_and_store_my_did(self.wallet, self.seed)
        # Download the genesis file
        resp = await aiohttp.ClientSession().get(self.ledger_url)
        genesis = await resp.read()
        genesisFileName = "genesis.apts"
        with open(genesisFileName, 'wb') as output:
            output.write(genesis)
        await self._open_pool({'genesis_txn': genesisFileName}) 
開發者ID:hyperledger,項目名稱:aries-protocol-test-suite,代碼行數:35,代碼來源:indy_provider.py

示例5: wallet_handle

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def wallet_handle(config, logger):
    wallet_config = (
        json.dumps({
            'id': config.wallet_name,
            'storage_config': {
                'path': config.wallet_path
            }
        }),
        json.dumps({'key': 'test-agent'})
    )
    # Initialization steps
    # -- Create wallet
    logger.debug('Creating wallet: {}'.format(config.wallet_name))
    try:
        await wallet.create_wallet(*wallet_config)
    except:
        pass

    # -- Open a wallet
    logger.debug('Opening wallet: {}'.format(config.wallet_name))
    wallet_handle = await wallet.open_wallet(*wallet_config)

    yield wallet_handle

    # Cleanup
    if config.clear_wallets:
        logger.debug("Closing wallet")
        await wallet.close_wallet(wallet_handle)
        logger.debug("deleting wallet")
        await wallet.delete_wallet(*wallet_config)

        logger.debug("removing wallet directory")
        os.rmdir(config.wallet_path) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:35,代碼來源:conftest.py

示例6: wallet_helper

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def wallet_helper(wallet_id=None, wallet_key='', wallet_key_derivation_method='ARGON2I_INT'):
    if not wallet_id:
        wallet_id = random_string(5)
    wallet_config = json.dumps({"id": wallet_id})
    wallet_credentials = json.dumps({"key": wallet_key, "key_derivation_method": wallet_key_derivation_method})
    await wallet.create_wallet(wallet_config, wallet_credentials)
    wallet_handle = await wallet.open_wallet(wallet_config, wallet_credentials)

    return wallet_handle, wallet_config, wallet_credentials 
開發者ID:hyperledger,項目名稱:indy-node,代碼行數:11,代碼來源:utils.py

示例7: wallet_create_wallet

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def wallet_create_wallet(self, config, credential):
        await wallet.create_wallet(config, credential) 
開發者ID:hyperledger,項目名稱:indy-node,代碼行數:4,代碼來源:perf_client.py

示例8: onboarding

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def onboarding(pool_handle, _from, from_wallet, from_did, to, to_wallet: Optional[str], to_wallet_config: str,
                     to_wallet_credentials: str):
    logger.info("\"{}\" -> Create and store in Wallet \"{} {}\" DID".format(_from, _from, to))
    (from_to_did, from_to_key) = await did.create_and_store_my_did(from_wallet, "{}")

    logger.info("\"{}\" -> Send Nym to Ledger for \"{} {}\" DID".format(_from, _from, to))
    await send_nym(pool_handle, from_wallet, from_did, from_to_did, from_to_key, None)

    logger.info("\"{}\" -> Send connection request to {} with \"{} {}\" DID and nonce".format(_from, to, _from, to))
    connection_request = {
        'did': from_to_did,
        'nonce': 123456789
    }

    if not to_wallet:
        logger.info("\"{}\" -> Create wallet".format(to))
        try:
            await wallet.create_wallet(to_wallet_config, to_wallet_credentials)
        except IndyError as ex:
            if ex.error_code == ErrorCode.PoolLedgerConfigAlreadyExistsError:
                pass
        to_wallet = await wallet.open_wallet(to_wallet_config, to_wallet_credentials)

    logger.info("\"{}\" -> Create and store in Wallet \"{} {}\" DID".format(to, to, _from))
    (to_from_did, to_from_key) = await did.create_and_store_my_did(to_wallet, "{}")

    logger.info("\"{}\" -> Get key for did from \"{}\" connection request".format(to, _from))
    from_to_verkey = await did.key_for_did(pool_handle, to_wallet, connection_request['did'])

    logger.info("\"{}\" -> Anoncrypt connection response for \"{}\" with \"{} {}\" DID, verkey and nonce"
                .format(to, _from, to, _from))
    connection_response = json.dumps({
        'did': to_from_did,
        'verkey': to_from_key,
        'nonce': connection_request['nonce']
    })
    anoncrypted_connection_response = await crypto.anon_crypt(from_to_verkey, connection_response.encode('utf-8'))

    logger.info("\"{}\" -> Send anoncrypted connection response to \"{}\"".format(to, _from))

    logger.info("\"{}\" -> Anondecrypt connection response from \"{}\"".format(_from, to))
    decrypted_connection_response = \
        json.loads((await crypto.anon_decrypt(from_wallet, from_to_key,
                                              anoncrypted_connection_response)).decode("utf-8"))

    logger.info("\"{}\" -> Authenticates \"{}\" by comparision of Nonce".format(_from, to))
    assert connection_request['nonce'] == decrypted_connection_response['nonce']

    logger.info("\"{}\" -> Send Nym to Ledger for \"{} {}\" DID".format(_from, to, _from))
    await send_nym(pool_handle, from_wallet, from_did, to_from_did, to_from_key, None)

    return to_wallet, from_to_key, to_from_did, to_from_key, decrypted_connection_response 
開發者ID:kdenhartog,項目名稱:indy-dev,代碼行數:54,代碼來源:getting_started.py

示例9: connect_wallet

# 需要導入模塊: from indy import wallet [as 別名]
# 或者: from indy.wallet import create_wallet [as 別名]
def connect_wallet(self, agent_name, passphrase, ephemeral=False):
        """ Create if not already exists and open wallet.
        """

        self.owner = agent_name
        wallet_suffix = "wallet"
        if ephemeral:
            wallet_suffix = "ephemeral_wallet"
        wallet_name = '{}-{}'.format(self.owner, wallet_suffix)

        wallet_config = json.dumps({"id": wallet_name})
        wallet_credentials = json.dumps({"key": passphrase})

        # Handle ephemeral wallets
        if ephemeral:
            try:
                await wallet.delete_wallet(wallet_config, wallet_credentials)
                print("Removing ephemeral wallet.")
            except error.IndyError as e:
                if e.error_code is error.ErrorCode.WalletNotFoundError:
                    pass  # This is ok, and expected.
                else:
                    print("Unexpected Indy Error: {}".format(e))
            except Exception as e:
                print(e)
        # pylint: disable=bare-except

        try:
            await wallet.create_wallet(wallet_config, wallet_credentials)
        except error.IndyError as e:
            if e.error_code is error.ErrorCode.WalletAlreadyExistsError:
                pass  # This is ok, and expected.
            else:
                print("Unexpected Indy Error: {}".format(e))
        except Exception as e:
            print(e)

        try:
            if self.wallet_handle:
                await wallet.close_wallet(self.wallet_handle)

            self.wallet_handle = await wallet.open_wallet(
                wallet_config,
                wallet_credentials
            )

            (_, self.endpoint_vk) = await did.create_and_store_my_did(self.wallet_handle, "{}")

            self.initialized = True

        except Exception as e:
            print(e)
            print("Could not open wallet!")

            raise WalletConnectionException 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:57,代碼來源:agent.py


注:本文中的indy.wallet.create_wallet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。