Skip to content

Commit

Permalink
Merge pull request #1061 from animo/cwu-bbs-main
Browse files Browse the repository at this point in the history
CWU - W3C Issue Credential
  • Loading branch information
ianco authored Apr 29, 2021
2 parents 0b3de3f + afaf1ac commit cd4e4b0
Show file tree
Hide file tree
Showing 241 changed files with 21,280 additions and 2,885 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ jobs:
- checkout
- restore_cache:
keys:
- v5-pip-dependencies-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements.dev.txt" }}
- v5-pip-dependencies-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements.dev.txt" }}-{{ checksum "requirements.bbs.txt" }}
- v5-pip-dependencies-{{ .Branch }}-
- run:
name: Install Python Dependencies
command: |
pip install \
--user \
-r requirements.txt \
-r requirements.dev.txt
-r requirements.dev.txt \
-r requirements.bbs.txt
- save_cache:
paths:
- /home/indy/.local/lib/python3.6/site-packages
key: v5-pip-dependencies-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements.dev.txt" }}
key: v5-pip-dependencies-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements.dev.txt" }}-{{ checksum "requirements.bbs.txt" }}

- run:
name: Run Agent Tests
Expand Down
23 changes: 18 additions & 5 deletions aries_cloudagent/config/wallet.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Wallet configuration."""

import logging
from typing import Tuple

from ..core.error import ProfileNotFoundError
from ..core.profile import Profile, ProfileManager
from ..wallet.base import BaseWallet
from ..wallet.did_info import DIDInfo
from ..wallet.crypto import seed_to_did
from ..wallet.key_type import KeyType
from ..wallet.did_method import DIDMethod

from .base import ConfigError
from .injection_context import InjectionContext
Expand All @@ -18,7 +21,7 @@

async def wallet_config(
context: InjectionContext, provision: bool = False
) -> (Profile, DIDInfo):
) -> Tuple[Profile, DIDInfo]:
"""Initialize the root profile."""

mgr = context.inject(ProfileManager)
Expand Down Expand Up @@ -65,7 +68,9 @@ async def wallet_config(
public_did = public_did_info.did
if wallet_seed and seed_to_did(wallet_seed) != public_did:
if context.settings.get("wallet.replace_public_did"):
replace_did_info = await wallet.create_local_did(wallet_seed)
replace_did_info = await wallet.create_local_did(
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
)
public_did = replace_did_info.did
await wallet.set_public_did(public_did)
print(f"Created new public DID: {public_did}")
Expand All @@ -84,14 +89,19 @@ async def wallet_config(
metadata = {"endpoint": endpoint} if endpoint else None

local_did_info = await wallet.create_local_did(
seed=wallet_seed, metadata=metadata
method=DIDMethod.SOV,
key_type=KeyType.ED25519,
seed=wallet_seed,
metadata=metadata,
)
local_did = local_did_info.did
if provision:
print(f"Created new local DID: {local_did}")
print(f"Verkey: {local_did_info.verkey}")
else:
public_did_info = await wallet.create_public_did(seed=wallet_seed)
public_did_info = await wallet.create_public_did(
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
)
public_did = public_did_info.did
if provision:
print(f"Created new public DID: {public_did}")
Expand All @@ -108,7 +118,10 @@ async def wallet_config(
test_seed = "testseed000000000000000000000001"
if test_seed:
await wallet.create_local_did(
seed=test_seed, metadata={"endpoint": "1.2.3.4:8021"}
method=DIDMethod.SOV,
key_type=KeyType.ED25519,
seed=test_seed,
metadata={"endpoint": "1.2.3.4:8021"},
)

await txn.commit()
Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/connections/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from ..storage.error import StorageNotFoundError
from ..storage.record import StorageRecord
from ..wallet.base import BaseWallet
from ..did.did_key import DIDKey
from ..wallet.did_info import DIDInfo
from ..wallet.util import did_key_to_naked
from .models.conn_record import ConnRecord
from .models.connection_target import ConnectionTarget
from .models.diddoc import DIDDoc, PublicKey, PublicKeyType, Service
Expand Down Expand Up @@ -315,11 +315,11 @@ async def fetch_connection_targets(
else:
endpoint = invitation.service_blocks[0].service_endpoint
recipient_keys = [
did_key_to_naked(k)
DIDKey.from_did(k).public_key_b58
for k in invitation.service_blocks[0].recipient_keys
]
routing_keys = [
did_key_to_naked(k)
DIDKey.from_did(k).public_key_b58
for k in invitation.service_blocks[0].routing_keys
]

Expand Down
6 changes: 6 additions & 0 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ..protocols.connections.v1_0.messages.connection_invitation import (
ConnectionInvitation,
)
from ..vc.ld_proofs.document_loader import DocumentLoader
from ..protocols.coordinate_mediation.v1_0.manager import MediationManager
from ..protocols.out_of_band.v1_0.manager import OutOfBandManager
from ..protocols.out_of_band.v1_0.messages.invitation import HSProto, InvitationMessage
Expand Down Expand Up @@ -128,6 +129,11 @@ async def setup(self):
multitenant_mgr = MultitenantManager(self.root_profile)
context.injector.bind_instance(MultitenantManager, multitenant_mgr)

# Bind default PyLD document loader
context.injector.bind_instance(
DocumentLoader, DocumentLoader(self.root_profile)
)

self.outbound_queue = get_outbound_queue(context.settings)

# Admin API
Expand Down
29 changes: 24 additions & 5 deletions aries_cloudagent/core/tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ...protocols.coordinate_mediation.v1_0.models.mediation_record import (
MediationRecord,
)
from ...resolver.did_resolver import DIDResolver, DIDResolverRegistry
from ...multitenant.manager import MultitenantManager
from ...transport.inbound.message import InboundMessage
from ...transport.inbound.receipt import MessageReceipt
Expand All @@ -30,6 +31,8 @@
from ...transport.pack_format import PackWireFormat
from ...utils.stats import Collector
from ...wallet.base import BaseWallet
from ...wallet.key_type import KeyType
from ...wallet.did_method import DIDMethod

from .. import conductor as test_module

Expand Down Expand Up @@ -80,6 +83,7 @@ async def build_context(self) -> InjectionContext:
context.injector.bind_instance(ProfileManager, InMemoryProfileManager())
context.injector.bind_instance(ProtocolRegistry, ProtocolRegistry())
context.injector.bind_instance(BaseWireFormat, self.wire_format)
context.injector.bind_instance(DIDResolver, DIDResolver(DIDResolverRegistry()))
return context


Expand Down Expand Up @@ -108,7 +112,10 @@ async def test_startup(self):
session = await conductor.root_profile.session()

wallet = session.inject(BaseWallet)
await wallet.create_public_did()
await wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)

mock_inbound_mgr.return_value.setup.assert_awaited_once()
mock_outbound_mgr.return_value.setup.assert_awaited_once()
Expand Down Expand Up @@ -499,7 +506,10 @@ async def test_admin(self):

session = await conductor.root_profile.session()
wallet = session.inject(BaseWallet)
await wallet.create_public_did()
await wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)

with async_mock.patch.object(
admin, "start", autospec=True
Expand Down Expand Up @@ -529,7 +539,10 @@ async def test_admin_startx(self):

session = await conductor.root_profile.session()
wallet = session.inject(BaseWallet)
await wallet.create_public_did()
await wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)

with async_mock.patch.object(
admin, "start", autospec=True
Expand Down Expand Up @@ -577,7 +590,10 @@ async def test_start_static(self):

session = await conductor.root_profile.session()
wallet = session.inject(BaseWallet)
await wallet.create_public_did()
await wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)

mock_mgr.return_value.create_static_connection = async_mock.CoroutineMock()
await conductor.start()
Expand Down Expand Up @@ -695,7 +711,10 @@ async def test_print_invite_connection(self):

session = await conductor.root_profile.session()
wallet = session.inject(BaseWallet)
await wallet.create_public_did()
await wallet.create_public_did(
DIDMethod.SOV,
KeyType.ED25519,
)

await conductor.start()
await conductor.stop()
Expand Down
File renamed without changes.
Loading

0 comments on commit cd4e4b0

Please sign in to comment.