-
Notifications
You must be signed in to change notification settings - Fork 516
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
DIDComm V2 Initial Implementation #2959
Merged
jamshale
merged 44 commits into
openwallet-foundation:main
from
Indicio-tech:feat/didcommv2-proof-of-concept
Jul 2, 2024
Merged
Changes from 17 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
223e9f9
feat: (WIP) didcommv2 handling
mepeltier f6ed06d
feat: wallet methods for assigning kid to keys
dbluhm 88ba288
refactor: inject DMP dependencies
dbluhm c41d437
fix: x25519 key creation and transformation
mepeltier 7a9030d
feat: (WIP) didcomm v2 message handling
mepeltier a8530ff
feat: add flag for didcomm v2 support
mepeltier d39eb4d
chore: remove unnecessary logs
mepeltier 2693a93
feat: Add first pass of DIDComm V2 response
TheTechmage e15267a
refactor: revert profile/session injection
dbluhm 4808708
feat: resolve circular dependency
mepeltier 1089a22
feat: add additional dcv2 flag checks
mepeltier 1ced95a
feat: revert bbs removal
mepeltier 1c47e3b
feat: make dmp an optional dep
mepeltier 87ec574
chore: adjust flag pattern
mepeltier 291d4e1
feat: Return Problem Report for DIDComm V2
TheTechmage 30107e8
chore: balck
TheTechmage d6c3f19
chore: cleanup lock file after rebase
TheTechmage bb2a20a
feat: split out v2 pack format
mepeltier 1131c91
feat: gate didcommv2 imports on didcommv2 flag
mepeltier 2a3067e
chore: cleanup lingering logging statements
mepeltier 4fa84ad
feat: Return DIDComm V2 problem report
TheTechmage 258d8fc
Merge branch 'feat/didcommv2-proof-of-concept' of github.com:Indicio-…
TheTechmage 4e7fc62
fix: conditional imports
mepeltier 3b0c966
fix: get unit tests passing
mepeltier 6a8e140
Merge branch 'main' into feat/didcommv2-proof-of-concept
mepeltier 0244092
chore: poetry lock
mepeltier 8ae16d3
chore: minor cleanup
mepeltier 8bf1d85
fix: fixes for tests
mepeltier d20918e
Merge branch 'main' into feat/didcommv2-proof-of-concept
mepeltier bc5fde9
chore: poetry lock
mepeltier b7073bb
fix: move split to last possible moment
TheTechmage cd44785
feat: Add didcommv2 extra to Dockerfile for builds
TheTechmage 0020ff8
Merge remote-tracking branch 'origin/main' into feat/didcommv2-proof-…
TheTechmage 3d151c6
feat: adjust test build for didcommv2 tests
mepeltier 5fa9e11
feat: add tests for didcommv2 adapters
mepeltier 2cb2ca2
feat: tests for v2 pack format
mepeltier 85a3a52
chore: poetry lock
mepeltier a515948
Merge branch 'main' into feat/didcommv2-proof-of-concept
mepeltier f917714
chore: poetry lock
mepeltier eed6981
feat: additional in_memory wallet test
mepeltier dc1ee0a
Merge branch 'main' into feat/didcommv2-proof-of-concept
mepeltier 8bb32d0
chore: poetry lock
mepeltier fdc4408
Merge branch 'main' into feat/didcommv2-proof-of-concept
mepeltier 118d319
chore: poetry lock
mepeltier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .adapters import ResolverAdapter, SecretsAdapter | ||
|
||
|
||
__all__ = ["ResolverAdapter", "SecretsAdapter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"""Adapters for DMP library.""" | ||
|
||
import logging | ||
from typing import Optional, cast | ||
from aries_askar import Key | ||
from didcomm_messaging import SecretsManager | ||
from didcomm_messaging.crypto.backend.askar import AskarSecretKey | ||
from didcomm_messaging.resolver import DIDResolver as DMPResolver | ||
|
||
from ..core.error import BaseError | ||
from ..core.profile import Profile, ProfileSession | ||
from ..resolver.did_resolver import DIDResolver | ||
from ..askar.profile import AskarProfileSession | ||
|
||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class DMPAdapterError(BaseError): | ||
"""Raised on general errors from DMP Adapters.""" | ||
|
||
|
||
class ResolverAdapter(DMPResolver): | ||
"""Adapter for ACA-Py resolver to DMP Resolver.""" | ||
|
||
def __init__(self, profile: Profile, resolver: DIDResolver): | ||
"""Init the adapter.""" | ||
self.profile = profile | ||
self.resolver = resolver | ||
|
||
async def resolve(self, did: str) -> dict: | ||
"""Resolve a DID.""" | ||
return await self.resolver.resolve(self.profile, did) | ||
|
||
async def is_resolvable(self, did: str) -> bool: | ||
"""Check to see if a DID is resolvable.""" | ||
for resolver in self.resolver.resolvers: | ||
if await resolver.supports(self.profile, did): | ||
return True | ||
|
||
return False | ||
|
||
|
||
class SecretsAdapterError(DMPAdapterError): | ||
"""Errors from DMP Secrets Adapter.""" | ||
|
||
|
||
class SecretsAdapter(SecretsManager[AskarSecretKey]): | ||
"""Adapter for providing a secrets manager compatible with DMP.""" | ||
|
||
def __init__(self, session: ProfileSession): | ||
"""Init the adapter.""" | ||
self.session = session | ||
|
||
async def get_secret_by_kid(self, kid: str) -> Optional[AskarSecretKey]: | ||
"""Get a secret key by its ID.""" | ||
if not isinstance(self.session, AskarProfileSession): | ||
raise SecretsAdapterError( | ||
"ACA-Py's implementation of DMP only supports an Askar backend" | ||
) | ||
|
||
LOGGER.debug("GETTING SECRET BY KID: %s", kid) | ||
key_entries = await self.session.handle.fetch_all_keys( | ||
tag_filter={"kid": kid}, limit=2 | ||
) | ||
if len(key_entries) > 1: | ||
raise SecretsAdapterError(f"More than one key found with kid {kid}") | ||
|
||
entry = key_entries[0] | ||
if entry: | ||
key = cast(Key, entry.key) | ||
return AskarSecretKey(key=key, kid=kid) | ||
|
||
LOGGER.debug("RETURNING NONE") | ||
return None |
TheTechmage marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""DIDComm V2 Agent message base class and schema.""" | ||
|
||
from .base_message import BaseMessage | ||
from .models.base import BaseModel | ||
|
||
|
||
class V2AgentMessage(BaseModel, BaseMessage): | ||
"""DIDComm V2 message base class.""" | ||
|
||
class Meta: | ||
"""DIDComm V2 message metadats.""" | ||
|
||
schema_class = None | ||
message_type = None |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling out a limitation: experimental v2 support will only work using did:peer:2 right now.
Should we implement it for did:peer:4 as well at this stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how early we are in the process, I don't think its necessary, but at the same time, it might be worth getting it in before our changes are more solidified. It'll also probably make it easier to switch off of did:peer:2, which is a good thing imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do believe that it's not limited to
did:peer:2
. Otherdid:peer
methods should be supported as well. Once I have something better to key off of for outbound, things likedid:web
should work (in theory). Though you are right in that alldid
methods, aside fromdid:peer:2
, are currently untested