Skip to content

Commit fd1e350

Browse files
authored
Merge branch 'main' into main
2 parents 8b2eca5 + 1673245 commit fd1e350

10 files changed

Lines changed: 60 additions & 40 deletions

File tree

aries_cloudagent/indy/credx/holder.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
import uuid
88

9-
from typing import Sequence, Tuple, Union
9+
from typing import Dict, Sequence, Tuple, Union
1010

1111
from aries_askar import AskarError, AskarErrorCode
1212
from indy_credx import (
@@ -471,27 +471,26 @@ async def create_presentation(
471471
472472
"""
473473

474-
creds = {}
475-
476-
def get_rev_state(cred_id, timestamp):
477-
reg_id = creds[cred_id].rev_reg_id
478-
if not reg_id:
479-
raise IndyHolderError(
480-
f"Cannot prove credential '{cred_id}' for "
481-
"specific timestamp, credential has no rev_reg_id"
482-
)
483-
if not rev_states or reg_id not in rev_states:
484-
raise IndyHolderError(
485-
f"No revocation states provided for credential '{cred_id}'"
486-
f"with rev_reg_id '{reg_id}'"
487-
)
488-
state = rev_states[reg_id].get(timestamp)
489-
if not state:
490-
raise IndyHolderError(
491-
f"No revocation states provided for credential '{cred_id}'"
492-
f"with rev_reg_id '{reg_id}' at timestamp {timestamp}"
493-
)
494-
return state
474+
creds: Dict[str, Credential] = {}
475+
476+
def get_rev_state(cred_id: str, detail: dict):
477+
cred = creds[cred_id]
478+
rev_reg_id = cred.rev_reg_id
479+
timestamp = detail.get("timestamp") if rev_reg_id else None
480+
rev_state = None
481+
if timestamp:
482+
if not rev_states or rev_reg_id not in rev_states:
483+
raise IndyHolderError(
484+
f"No revocation states provided for credential '{cred_id}' "
485+
f"with rev_reg_id '{rev_reg_id}'"
486+
)
487+
rev_state = rev_states[rev_reg_id].get(timestamp)
488+
if not rev_state:
489+
raise IndyHolderError(
490+
f"No revocation states provided for credential '{cred_id}' "
491+
f"with rev_reg_id '{rev_reg_id}' at timestamp {timestamp}"
492+
)
493+
return timestamp, rev_state
495494

496495
self_attest = requested_credentials.get("self_attested_attributes") or {}
497496
present_creds = PresentCredentials()
@@ -501,25 +500,26 @@ def get_rev_state(cred_id, timestamp):
501500
if cred_id not in creds:
502501
# NOTE: could be optimized if multiple creds are requested
503502
creds[cred_id] = await self._get_credential(cred_id)
504-
timestamp = detail.get("timestamp")
503+
timestamp, rev_state = get_rev_state(cred_id, detail)
505504
present_creds.add_attributes(
506505
creds[cred_id],
507506
reft,
508507
reveal=detail["revealed"],
509508
timestamp=timestamp,
510-
rev_state=get_rev_state(cred_id, timestamp) if timestamp else None,
509+
rev_state=rev_state,
511510
)
512511
req_preds = requested_credentials.get("requested_predicates") or {}
513512
for reft, detail in req_preds.items():
513+
cred_id = detail["cred_id"]
514514
if cred_id not in creds:
515515
# NOTE: could be optimized if multiple creds are requested
516516
creds[cred_id] = await self._get_credential(cred_id)
517-
timestamp = detail.get("timestamp")
517+
timestamp, rev_state = get_rev_state(cred_id, detail)
518518
present_creds.add_predicates(
519519
creds[cred_id],
520520
reft,
521521
timestamp=timestamp,
522-
rev_state=get_rev_state(cred_id, timestamp) if timestamp else None,
522+
rev_state=rev_state,
523523
)
524524

525525
try:

demo/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ There are several demos available for ACA-Py mostly (but not only) aimed at deve
2525
- [Multi-ledger](#multi-ledger)
2626
- [DID Exchange](#did-exchange)
2727
- [Endorser](#endorser)
28-
- [Run Askar Backend](#run-askar-backend)
28+
- [Run Indy-SDK Backend](#run-indy-sdk-backend)
2929
- [Learning about the Alice/Faber code](#learning-about-the-alicefaber-code)
3030
- [OpenAPI (Swagger) Demo](#openapi-swagger-demo)
3131
- [Performance Demo](#performance-demo)
@@ -247,12 +247,12 @@ Note that you can't (currently) use the DID Exchange protocol to connect with an
247247

248248
This is described in [Endorser.md](Endorser.md)
249249

250-
### Run Askar Backend
250+
### Run Indy-SDK Backend
251251

252-
This runs using the askar libraries instead of indy-sdk:
252+
This runs using the indy-sdk libraries instead of askar:
253253

254254
```bash
255-
./run_demo faber --wallet-type askar
255+
./run_demo faber --wallet-type indy
256256
```
257257

258258
### Mediation
@@ -404,14 +404,20 @@ You can also run the demo against a postgres database using the following:
404404

405405
(Obvs you need to be running a postgres database - the command to start postgres is in the yml file provided above.)
406406

407-
You can tweak the number of credentials issued using the `--count` and `--batch` parameters, and you can run against an Askar database using the `--wallet-type askar` option.
407+
You can tweak the number of credentials issued using the `--count` and `--batch` parameters, and you can run against an Askar database using the `--wallet-type askar` option (or run using indy-sdk using `--wallet-type indy`).
408408

409409
An example full set of options is:
410410

411411
```bash
412412
./run_demo performance --arg-file demo/postgres-indy-args.yml -c 10000 -b 10 --wallet-type askar
413413
```
414414

415+
Or:
416+
417+
```bash
418+
./run_demo performance --arg-file demo/postgres-indy-args.yml -c 10000 -b 10 --wallet-type indy
419+
```
420+
415421
## Coding Challenge: Adding ACME
416422

417423
Now that you have a solid foundation in using ACA-Py, time for a coding challenge. In this challenge, we extend the Alice-Faber command line demo by adding in ACME Corp, a place where Alice wants to work. The demo adds:

demo/alice-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PYTHONPATH=.. ../bin/aca-py start \
1111
--outbound-transport http \
1212
--admin 0.0.0.0 8031 \
1313
--admin-insecure-mode \
14-
--wallet-type indy \
14+
--wallet-type askar \
1515
--wallet-name alice.agent420695 \
1616
--wallet-key alice.agent420695 \
1717
--preserve-exchange-records \

demo/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636
--tails-server-base-url 'https://tails-test.vonx.io' \
3737
--notify-revocation \
3838
--monitor-revocation-notification \
39-
--wallet-type 'indy' \
39+
--wallet-type 'askar' \
4040
--wallet-name 'acapy_agent_wallet' \
4141
--wallet-key 'key' \
4242
--wallet-storage-type 'postgres_storage' \

demo/faber-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PYTHONPATH=.. ../bin/aca-py start \
1111
--outbound-transport http \
1212
--admin 0.0.0.0 8021 \
1313
--admin-insecure-mode \
14-
--wallet-type indy \
14+
--wallet-type askar \
1515
--wallet-name faber.agent916333 \
1616
--wallet-key faber.agent916333 \
1717
--preserve-exchange-records \

demo/features/0453-issue-credential.feature

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@ Feature: RFC 0453 Aries agent issue credential
5454
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
5555
| --revocation --public-did | | driverslicense | Data_DL_NormalizedValues |
5656
| --revocation --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues |
57-
| --revocation --public-did --mediation | --mediation | driverslicense | Data_DL_NormalizedValues |
5857
| --revocation --public-did --multitenant | --multitenant | driverslicense | Data_DL_NormalizedValues |
58+
59+
@T004.1-RFC0453
60+
Scenario Outline: Issue a credential with revocation, with the Issuer beginning with an offer, and then revoking the credential
61+
Given we have "2" agents
62+
| name | role | capabilities |
63+
| Acme | issuer | <Acme_capabilities> |
64+
| Bob | holder | <Bob_capabilities> |
65+
And "Acme" and "Bob" have an existing connection
66+
And "Bob" has an issued <Schema_name> credential <Credential_data> from "Acme"
67+
Then "Acme" revokes the credential
68+
And "Bob" has the credential issued
69+
70+
Examples:
71+
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
72+
| --revocation --public-did --mediation | --mediation | driverslicense | Data_DL_NormalizedValues |

demo/features/0454-present-proof.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Feature: RFC 0454 Aries agent present proof
9797
| Acme | --revocation --public-did --mediation | | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |
9898
| Acme | --revocation --public-did --multitenant | --multitenant | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |
9999

100-
@T003-RFC0454.1
100+
@T003-RFC0454.1 @GHA
101101
Scenario Outline: Present Proof for multiple credentials where the one is revocable and one isn't
102102
Given we have "4" agents
103103
| name | role | capabilities |
@@ -117,7 +117,7 @@ Feature: RFC 0454 Aries agent present proof
117117
| issuer1 | Acme1_capabilities | issuer2 | Acme2_capabilities | Bob_cap | Schema_name_1 | Credential_data_1 | Schema_name_2 | Credential_data_2 | Proof_request |
118118
| Acme1 | --revocation --public-did | Acme2 | --public-did | | driverslicense_v2 | Data_DL_MaxValues | health_id | Data_DL_MaxValues | DL_age_over_19_v2_with_health_id |
119119

120-
@T003-RFC0454.2
120+
@T003-RFC0454.2 @GHA
121121
Scenario Outline: Present Proof for multiple credentials where the one is revocable and one isn't, and the revocable credential is revoked
122122
Given we have "4" agents
123123
| name | role | capabilities |

demo/local-indy-args.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ auto-ping-connection: true
2525
# curl -d '{"seed":"my_seed_000000000000000000000000", "role":"TRUST_ANCHOR", "alias":"My Agent"}' -X POST http://localhost:9000/register
2626
# note that the env var name is configured in argparse.py
2727
# seed = comes from ACAPY_WALLET_SEED
28-
wallet-type: indy
28+
wallet-type: askar
2929
wallet-name: testwallet
3030
# wallet-key = comes from ACAPY_WALLET_KEY
3131
# run a local postgres (docker) like:

demo/runners/support/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def __init__(
195195
else seed
196196
)
197197
self.storage_type = params.get("storage_type")
198-
self.wallet_type = params.get("wallet_type") or "indy"
198+
self.wallet_type = params.get("wallet_type") or "askar"
199199
self.wallet_name = (
200200
params.get("wallet_name") or self.ident.lower().replace(" ", "") + rand_name
201201
)

demo/runners/support/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def progress(*args, **kwargs):
235235

236236

237237
def check_requires(args):
238-
wtype = args.wallet_type or "indy"
238+
wtype = args.wallet_type or "askar"
239239

240240
if wtype == "indy":
241241
try:

0 commit comments

Comments
 (0)