Split of vcx_provision_agent
I propose to split deprecate vcx_provision_agent
and split it into 3 new functions vcx_create_wallet
, vcx_configure_issuer_wallet
, vcx_provision_new_agent
due to following problems. To enable this, we will also need vcx_open_wallet
which does not rely on settings.rs
.
Problem 1
Currently this is function which has was given 3 responsibilities:
- create new wallet
- configure wallet (create prover master secret in wallet, create issuer's DID from seed (using
enterprise_seed
attribute))
- using that wallet, onboard a new agency agent
Though this covers common scenarios, it's restrictive at the same time - what if I only want to create new wallet and onboard agency client later? (perhaps running on mobile app for the first while not being connected to the internet - we might not be able to onboard agency client, but we might at least want to create the app wallet). Or perhaps we have wallet(s) and want to onboard to agency using it.
Problem 2
Additionally there's one more design issue with vcx_provision_agent
. Currently, it requires you to pass in "config" looking as such:
{
"path": "/path/to/genesis/127.0.0.1",
"name": "my_agent_name",
"logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTjkD2iJdaKMlH2sKgR_flz6sa3mgkB9PRQwve4GLoXqPI7r73RiQ",
"agency_url": "http://127.0.0.1:8080",
"agency_did": "VsKV7grR1BUE29mG2Fm2kX",
"agency_verkey": "Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR",
"payment_method": "null",
"enterprise_seed": "000000000000000000000000Trustee1",
"wallet_name": "my_wallet_name",
"wallet_key": "123456",
"wallet_key_derivation": "ARGON2I_MOD",
"wallet_type": "postgres_storage",
"storage_config": "{\"url\":\"localhost:5432\"}",
"storage_credentials": "{\"account\":\"postgres\",\"password\":\"password_123\",\"admin_account\":\"postgres\",\"admin_password\":\"password_foo\"}"
}
Performs some sort of mappings to these fields, so that it produces similarly looking config, with additional agency_client related info (remote_to_sdk_did
, .. etc.):
{
"path": "/path/to/genesis/127.0.0.1",
"institution_did": "V4SGRU86Z58d6TV7PBUe6f",
"institution_name": "my_agent_name",
"institution_verkey": "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL",
"agency_did": "VsKV7grR1BUE29mG2Fm2kX",
"agency_endpoint": "http://127.0.0.1:8080",
"agency_verkey": "Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR",
"remote_to_sdk_did": "GkdUhwyWqNw3vGs6FQFFHb",
"remote_to_sdk_verkey": "9axcTwXeJ1haJBw9LqexT8dRpiFCJwA6ZUevM5nfiDKg",
"sdk_to_remote_did": "C5DiHD1n3MqNcv5h7PBK9J",
"sdk_to_remote_verkey": "732pD7kDiBjSyS57aNXi52Xpg2DLCTb43aLpddo2X8CG",
"wallet_name": "my_wallet_name",
"wallet_key": "123456",
"wallet_key_derivation": "ARGON2I_MOD",
"wallet_type": "postgres_storage",
"storage_config": "{\"url\":\"localhost:5432\"}",
"storage_credentials": "{\"account\":\"postgres\",\"password\":\"password_123\",\"admin_account\":\"postgres\",\"admin_password\":\"password_foo\"}"
}
And whenever you initialize vcx, you are expected to pass in this as parameter. The fact the attributes are being renamed (name
becomes institution_name
, ...) is confusing and the overall flow rigid and reflects previously coupled architecture of the library.
Solution
So I suggest to deprecate vcx_provision_agent
and instead create:
vcx_create_wallet
Creates new wallet using provided parameters, pretty much propagates to IndySDK and creates wallet. Additionally creates prover master secret, as that'd be needed on both mobile and institutional agents. It keeps wallet closed. API:
vcx_create_wallet(wallet_config) -> void
Whereas the argument wallet_config
is JSON string such as:
{
"wallet_name": "my_wallet_name",
"wallet_key": "123456",
"wallet_key_derivation": "ARGON2I_MOD",
"wallet_type": "postgres_storage",
"storage_config": "{\"url\":\"localhost:5432\"}",
"storage_credentials": "{\"account\":\"postgres\",\"password\":\"password_123\",\"admin_account\":\"postgres\",\"admin_password\":\"password_foo\"}"
}
vcx_configure_issuer_wallet
This is only needed if you are issuer, so mobile agents would not need to call this. API
vcx_create_wallet(enterprise_seed, institution_name) -> institution_config
Whereas institution_config
is JSON such as
{
"institution_did": "V4SGRU86Z58d6TV7PBUe6f",
"institution_name": "my_agent_name",
"institution_verkey": "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL",
}
vcx_provision_new_agent
Provision new agent using provided agency information and a wallet_handle. API:
vcx_provision_new_agent(agency_did, agency_vk, agency_endpoint) -> agency_config
whereas the returned agency_config would be JSON string containing information needed to create agency client (apart from proper wallet handle)
{
"agency_did": "VsKV7grR1BUE29mG2Fm2kX",
"agency_endpoint": "http://127.0.0.1:8080",
"agency_verkey": "Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR",
"remote_to_sdk_did": "GkdUhwyWqNw3vGs6FQFFHb",
"remote_to_sdk_verkey": "9axcTwXeJ1haJBw9LqexT8dRpiFCJwA6ZUevM5nfiDKg",
"sdk_to_remote_did": "C5DiHD1n3MqNcv5h7PBK9J",
"sdk_to_remote_verkey": "732pD7kDiBjSyS57aNXi52Xpg2DLCTb43aLpddo2X8CG"
}
Okay so there we have it, vcx_provision_agent
split into 3 functions. Assuming no modifications to other functions, the caller would now have some extra work - he needs to combine known information (wallet info) with infromation received (agency_client config) to construct the config JSON to be pass into vcx_init_core
. This was previously bit easier as this was "conveniently" received from vcx_provision_agent
.
Example of "NodeJS pseudocode" based institutional agent consuming new APIs
const pool_config = {
"path": "/path/to/genesis/127.0.0.1",
}
const wallet_config = {
"wallet_name" = "my_wallet_name",
"wallet_key" = "123456",
"wallet_key_derivation" = "ARGON2I_MOD",
"wallet_type" = "postgres_storage",
"storage_config" = "{\"url\":\"localhost:5432\"}",
"storage_credentials" = "{\"account\":\"postgres\",\"password\":\"password_123\",\"admin_account\":\"postgres\",\"admin_password\":\"password_foo\"}"
}
cosnt enterprise_seed = "000000000000000000000000Trustee1"
const institution_name = "Faber"
const agency_did="VsKV7grR1BUE29mG2Fm2kX"
const agency_endpoint="http://127.0.0.1:8080"
const agency_verkey="Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR"
await vcx_create_wallet(wallet_config)
const wallet_handle = await vcx_open_wallet_directly(wallet_config)
const institution_config = await vcx_configure_issuer_wallet(wallet_handle, "enterprise_seed", institution_name)
const agency_config = await vcx_provision_new_agent(agency_did, agency_vk, agency_endpoint)
await vcx_close_wallet_directly(wallet_handle)
const initConfig = { ...agency_config, ...wallet_config, ...institution_config, ...pool_config }
await vcx_init_core(initConfig)
await vcx_open_wallet()
await vcx_open_pool()
Additional APIs needed
Additionally as can be seen per example above, we also need APIs:
vcx_open_wallet_directly(wallet_config) -> wallet_handle
vcx_close_wallet_directly(wallet_handle)