本文整理汇总了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
示例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]
示例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
示例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})
示例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)
示例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
示例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)
示例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
示例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