Skip to content

Commit

Permalink
Support for anoncreds and askar wallets concurrently
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Mar 15, 2024
1 parent 3eb0bf7 commit 3ec52e3
Show file tree
Hide file tree
Showing 34 changed files with 1,563 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
class TestLegacyIndyRegistry(IsolatedAsyncioTestCase):
async def asyncSetUp(self):
self.profile = InMemoryProfile.test_profile(
settings={"wallet-type": "askar-anoncreds"},
settings={"wallet.type": "askar-anoncreds"},
profile_class=AskarAnoncredsProfile,
)
self.registry = test_module.LegacyIndyRegistry()
Expand Down
3 changes: 3 additions & 0 deletions aries_cloudagent/anoncreds/error_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Error messages for anoncreds."""

ANONCREDS_PROFILE_REQUIRED_MSG = "AnonCreds interface requires AskarAnoncreds profile"
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ..core.profile import Profile
from ..ledger.base import BaseLedger
from ..wallet.error import WalletNotFoundError
from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG
from .models.anoncreds_cred_def import CredDef

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -72,7 +73,7 @@ def __init__(self, profile: Profile):
def profile(self) -> AskarAnoncredsProfile:
"""Accessor for the profile instance."""
if not isinstance(self._profile, AskarAnoncredsProfile):
raise ValueError("AnonCreds interface requires AskarAnoncreds")
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

return self._profile

Expand Down
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
AnonCredsSchemaAlreadyExists,
BaseAnonCredsError,
)
from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG
from .events import CredDefFinishedEvent
from .models.anoncreds_cred_def import CredDef, CredDefResult
from .models.anoncreds_schema import AnonCredsSchema, SchemaResult, SchemaState
Expand Down Expand Up @@ -97,7 +98,7 @@ def __init__(self, profile: Profile):
def profile(self) -> AskarAnoncredsProfile:
"""Accessor for the profile instance."""
if not isinstance(self._profile, AskarAnoncredsProfile):
raise ValueError("AnonCreds interface requires AskarAnoncreds")
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

return self._profile

Expand Down
18 changes: 9 additions & 9 deletions aries_cloudagent/anoncreds/models/anoncreds_cred_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CredDefValuePrimary(BaseModel):
class Meta:
"""PrimarySchema metadata."""

schema_class = "CredDefValuePrimarySchema"
schema_class = "CredDefValuePrimarySchemaAnoncreds"

def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs):
"""Initialize an instance.
Expand All @@ -51,7 +51,7 @@ def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs):
self.z = z


class CredDefValuePrimarySchema(BaseModelSchema):
class CredDefValuePrimarySchemaAnoncreds(BaseModelSchema):
"""Cred def value primary schema."""

class Meta:
Expand All @@ -73,7 +73,7 @@ class CredDefValueRevocation(BaseModel):
class Meta:
"""CredDefValueRevocation metadata."""

schema_class = "CredDefValueRevocationSchema"
schema_class = "CredDefValueRevocationSchemaAnoncreds"

def __init__(
self,
Expand Down Expand Up @@ -120,7 +120,7 @@ def __init__(
self.y = y


class CredDefValueRevocationSchema(BaseModelSchema):
class CredDefValueRevocationSchemaAnoncreds(BaseModelSchema):
"""Cred def value revocation schema."""

class Meta:
Expand Down Expand Up @@ -158,7 +158,7 @@ class CredDefValue(BaseModel):
class Meta:
"""CredDefValue metadata."""

schema_class = "CredDefValueSchema"
schema_class = "CredDefValueSchemaAnoncreds"

def __init__(
self,
Expand All @@ -180,7 +180,7 @@ def __init__(
self.revocation = revocation


class CredDefValueSchema(BaseModelSchema):
class CredDefValueSchemaAnoncreds(BaseModelSchema):
"""Cred def value schema."""

class Meta:
Expand All @@ -190,11 +190,11 @@ class Meta:
unknown = EXCLUDE

primary = fields.Nested(
CredDefValuePrimarySchema(),
CredDefValuePrimarySchemaAnoncreds(),
metadata={"description": "Primary value for credential definition"},
)
revocation = fields.Nested(
CredDefValueRevocationSchema(),
CredDefValueRevocationSchemaAnoncreds(),
metadata={"description": "Revocation value for credential definition"},
required=False,
)
Expand Down Expand Up @@ -277,7 +277,7 @@ class Meta:
"example": "default",
}
)
value = fields.Nested(CredDefValueSchema())
value = fields.Nested(CredDefValueSchemaAnoncreds())


class CredDefState(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ..core.event_bus import Event, EventBus
from ..core.profile import Profile, ProfileSession
from ..tails.base import BaseTailsServer
from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG
from .events import RevListFinishedEvent, RevRegDefFinishedEvent
from .issuer import (
CATEGORY_CRED_DEF,
Expand Down Expand Up @@ -95,7 +96,7 @@ def __init__(self, profile: Profile):
def profile(self) -> AskarAnoncredsProfile:
"""Accessor for the profile instance."""
if not isinstance(self._profile, AskarAnoncredsProfile):
raise ValueError("AnonCreds interface requires AskarAnoncreds")
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

return self._profile

Expand Down
Loading

0 comments on commit 3ec52e3

Please sign in to comment.