Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow provision of local-only DID in wallet #559

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,17 @@ def add_arguments(self, parser: ArgumentParser):
"--seed",
type=str,
metavar="<wallet-seed>",
help="Specifies the seed to use for the creation of a public DID\
for the agent to use with a Hyperledger Indy ledger. The DID\
must already exist on the ledger.",
help="Specifies the seed to use for the creation of a public\
DID for the agent to use with a Hyperledger Indy ledger, or a local\
('--wallet-local-did') DID. If public, the DID must already exist\
on the ledger.",
)
parser.add_argument(
"--wallet-local-did",
action="store_true",
help="If this parameter is set, provisions the wallet with a\
local DID from the '--seed' parameter, instead of a public DID\
to use with a Hyperledger Indy ledger.",
)
parser.add_argument(
"--wallet-key",
Expand Down Expand Up @@ -787,7 +795,7 @@ def add_arguments(self, parser: ArgumentParser):
"--wallet-storage-creds",
type=str,
metavar="<storage-creds>",
help='Specify the storage credentials to use for the wallet.\
help='Specifies the storage credentials to use for the wallet.\
This is required if you are for using \'postgres_storage\' wallet\
For example, \'{"account":"postgres","password":\
"mysecretpassword","admin_account":"postgres","admin_password":\
Expand All @@ -806,6 +814,8 @@ def get_settings(self, args: Namespace) -> dict:
settings = {}
if args.seed:
settings["wallet.seed"] = args.seed
if args.wallet_local_did:
settings["wallet.local_did"] = True
if args.wallet_key:
settings["wallet.key"] = args.wallet_key
if args.wallet_rekey:
Expand Down
20 changes: 14 additions & 6 deletions aries_cloudagent/config/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async def wallet_config(context: InjectionContext, provision: bool = False):
print("Wallet name:", wallet.name)

wallet_seed = context.settings.get("wallet.seed")
wallet_local_did = context.settings.get("wallet.local_did")
public_did_info = await wallet.get_public_did()
public_did = None

Expand All @@ -45,13 +46,20 @@ async def wallet_config(context: InjectionContext, provision: bool = False):
+ f" public did {public_did}"
)
elif wallet_seed:
public_did_info = await wallet.create_public_did(seed=wallet_seed)
public_did = public_did_info.did
if provision:
print(f"Created new public DID: {public_did}")
print(f"Verkey: {public_did_info.verkey}")
if wallet_local_did:
local_did_info = await wallet.create_local_did(seed=wallet_seed)
local_did = local_did_info.did
if provision:
print(f"Created new local DID: {local_did}")
print(f"Verkey: {local_did_info.verkey}")
else:
public_did_info = await wallet.create_public_did(seed=wallet_seed)
public_did = public_did_info.did
if provision:
print(f"Created new public DID: {public_did}")
print(f"Verkey: {public_did_info.verkey}")

if provision and not public_did:
if provision and not wallet_local_did and not public_did:
print("No public DID")

# Debug settings
Expand Down
4 changes: 1 addition & 3 deletions aries_cloudagent/ledger/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ async def _submit(

if not self.pool_handle:
raise ClosedPoolError(
"Cannot sign and submit request to closed pool {}".format(
self.pool_name
)
f"Cannot sign and submit request to closed pool '{self.pool_name}'"
)

if sign is None or sign:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,47 +326,48 @@ def non_revoc(cred_def_id: str) -> NonRevocationInterval:
proof_req["requested_attributes"][
"self_{}_uuid".format(canon(attr_spec.name))
] = {"name": canon(attr_spec.name)}
else:
cd_id = attr_spec.cred_def_id
revoc_support = bool(
ledger
and (await ledger.get_credential_definition(cd_id))["value"].get(
"revocation"
)
)
continue

cd_id = attr_spec.cred_def_id
revoc_support = False
if ledger:
async with ledger:
revoc_support = (await ledger.get_credential_definition(cd_id))[
"value"
].get("revocation")

interval = non_revoc(cd_id) if revoc_support else None

if attr_spec.referent:
if attr_spec.referent in attr_specs_names:
attr_specs_names[attr_spec.referent]["names"].append(
canon(attr_spec.name)
)
else:
attr_specs_names[attr_spec.referent] = {
"names": [canon(attr_spec.name)],
"restrictions": [{"cred_def_id": cd_id}],
**{
"non_revoked": interval.serialize()
for _ in [""]
if revoc_support
},
}
interval = non_revoc(cd_id) if revoc_support else None

if attr_spec.referent:
if attr_spec.referent in attr_specs_names:
attr_specs_names[attr_spec.referent]["names"].append(
canon(attr_spec.name)
)
else:
proof_req["requested_attributes"][
"{}_{}_uuid".format(
len(proof_req["requested_attributes"]),
canon(attr_spec.name),
)
] = {
"name": canon(attr_spec.name),
attr_specs_names[attr_spec.referent] = {
"names": [canon(attr_spec.name)],
"restrictions": [{"cred_def_id": cd_id}],
**{
"non_revoked": interval.serialize()
for _ in [""]
if revoc_support
},
}
else:
proof_req["requested_attributes"][
"{}_{}_uuid".format(
len(proof_req["requested_attributes"]), canon(attr_spec.name),
)
] = {
"name": canon(attr_spec.name),
"restrictions": [{"cred_def_id": cd_id}],
**{
"non_revoked": interval.serialize()
for _ in [""]
if revoc_support
},
}

for (reft, attr_spec) in attr_specs_names.items():
proof_req["requested_attributes"][
"{}_{}_uuid".format(
Expand All @@ -376,12 +377,12 @@ def non_revoc(cred_def_id: str) -> NonRevocationInterval:

for pred_spec in self.predicates:
cd_id = pred_spec.cred_def_id
revoc_support = bool(
ledger
and (await ledger.get_credential_definition(cd_id))["value"].get(
"revocation"
)
)
revoc_support = False
if ledger:
async with ledger:
revoc_support = (await ledger.get_credential_definition(cd_id))[
"value"
].get("revocation")

interval = non_revoc(cd_id) if revoc_support else None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
if not context.connection_ready:
raise HandlerException("Cannot query routes: no active connection")

# TODO implement pagination
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the storage query uses pagination: comment was obsolete


mgr = RoutingManager(context)
result = await mgr.get_routes(
context.connection_record.connection_id, context.message.filter
Expand Down