Skip to content

Commit

Permalink
Handle failed tails server issuance [Anoncreds] (#3049)
Browse files Browse the repository at this point in the history
* Fix anoncreds legacy indy revocation rotate without tails server / Refactor

Signed-off-by: jamshale <[email protected]>

* Refactor / More descriptive variable name

Signed-off-by: jamshale <[email protected]>

* Update some class docs / Remove un-needed TODO's

Signed-off-by: jamshale <[email protected]>

* Reformat with black

Signed-off-by: jamshale <[email protected]>

* Remove failed state

Signed-off-by: jamshale <[email protected]>

---------

Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale authored Jun 21, 2024
1 parent 9e92e23 commit a4ad003
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 253 deletions.
11 changes: 2 additions & 9 deletions aries_cloudagent/anoncreds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from ..config.injection_context import InjectionContext
from ..core.error import BaseError
from ..core.profile import Profile
from .models.anoncreds_cred_def import (
CredDef,
CredDefResult,
GetCredDefResult,
)
from .models.anoncreds_cred_def import CredDef, CredDefResult, GetCredDefResult
from .models.anoncreds_revocation import (
GetRevListResult,
GetRevRegDefResult,
Expand Down Expand Up @@ -59,10 +55,7 @@ def __init__(
Args:
message: Message
obj_id: Object ID
obj: Object
TODO: update this docstring - Anoncreds-break.
obj: Generic Object
"""
super().__init__(message, obj_id, obj, *args, **kwargs)
self._message = message
Expand Down
8 changes: 2 additions & 6 deletions aries_cloudagent/anoncreds/default/did_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
from ....config.injection_context import InjectionContext
from ....core.profile import Profile
from ...base import BaseAnonCredsRegistrar, BaseAnonCredsResolver
from ...models.anoncreds_cred_def import (
CredDef,
CredDefResult,
GetCredDefResult,
)
from ...models.anoncreds_cred_def import CredDef, CredDefResult, GetCredDefResult
from ...models.anoncreds_revocation import (
GetRevListResult,
GetRevRegDefResult,
Expand All @@ -32,7 +28,7 @@ def __init__(self):
"""Initialize an instance.
Args:
TODO: update this docstring - Anoncreds-break.
None
"""
self._supported_identifiers_regex = re.compile(r"^did:indy:.*$")
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/anoncreds/default/did_web/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self):
"""Initialize an instance.
Args:
TODO: update this docstring - Anoncreds-break.
None
"""
self._supported_identifiers_regex = re.compile(
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(self):
"""Initialize an instance.
Args:
TODO: update this docstring - Anoncreds-break.
None
"""
B58 = alphabet if isinstance(alphabet, str) else alphabet.decode("ascii")
Expand Down Expand Up @@ -621,7 +621,9 @@ async def register_revocation_registry_definition(
endorser_did=endorser_did,
)
except LedgerError as err:
raise AnonCredsRegistrationError(err.roll_up) from err
LOGGER.error(
f"Error registering revocation registry definition {rev_reg_def_id}: {err.roll_up}" # noqa: E501
)

# Didn't need endorsement
if write_ledger:
Expand Down Expand Up @@ -1108,7 +1110,6 @@ def _wallet_accumalator_matches_ledger_list(
)

async with profile.session() as session:

LOGGER.debug(f"revocation_list = {rev_list.revocation_list}")
LOGGER.debug(f"rev_reg_delta = {rev_reg_delta.get('value')}")

Expand All @@ -1117,7 +1118,6 @@ def _wallet_accumalator_matches_ledger_list(
)

if not _wallet_accumalator_matches_ledger_list(rev_list, rev_reg_delta):

recovery_txn = await generate_ledger_rrrecovery_txn(
genesis_transactions, rev_list
)
Expand Down
9 changes: 0 additions & 9 deletions aries_cloudagent/anoncreds/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def __init__(
Args:
payload: CredDefFinishedPayload
TODO: update this docstring - Anoncreds-break.
"""
self._topic = CRED_DEF_FINISHED_EVENT
self._payload = payload
Expand Down Expand Up @@ -82,9 +79,6 @@ def __init__(self, payload: RevRegDefFinishedPayload):
Args:
payload: RevRegDefFinishedPayload
TODO: update this docstring - Anoncreds-break.
"""
self._topic = REV_REG_DEF_FINISHED_EVENT
self._payload = payload
Expand Down Expand Up @@ -122,9 +116,6 @@ def __init__(self, payload: RevListFinishedPayload):
Args:
payload: RevListFinishedPayload
TODO: update this docstring - Anoncreds-break.
"""
self._topic = REV_LIST_FINISHED_EVENT
self._payload = payload
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ async def create_and_register_credential_definition(
if not isinstance(support_revocation, bool):
raise ValueError("support_revocation must be a boolean")

max_cred_num = options.get("max_cred_num", DEFAULT_MAX_CRED_NUM)
max_cred_num = options.get("revocation_registry_size", DEFAULT_MAX_CRED_NUM)
if not isinstance(max_cred_num, int):
raise ValueError("max_cred_num must be an integer")

Expand Down
60 changes: 23 additions & 37 deletions aries_cloudagent/anoncreds/models/anoncreds_cred_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs):
"""Initialize an instance.
Args:
n: n
s: s
r: r
rctxt: rctxt
z: z
TODO: update this docstring - Anoncreds-break.
n: is a safe RSA-2048 number.
s: is a randomly selected quadratic residue of n.
r: is an object that defines a CL-RSA public key fragment
for each attribute in the credential.
rctxt: is equal to s^(xrctxt), where xrctxt is a randomly selected integer
between 2 and p'q'-1.
z: is equal to s^(xz), where xz is a randomly selected integer between 2
and p'q'-1. This makes up part of the CL-RSA public key, independent of
the message blocks being signed.
"""
super().__init__(**kwargs)
self.n = n
Expand Down Expand Up @@ -92,20 +93,20 @@ def __init__(
"""Initialize an instance.
Args:
g: g
g_dash: g_dash
h: h
h0: h0
h1: h1
h2: h2
htilde: htilde
h_cap: h_cap
u: u
pk: pk
y: y
TODO: update this docstring - Anoncreds-break.
g: is a generator for the elliptic curve group G1.
g_dash: is a generator for the elliptic curve group G2.
h: is an elliptic curve point selected uniformly at random from G1.
h0: is an elliptic curve point selected uniformly at random from G1.
h1: is an elliptic curve point selected uniformly at random from G1.
h2: is an elliptic curve point selected uniformly at random from G1.
htilde: is an elliptic curve point selected uniformly at random from G1.
h_cap: is an elliptic curve point selected uniformly at random from G2.
u: is an elliptic curve point selected uniformly at random from G2.
pk: is the public key in G1 for the issuer with respect to this accumulator,
computed as g^sk (in multiplicative notation), where sk is from
r_key above.
y: is the an elliptic curve point in G2. computed as h_cap^x
(in multiplicative notation), where x is from r_key above
"""
self.g = g
self.g_dash = g_dash
Expand Down Expand Up @@ -171,9 +172,6 @@ def __init__(
Args:
primary: Cred Def value primary
revocation: Cred Def value revocation
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.primary = primary
Expand Down Expand Up @@ -225,9 +223,6 @@ def __init__(
type: Type
tag: Tag
value: Cred Def value
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -307,9 +302,6 @@ def __init__(
state: State
credential_definition_id: Cred Def ID
credential_definition: Cred Def
TODO: update this docstring - Anoncreds-break.
"""
self.state = state
self.credential_definition_id = credential_definition_id
Expand Down Expand Up @@ -370,9 +362,6 @@ def __init__(
credential_definition_state: Cred Def state
registration_metadata: Registration metadata
credential_definition_metadata: Cred Def metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -420,9 +409,6 @@ def __init__(
credential_definition: Cred Def
resolution_metadata: Resolution metadata
credential_definition_metadata: Cred Def metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.credential_definition_id = credential_definition_id
Expand Down
27 changes: 0 additions & 27 deletions aries_cloudagent/anoncreds/models/anoncreds_revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ def __init__(
max_cred_num: Max. number of Creds
tails_location: Tails file location
tails_hash: Tails file hash
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.public_keys = public_keys
Expand Down Expand Up @@ -102,9 +99,6 @@ def __init__(
cred_def_id: Cred Def ID
tag: Tag
value: Rev Reg Def Value
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -183,9 +177,6 @@ def __init__(
state: State
revocation_registry_definition_id: Rev Reg Definition ID
revocation_registry_definition: Rev Reg Definition
TODO: update this docstring - Anoncreds-break.
"""
self.state = state
self.revocation_registry_definition_id = revocation_registry_definition_id
Expand Down Expand Up @@ -247,9 +238,6 @@ def __init__(
revocation_registry_definition_state: Rev Reg Def state
registration_metadata: Registration metadata
revocation_registry_definition_metadata: Rev Reg Def metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -311,9 +299,6 @@ def __init__(
revocation_registry_id: Revocation Registry ID
resolution_metadata: Resolution metadata
revocation_registry_metadata: Revocation Registry metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.revocation_registry = revocation_registry
Expand Down Expand Up @@ -362,9 +347,6 @@ def __init__(
revocation_list: Revocation list
current_accumulator: Current accumulator
timestamp: Timestamp
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -453,9 +435,6 @@ def __init__(
Args:
state: State
revocation_list: Revocation list
TODO: update this docstring - Anoncreds-break.
"""
self.state = state
self.revocation_list = revocation_list
Expand Down Expand Up @@ -508,9 +487,6 @@ def __init__(
revocation_list_state: Revocation list state
registration_metadata: Registration metadata
revocation_list_metadata: Revocation list metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -561,9 +537,6 @@ def __init__(
revocation_list: Revocation list
resolution_metadata: Resolution metadata
revocation_registry_metadata: Rev Reg metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.revocation_list = revocation_list
Expand Down
14 changes: 1 addition & 13 deletions aries_cloudagent/anoncreds/models/anoncreds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
from marshmallow.validate import OneOf

from ...messaging.models.base import BaseModel, BaseModelSchema
from ...messaging.valid import (
INDY_OR_KEY_DID_EXAMPLE,
INDY_SCHEMA_ID_EXAMPLE,
)
from ...messaging.valid import INDY_OR_KEY_DID_EXAMPLE, INDY_SCHEMA_ID_EXAMPLE


class AnonCredsSchema(BaseModel):
Expand All @@ -31,9 +28,6 @@ def __init__(
attr_names: Schema Attribute Name list
name: Schema name
version: Schema version
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -106,9 +100,6 @@ def __init__(
schema_id: Schema ID
resolution_metadata: Resolution Metdata
schema_metadata: Schema Metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.schema_value = schema
Expand Down Expand Up @@ -221,9 +212,6 @@ def __init__(
schema_state: Schema state
registration_metadata: Registration Metdata
schema_metadata: Schema Metadata
TODO: update this docstring - Anoncreds-break.
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down
Loading

0 comments on commit a4ad003

Please sign in to comment.