Skip to content

Commit

Permalink
Fix mistakes / enable anoncreds integration endorsement testing
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Feb 7, 2024
1 parent 39f98c0 commit 0d7a2a8
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 99 deletions.
24 changes: 15 additions & 9 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,12 @@ async def update_revocation_list(
)

result = await self._revoc_reg_entry_with_fix(
profile, curr_list, rev_reg_def.type, rev_reg_entry, True, None
profile,
curr_list,
rev_reg_def.type,
rev_reg_entry,
write_ledger,
endorser_did,
)

if write_ledger:
Expand Down Expand Up @@ -1120,14 +1125,15 @@ async def txn_submit(
raise LedgerError("No ledger available")

try:
return await shield(
ledger.txn_submit(
ledger_transaction,
sign=sign,
taa_accept=taa_accept,
sign_did=sign_did,
write_ledger=write_ledger,
async with ledger:
return await shield(
ledger.txn_submit(
ledger_transaction,
sign=sign,
taa_accept=taa_accept,
sign_did=sign_did,
write_ledger=write_ledger,
)
)
)
except LedgerError as err:
raise AnonCredsRegistrationError(err.roll_up) from err
26 changes: 17 additions & 9 deletions aries_cloudagent/anoncreds/revocation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def register_events(self, event_bus: EventBus):
async def on_cred_def(self, profile: Profile, event: CredDefFinishedEvent):
"""Handle cred def finished."""
payload = event.payload
if payload.support_revocation:
auto_create_revocation = profile.settings.get(
"endorser.auto_create_rev_reg", False
)
if payload.support_revocation and auto_create_revocation:
revoc = AnonCredsRevocation(profile)
for registry_count in range(self.INITIAL_REGISTRY_COUNT):
await revoc.create_and_register_revocation_registry_definition(
Expand All @@ -75,15 +78,20 @@ async def on_cred_def(self, profile: Profile, event: CredDefFinishedEvent):

async def on_rev_reg_def(self, profile: Profile, event: RevRegDefFinishedEvent):
"""Handle rev reg def finished."""
revoc = AnonCredsRevocation(profile)
await revoc.upload_tails_file(event.payload.rev_reg_def)
await revoc.create_and_register_revocation_list(
event.payload.rev_reg_def_id, event.payload.options
payload = event.payload
auto_create_revocation = profile.settings.get(
"endorser.auto_create_rev_reg", False
)

if event.payload.rev_reg_def.tag == str(0):
# Mark the first registry as active
await revoc.set_active_registry(event.payload.rev_reg_def_id)
if auto_create_revocation:
revoc = AnonCredsRevocation(profile)
await revoc.upload_tails_file(payload.rev_reg_def)
await revoc.create_and_register_revocation_list(
payload.rev_reg_def_id, payload.options
)

if payload.rev_reg_def.tag == str(0):
# Mark the first registry as active
await revoc.set_active_registry(payload.rev_reg_def_id)

async def on_rev_list(self, profile: Profile, event: RevListFinishedEvent):
"""Handle rev list finished."""
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ async def rev_reg_def_post(request: web.BaseRequest):
issuer_id = revocation_registry_definition.get("issuerId")
cred_def_id = revocation_registry_definition.get("credDefId")
max_cred_num = revocation_registry_definition.get("maxCredNum")
tag = revocation_registry_definition.get("tag")

issuer = AnonCredsIssuer(context.profile)
revocation = AnonCredsRevocation(context.profile)
Expand All @@ -566,7 +567,7 @@ async def rev_reg_def_post(request: web.BaseRequest):
cred_def_id,
registry_type="CL_ACCUM",
max_cred_num=max_cred_num,
tag="default",
tag=tag,
options=options,
)
)
Expand Down
9 changes: 7 additions & 2 deletions aries_cloudagent/ledger/indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,11 @@ async def send_revoc_reg_def(
write_ledger=write_ledger,
endorser_did=endorser_did,
)
legacy_indy_registry = LegacyIndyRegistry()

if endorser_did and not write_ledger:
rev_reg_def_req.set_endorser(endorser_did)

legacy_indy_registry = LegacyIndyRegistry()
resp = await legacy_indy_registry.txn_submit(
self.profile,
rev_reg_def_req,
Expand Down Expand Up @@ -1214,8 +1217,10 @@ async def send_revoc_reg_entry(
write_ledger=write_ledger,
endorser_did=endorser_did,
)
if endorser_did and not write_ledger:
revoc_reg_entry_req.set_endorser(endorser_did)

legacy_indy_registry = LegacyIndyRegistry()

resp = await legacy_indy_registry.txn_submit(
self.profile,
revoc_reg_entry_req,
Expand Down
50 changes: 45 additions & 5 deletions demo/features/0586-sign-transaction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
Examples:
| Acme_capabilities | Bob_capabilities | Schema_name |
| --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | anoncreds-testing |
| --wallet-type askar-anoncreds | | anoncreds-testing |
| --wallet-type askar-anoncreds | | driverslicense |
| | --wallet-type askar-anoncreds | anoncreds-testing |


@T001.1-RFC0586
@T001.1-RFC0586 @GHA
Scenario Outline: endorse a transaction and write to the ledger
Given we have "2" agents
| name | role | capabilities |
Expand All @@ -60,8 +60,9 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
And "Bob" has written the schema <Schema_name> to the ledger

Examples:
| Acme_capabilities | Bob_capabilities | Schema_name |
| | | driverslicense |
| Acme_capabilities | Bob_capabilities | Schema_name |
| | | driverslicense |
| | --wallet-type askar-anoncreds | anoncreds-testing |


@T002-RFC0586
Expand Down Expand Up @@ -107,8 +108,17 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
| --revocation --public-did --mediation | --revocation --mediation | driverslicense | Data_DL_NormalizedValues |
| --revocation --public-did --multitenant | --revocation --multitenant | driverslicense | Data_DL_NormalizedValues |
| --revocation --public-did --mediation --multitenant | --revocation --mediation --multitenant | driverslicense | Data_DL_NormalizedValues |

@Mulitledger
Examples:
| Acme_capabilities | Bob_capabilties | Schema_name | Credential_data |
| --multitenant --multi-ledger --revocation --public-did | --multitenant --multi-ledger --revocation | driverslicense | Data_DL_NormalizedValues |

@WalletType_Askar_AnonCreds
Examples:
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --revocation --public-did --did-exchange | --revocation --did-exchange --wallet-type askar-anoncreds | anoncreds-testing | Data_AC_NormalizedValues |

@T002.1-RFC0586 @GHA
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, manually invoking each endorsement endpoint
Given we have "2" agents
Expand Down Expand Up @@ -150,6 +160,12 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --revocation --public-did | --revocation | driverslicense | Data_DL_NormalizedValues |

@WalletType_Askar_AnonCreds
Examples:
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --revocation --public-did | --revocation --wallet-type askar-anoncreds | anoncreds-testing | Data_AC_NormalizedValues |


@T003-RFC0586
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, with auto endorsing workflow
Given we have "2" agents
Expand Down Expand Up @@ -180,7 +196,7 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
| --endorser-role endorser --revocation --public-did --multitenant | --endorser-role author --revocation --multitenant | driverslicense | Data_DL_NormalizedValues |
| --endorser-role endorser --revocation --public-did --mediation --multitenant | --endorser-role author --revocation --mediation --multitenant | driverslicense | Data_DL_NormalizedValues |

@T003.1-RFC0586 @GHA
@T003.1-RFC0586 @GHA
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, with auto endorsing workflow
Given we have "2" agents
| name | role | capabilities |
Expand All @@ -207,3 +223,27 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --endorser-role endorser --revocation --public-did | --endorser-role author --revocation | driverslicense | Data_DL_NormalizedValues |
| --endorser-role endorser --revocation --public-did | --endorser-role author --revocation --multitenant | driverslicense | Data_DL_NormalizedValues |

@T003.2-RFC0586 @GHA
Scenario Outline: endorse a schema and cred def transaction, write to the ledger, issue and revoke a credential, with auto endorsing workflow
Given we have "2" agents
| name | role | capabilities |
| Acme | endorser | <Acme_capabilities> |
| Bob | author | <Bob_capabilities> |
And "Acme" and "Bob" have an existing connection
When "Acme" has a DID with role "ENDORSER"
And "Acme" connection has job role "TRANSACTION_ENDORSER"
And "Bob" connection has job role "TRANSACTION_AUTHOR"
And "Bob" connection sets endorser info
And "Bob" has a DID with role "AUTHOR"
And "Bob" authors a schema transaction with <Schema_name>
And "Bob" has written the schema <Schema_name> to the ledger
And "Bob" authors a credential definition transaction with <Schema_name>
And "Bob" has written the credential definition for <Schema_name> to the ledger
And "Bob" has written the revocation registry definition to the ledger
And "Bob" has written the revocation registry entry transaction to the ledger
And "Acme" has an issued <Schema_name> credential <Credential_data> from "Bob"

Examples:
| Acme_capabilities | Bob_capabilities | Schema_name | Credential_data |
| --endorser-role endorser --revocation --public-did | --endorser-role author --revocation --wallet-type askar-anoncreds | anoncreds-testing | Data_AC_NormalizedValues |
Loading

0 comments on commit 0d7a2a8

Please sign in to comment.