Skip to content

Commit

Permalink
Add #21 Ability to switch trust anchors when a credential is issued a…
Browse files Browse the repository at this point in the history
…nd verified
  • Loading branch information
albinpa committed Jul 21, 2023
1 parent 84fc156 commit 659ac48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mydata_did/patched_protocols/issue_credential/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from aries_cloudagent.connections.models.connection_record import ConnectionRecord

from mydata_did.v1_0.models.exchange_records.data_agreement_record import DataAgreementV1Record
from mydata_did.v1_0.manager import DataAgreementMethodOfUse

from .messages.credential_ack import CredentialAck
from .messages.credential_issue import CredentialIssue
Expand Down Expand Up @@ -37,7 +38,6 @@

LOGGER = logging.getLogger(__name__)


class CredentialManagerError(BaseError):
"""Credential error."""

Expand Down Expand Up @@ -248,8 +248,8 @@ async def _create(cred_def_id):
# vet attributes
ledger: BaseLedger = await self.context.inject(BaseLedger)
async with ledger:
schema_id = await ledger.credential_definition_id2schema_id(cred_def_id)
schema = await ledger.get_schema(schema_id)
schema_id = await ledger.credential_definition_id2schema_id(cred_def_id, operational_context=DataAgreementMethodOfUse.DATA_SOURCE)
schema = await ledger.get_schema(schema_id, operational_context=DataAgreementMethodOfUse.DATA_SOURCE)
schema_attrs = {attr for attr in schema["attrNames"]}
preview_attrs = {attr for attr in cred_preview.attr_dict()}
if preview_attrs != schema_attrs:
Expand Down
10 changes: 6 additions & 4 deletions mydata_did/patched_protocols/present_proof/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
import time

from mydata_did.v1_0.manager import DataAgreementMethodOfUse

from aries_cloudagent.revocation.models.revocation_registry import RevocationRegistry
from aries_cloudagent.config.injection_context import InjectionContext
from aries_cloudagent.core.error import BaseError
Expand Down Expand Up @@ -537,21 +539,21 @@ async def verify_presentation(
# Build schemas for anoncreds
if identifier["schema_id"] not in schemas:
schemas[identifier["schema_id"]] = await ledger.get_schema(
identifier["schema_id"]
identifier["schema_id"], operational_context = DataAgreementMethodOfUse.DATA_USING_SERVICE
)

if identifier["cred_def_id"] not in credential_definitions:
credential_definitions[
identifier["cred_def_id"]
] = await ledger.get_credential_definition(
identifier["cred_def_id"]
identifier["cred_def_id"], operational_context = DataAgreementMethodOfUse.DATA_USING_SERVICE
)

if identifier.get("rev_reg_id"):
if identifier["rev_reg_id"] not in rev_reg_defs:
rev_reg_defs[
identifier["rev_reg_id"]
] = await ledger.get_revoc_reg_def(identifier["rev_reg_id"])
] = await ledger.get_revoc_reg_def(identifier["rev_reg_id"], operational_context = DataAgreementMethodOfUse.DATA_USING_SERVICE)

if identifier.get("timestamp"):
rev_reg_entries.setdefault(identifier["rev_reg_id"], {})
Expand All @@ -564,7 +566,7 @@ async def verify_presentation(
found_rev_reg_entry,
_found_timestamp,
) = await ledger.get_revoc_reg_entry(
identifier["rev_reg_id"], identifier["timestamp"]
identifier["rev_reg_id"], identifier["timestamp"], operational_context = DataAgreementMethodOfUse.DATA_USING_SERVICE
)
rev_reg_entries[identifier["rev_reg_id"]][
identifier["timestamp"]
Expand Down
4 changes: 3 additions & 1 deletion mydata_did/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
from mydata_did.v1_0.utils.did.mydata_did import DIDMyData
from mydata_did.v1_0.utils.wallet.key_type import KeyType


class DataAgreementMethodOfUse():
DATA_SOURCE = "data-source"
DATA_USING_SERVICE = "data-using-service"
class ADAManagerError(BaseError):
"""ADA manager error"""

Expand Down

0 comments on commit 659ac48

Please sign in to comment.