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

DIF Presentation Exchange and present-proof-v2 Updates #1125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7fa9500
DIF Pres Exch
shaangill025 Apr 29, 2021
ccd9bcd
Adding dependancies
shaangill025 Apr 29, 2021
fe27020
Fixes and cleanup
shaangill025 Apr 30, 2021
557bcb0
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Apr 30, 2021
09b7d68
Fixing _id in dif pres exch schema
shaangill025 Apr 30, 2021
afd5d85
Merge branch 'main' into dif-pres-exch
shaangill025 May 1, 2021
657aeb8
final impl
shaangill025 May 10, 2021
9fde5a1
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 10, 2021
3f5877f
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 10, 2021
c9444b0
fix missing import
shaangill025 May 10, 2021
f61d855
bug fix
shaangill025 May 10, 2021
782c83f
merge changes and resolve conflicts
shaangill025 May 10, 2021
225afb7
Merge branch 'main' into dif-pres-exch
shaangill025 May 11, 2021
841c2cd
Fixed docker-compose
shaangill025 May 11, 2021
c5aea45
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 11, 2021
4e0c1f0
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 11, 2021
708e7ec
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 11, 2021
bb92c05
expanded type as cred_tag
shaangill025 May 11, 2021
626531f
present-proof-v1 and v2 indy refactoring and cleanup
shaangill025 May 12, 2021
6cdc24b
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 12, 2021
c29bf2f
formatting fix
shaangill025 May 12, 2021
f047710
formatting fix
shaangill025 May 12, 2021
e7f18c7
fix redundant data-keys
shaangill025 May 12, 2021
dbd3b86
refactoring dif_format_handler
shaangill025 May 12, 2021
d205207
refactoring format handlers and v2_0 manager
shaangill025 May 12, 2021
8bf9d11
merge changes and resolve conflict
shaangill025 May 12, 2021
4e70a79
AIP 2.0 changes
shaangill025 May 13, 2021
c2b6224
formatting fixes
shaangill025 May 13, 2021
3e0819c
OOB and cred_tag fix and Feedback improvement
shaangill025 May 17, 2021
c98b8b2
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 17, 2021
23b464f
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 17, 2021
8ec1bb6
fixes
shaangill025 May 17, 2021
18a5a0a
format handler instance variable fixes
shaangill025 May 18, 2021
41318ec
final updates
shaangill025 May 18, 2021
82a3d7f
merge main changes, resolve conflict & test coverage
shaangill025 May 19, 2021
65310d3
formatting fix
shaangill025 May 19, 2021
2f92b1c
Merge branch 'main' into dif-pres-exch
shaangill025 May 19, 2021
557916c
re-run checks
shaangill025 May 19, 2021
7f1f5af
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 19, 2021
2d5b20a
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 19, 2021
ba78b0e
Merge branch 'main' into dif-pres-exch
shaangill025 May 19, 2021
ed43e23
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 19, 2021
f7749a6
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 19, 2021
bca2d49
Merge branch 'main' into dif-pres-exch
shaangill025 May 20, 2021
537f25d
Merge main changes into dif-pres-exch and filter updates
shaangill025 May 27, 2021
6d13520
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 27, 2021
37fbce4
test fix
shaangill025 May 27, 2021
8ef4885
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 27, 2021
71c708b
Merge branch 'main' into dif-pres-exch
shaangill025 May 27, 2021
3066df9
more exception handling - DIF filter
shaangill025 May 27, 2021
2949d6d
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 May 27, 2021
9c0ac27
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 May 27, 2021
050ed22
w3c credential - expanded_type instead of short type
shaangill025 May 27, 2021
d3da6f9
resolve conflicts and merge main changes
shaangill025 May 28, 2021
0373bc2
issue-credential-v2 format handlers update
shaangill025 May 28, 2021
64ce9cd
small oob adjustment after merge
shaangill025 May 28, 2021
2a84001
bbs suite fix and other changes
shaangill025 Jun 1, 2021
791e347
updated graph struct handling
shaangill025 Jun 1, 2021
90ef978
cred endpoint fix, cleanup/fixes and test coverage
shaangill025 Jun 3, 2021
b9bca33
fix: blank node id transformation using regex
TimoGlastra Jun 5, 2021
c006cea
test updates and fixes
shaangill025 Jun 6, 2021
ff8f143
Merge branch 'dif-pres-exch' of https://github.com/shaangill025/aries…
shaangill025 Jun 6, 2021
e18591f
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Jun 6, 2021
e3369da
updated w3c credential fetching logic, raise exception with only base…
shaangill025 Jun 7, 2021
c5fc0d7
Merge branch 'main' of https://github.com/hyperledger/aries-cloudagen…
shaangill025 Jun 7, 2021
815f2d3
Raise exception on json_path match on proof object
shaangill025 Jun 7, 2021
5d025d6
restrict w3c credential fetching by specifying record_ids
shaangill025 Jun 8, 2021
67a78e3
Merge branch 'main' into dif-pres-exch
shaangill025 Jun 8, 2021
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
2 changes: 1 addition & 1 deletion aries_cloudagent/holder/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from ..admin.request_context import AdminRequestContext
from ..indy.holder import IndyHolder, IndyHolderError
from ..indy.sdk.models.cred_precis import IndyCredInfoSchema
from ..indy.models.cred_precis import IndyCredInfoSchema
from ..ledger.base import BaseLedger
from ..ledger.error import LedgerError
from ..messaging.models.openapi import OpenAPISchema
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/holder/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
VC_RECORD = VCRecord(
contexts=[
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/v1/examples",
"https://www.w3.org/2018/credentials/examples/v1",
],
types=[
"VerifiableCredential",
"AlumniCredential",
expanded_types=[
"https://www.w3.org/2018/credentials#VerifiableCredential",
"https://example.org/examples#UniversityDegreeCredential",
],
issuer_id="https://example.edu/issuers/565049",
subject_ids=["did:example:ebfeb1f712ebc6f1c276e12ec21"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from marshmallow import EXCLUDE, fields

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import (
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import (
INDY_CRED_DEF_ID,
INDY_REV_REG_ID,
INDY_SCHEMA_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from marshmallow import EXCLUDE, fields

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import INDY_CRED_DEF_ID, INDY_SCHEMA_ID, NUM_STR_WHOLE
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import INDY_CRED_DEF_ID, INDY_SCHEMA_ID, NUM_STR_WHOLE


class IndyKeyCorrectnessProof(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from marshmallow import fields, Schema

from ....messaging.models.openapi import OpenAPISchema
from ....messaging.valid import INDY_CRED_DEF_ID, INDY_VERSION, NUM_STR_WHOLE
from ...messaging.models.openapi import OpenAPISchema
from ...messaging.valid import INDY_CRED_DEF_ID, INDY_VERSION, NUM_STR_WHOLE


class CredDefValuePrimarySchema(OpenAPISchema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from marshmallow import EXCLUDE, fields

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.models.openapi import OpenAPISchema
from ....messaging.valid import (
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.models.openapi import OpenAPISchema
from ...messaging.valid import (
INDY_CRED_DEF_ID,
INDY_CRED_REV_ID,
INDY_REV_REG_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from marshmallow import EXCLUDE, fields

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import INDY_CRED_DEF_ID, INDY_DID, NUM_STR_WHOLE
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import INDY_CRED_DEF_ID, INDY_DID, NUM_STR_WHOLE


class IndyCredRequest(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from marshmallow import EXCLUDE, fields

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import INT_EPOCH
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import INT_EPOCH


class IndyNonRevocationInterval(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

from marshmallow import EXCLUDE, fields

from ....ledger.indy import IndySdkLedger
from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.util import canon
from ....messaging.valid import INDY_CRED_DEF_ID, INDY_PREDICATE
from ....protocols.didcomm_prefix import DIDCommPrefix
from ....wallet.util import b64_to_str

from ...util import generate_pr_nonce
from ...ledger.indy import IndySdkLedger
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.util import canon
from ...messaging.valid import INDY_CRED_DEF_ID, INDY_PREDICATE
from ...protocols.didcomm_prefix import DIDCommPrefix
from ...wallet.util import b64_to_str

from ..util import generate_pr_nonce

from .non_rev_interval import IndyNonRevocationInterval
from .predicate import Predicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from marshmallow import EXCLUDE, fields, validate

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import (
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import (
INDY_CRED_DEF_ID,
INDY_REV_REG_ID,
INDY_SCHEMA_ID,
INT_EPOCH,
NUM_STR_WHOLE,
)
from ....utils.tracing import AdminAPIMessageTracingSchema
from ...utils.tracing import AdminAPIMessageTracingSchema

from .predicate import Predicate
from .requested_creds import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
ValidationError,
)

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.models.openapi import OpenAPISchema
from ....messaging.valid import (
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.models.openapi import OpenAPISchema
from ...messaging.valid import (
INDY_CRED_DEF_ID,
INDY_PREDICATE,
INDY_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from marshmallow import fields

from ....messaging.models.openapi import OpenAPISchema
from ....messaging.valid import INT_EPOCH
from ...messaging.models.openapi import OpenAPISchema
from ...messaging.valid import INT_EPOCH


class IndyRequestedCredsRequestedAttrSchema(OpenAPISchema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from marshmallow import EXCLUDE, fields, validate

from ....messaging.models.base import BaseModel, BaseModelSchema
from ....messaging.valid import (
from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import (
BASE58_SHA256_HASH,
INDY_CRED_DEF_ID,
INDY_REV_REG_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from marshmallow import fields

from ....messaging.models.openapi import OpenAPISchema
from ....messaging.valid import INDY_SCHEMA_ID, INDY_VERSION, NATURAL_NUM
from ...messaging.models.openapi import OpenAPISchema
from ...messaging.valid import INDY_SCHEMA_ID, INDY_VERSION, NATURAL_NUM


class SchemaSchema(OpenAPISchema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from asynctest import TestCase as AsyncTestCase
from asynctest import mock as async_mock

from .....messaging.util import canon
from .....protocols.didcomm_prefix import DIDCommPrefix
from ....messaging.util import canon
from ....protocols.didcomm_prefix import DIDCommPrefix


from ..non_rev_interval import IndyNonRevocationInterval
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities to deal with indy."""

from ....indy.holder import IndyHolder
from ...indy.holder import IndyHolder

from .pres_preview import IndyPresPreview

Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/indy/sdk/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import indy.anoncreds
from indy.error import IndyError

from ...indy.sdk.models.xform import indy_proof_req2non_revoc_intervals
from ...indy.models.xform import indy_proof_req2non_revoc_intervals
from ...ledger.indy import IndySdkLedger
from ...messaging.util import canon, encode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from ...admin.request_context import AdminRequestContext
from ...indy.issuer import IndyIssuer
from ...indy.sdk.models.cred_def import CredentialDefinitionSchema
from ...indy.models.cred_def import CredentialDefinitionSchema
from ...ledger.base import BaseLedger
from ...ledger.error import LedgerError
from ...protocols.endorse_transaction.v1_0.manager import TransactionManager
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/messaging/schemas/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from ...admin.request_context import AdminRequestContext
from ...indy.issuer import IndyIssuer, IndyIssuerError
from ...indy.sdk.models.schema import SchemaSchema
from ...indy.models.schema import SchemaSchema
from ...ledger.base import BaseLedger
from ...ledger.error import LedgerError
from ...protocols.endorse_transaction.v1_0.manager import TransactionManager
Expand Down
13 changes: 13 additions & 0 deletions aries_cloudagent/messaging/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def _deserialize(self, value, attr, data, **kwargs):
raise ValidationError("Field should be str or dict")


class StrOrNumberField(Field):
"""String or Number field for Marshmallow."""

def _serialize(self, value, attr, obj, **kwargs):
return value

def _deserialize(self, value, attr, data, **kwargs):
if isinstance(value, (str, float, int)):
return value
else:
raise ValidationError("Field should be str or int or float")


class DictOrDictListField(Field):
"""Dict or Dict List field for Marshmallow."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from marshmallow import fields, validate

from .....core.profile import ProfileSession
from .....indy.sdk.models.cred import IndyCredential, IndyCredentialSchema
from .....indy.sdk.models.cred_abstract import IndyCredAbstract, IndyCredAbstractSchema
from .....indy.sdk.models.cred_precis import IndyCredInfo, IndyCredInfoSchema
from .....indy.sdk.models.cred_request import IndyCredRequest, IndyCredRequestSchema
from .....indy.models.cred import IndyCredential, IndyCredentialSchema
from .....indy.models.cred_abstract import IndyCredAbstract, IndyCredAbstractSchema
from .....indy.models.cred_precis import IndyCredInfo, IndyCredInfoSchema
from .....indy.models.cred_request import IndyCredRequest, IndyCredRequestSchema
from .....messaging.models.base_record import BaseExchangeRecord, BaseExchangeSchema
from .....messaging.valid import INDY_CRED_DEF_ID, INDY_SCHEMA_ID, UUIDFour
from .....storage.base import StorageError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
from abc import ABC, abstractclassmethod, abstractmethod
import logging

from typing import Mapping, Tuple, Union
from typing import Mapping, Tuple

from .....core.error import BaseError
from .....core.profile import Profile
from .....messaging.decorators.attach_decorator import AttachDecorator

from ..message_types import ATTACHMENT_FORMAT
from ..messages.cred_format import V20CredFormat
from ..messages.cred_proposal import V20CredProposal
from ..messages.cred_offer import V20CredOffer
from ..messages.cred_request import V20CredRequest
from ..messages.cred_issue import V20CredIssue
from ..models.detail.indy import V20CredExRecordIndy
from ..models.detail.ld_proof import V20CredExRecordLDProof
from ..models.cred_ex_record import V20CredExRecord

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -50,32 +47,7 @@ def profile(self) -> Profile:
"""
return self._profile

async def get_detail_record(
self, cred_ex_id: str
) -> Union[V20CredExRecordIndy, V20CredExRecordLDProof]:
"""Retrieve credential exchange detail record by cred_ex_id."""

async with self.profile.session() as session:
records = await self.format.detail.query_by_cred_ex_id(session, cred_ex_id)

if len(records) > 1:
LOGGER.warning(
"Cred ex id %s has %d %s detail records: should be 1",
cred_ex_id,
len(records),
self.format.api,
)
return records[0] if records else None

async def _check_uniqueness(self, cred_ex_id: str):
"""Raise exception on evidence that cred ex already has cred issued to it."""
async with self.profile.session() as session:
if await self.format.detail.query_by_cred_ex_id(session, cred_ex_id):
raise V20CredFormatError(
f"{self.format.api} detail record already "
f"exists for cred ex id {cred_ex_id}"
)

@abstractmethod
def get_format_identifier(self, message_type: str) -> str:
"""Get attachment format identifier for format and message combination.

Expand All @@ -86,31 +58,10 @@ def get_format_identifier(self, message_type: str) -> str:
str: Issue credential attachment format identifier

"""
return ATTACHMENT_FORMAT[message_type][self.format.api]

@abstractmethod
def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment:
"""Get credential format and attachment objects for use in cred ex messages.

Returns a tuple of both credential format and attachment decorator for use
in credential exchange messages. It looks up the correct format identifier and
encodes the data as a base64 attachment.

Args:
message_type (str): The message type for which to return the cred format.
Should be one of the message types defined in the message types file
data (dict): The data to include in the attach decorator

Returns:
CredFormatAttachment: Credential format and attachment data objects

"""
return (
V20CredFormat(
attach_id=self.format.api,
format_=self.get_format_identifier(message_type),
),
AttachDecorator.data_base64(data, ident=self.format.api),
)
"""Get credential format and attachment objects for use in cred ex messages."""

@abstractclassmethod
def validate_fields(cls, message_type: str, attachment_data: dict) -> None:
Expand Down
Loading