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

Revocation in issue credential #432

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
8 changes: 6 additions & 2 deletions aries_cloudagent/issuer/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,12 @@ async def create_credential(
tails_reader_handle,
)
except AnoncredsRevocationRegistryFullError:
self.logger.error("Revocation registry is full when creating a credential.")
raise IssuerRevocationRegistryFullError("Revocation registry full")
self.logger.error(
f"Revocation registry {revoc_reg_id} is full: cannot create credential"
)
raise IssuerRevocationRegistryFullError(
f"Revocation registry {revoc_reg_id} full"
)
except IndyError as error:
raise IndyErrorHandler.wrap_error(
error, "Error when issuing credential", IssuerError
Expand Down
65 changes: 35 additions & 30 deletions aries_cloudagent/protocols/issue_credential/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ....core.error import BaseError
from ....holder.base import BaseHolder
from ....issuer.base import BaseIssuer
from ....issuer.indy import IssuerRevocationRegistryFullError
from ....ledger.base import BaseLedger
from ....messaging.credential_definitions.util import (
CRED_DEF_TAGS,
Expand Down Expand Up @@ -242,19 +243,6 @@ async def create_offer(
cred_preview = None

async def _create(cred_def_id):
ledger: BaseLedger = await self.context.inject(BaseLedger)
async with ledger:
credential_definition = await ledger.get_credential_definition(
cred_def_id
)
if (
credential_definition["value"].get("revocation")
and not credential_exchange_record.revoc_reg_id
):
raise CredentialManagerError(
"Missing revocation registry ID for revocable credential definition"
)

issuer: BaseIssuer = await self.context.inject(BaseIssuer)
offer_json = await issuer.create_credential_offer(cred_def_id)
return json.loads(offer_json)
Expand Down Expand Up @@ -498,31 +486,48 @@ async def issue_credential(
ledger: BaseLedger = await self.context.inject(BaseLedger)
async with ledger:
schema = await ledger.get_schema(schema_id)
credential_definition = await ledger.get_credential_definition(
credential_exchange_record.credential_definition_id
)

if credential_exchange_record.revoc_reg_id:
revoc = IndyRevocation(self.context)
registry_record = await revoc.get_issuer_rev_reg_record(
credential_exchange_record.revoc_reg_id
if credential_definition["value"]["revocation"]:
issuer_rev_regs = await IssuerRevRegRecord.query_by_cred_def_id(
self.context,
credential_exchange_record.credential_definition_id,
state=IssuerRevRegRecord.STATE_ACTIVE
)
# FIXME exception on missing
if not issuer_rev_regs:
raise CredentialManagerError(
"Cred def id {} has no active revocation registry".format(
credential_exchange_record.credential_definition_id
)
)

registry = await registry_record.get_registry()
registry = await issuer_rev_regs[0].get_registry()
credential_exchange_record.revoc_reg_id = (
issuer_rev_regs[0].revoc_reg_id
)
tails_path = registry.tails_local_path
else:
tails_path = None

issuer: BaseIssuer = await self.context.inject(BaseIssuer)
(
credential_json,
credential_exchange_record.revocation_id,
) = await issuer.create_credential(
schema,
credential_offer,
credential_request,
credential_values,
credential_exchange_record.revoc_reg_id,
tails_path,
)
try:
(
credential_json,
credential_exchange_record.revocation_id,
) = await issuer.create_credential(
schema,
credential_offer,
credential_request,
credential_values,
credential_exchange_record.revoc_reg_id,
tails_path,
)
except IssuerRevocationRegistryFullError:
await registry.mark_full(self.context)
raise

credential_exchange_record.credential = json.loads(credential_json)

credential_exchange_record.state = V10CredentialExchange.STATE_ISSUED
Expand Down
Loading