From 31bd23fe5f5478befd79405d2de7025ccfad1daa Mon Sep 17 00:00:00 2001 From: sklump Date: Mon, 13 Jul 2020 13:51:43 +0000 Subject: [PATCH 1/2] remove the possibility of revocation registry issuance on demand: by default is much less chatty Signed-off-by: sklump --- aries_cloudagent/issuer/base.py | 3 --- aries_cloudagent/issuer/indy.py | 7 ++----- aries_cloudagent/revocation/indy.py | 6 ------ .../revocation/models/issuer_rev_reg_record.py | 18 ------------------ .../revocation/models/revocation_registry.py | 4 ++-- aries_cloudagent/revocation/routes.py | 7 ------- aries_cloudagent/revocation/tests/test_indy.py | 1 - demo/runners/support/agent.py | 6 ++++-- 8 files changed, 8 insertions(+), 44 deletions(-) diff --git a/aries_cloudagent/issuer/base.py b/aries_cloudagent/issuer/base.py index 8ea5d98792..e780abad9e 100644 --- a/aries_cloudagent/issuer/base.py +++ b/aries_cloudagent/issuer/base.py @@ -7,7 +7,6 @@ DEFAULT_CRED_DEF_TAG = "default" -DEFAULT_ISSUANCE_TYPE = "ISSUANCE_BY_DEFAULT" DEFAULT_SIGNATURE_TYPE = "CL" @@ -166,7 +165,6 @@ async def create_and_store_revocation_registry( tag: str, max_cred_num: int, tails_base_path: str, - issuance_type: str = None, ) -> Tuple[str, str, str]: """ Create a new revocation registry and store it in the wallet. @@ -178,7 +176,6 @@ async def create_and_store_revocation_registry( tag: the unique revocation registry tag max_cred_num: the number of credentials supported in the registry tails_base_path: where to store the tails file - issuance_type: optionally override the issuance type Returns: A tuple of the revocation registry ID, JSON, and entry JSON diff --git a/aries_cloudagent/issuer/indy.py b/aries_cloudagent/issuer/indy.py index 3e55297e77..a684bb76e7 100644 --- a/aries_cloudagent/issuer/indy.py +++ b/aries_cloudagent/issuer/indy.py @@ -15,7 +15,6 @@ IssuerError, IssuerRevocationRegistryFullError, DEFAULT_CRED_DEF_TAG, - DEFAULT_ISSUANCE_TYPE, DEFAULT_SIGNATURE_TYPE, ) from ..indy import create_tails_reader, create_tails_writer @@ -211,7 +210,7 @@ async def create_credential( ( credential_json, credential_revocation_id, - _, # rev_reg_delta_json only figures if rev reg is ISSUANCE_ON_DEMAND + _, # rev_reg_delta_json only for ISSUANCE_ON_DEMAND, excluded by design ) = await indy.anoncreds.issuer_create_credential( self.wallet.handle, json.dumps(credential_offer), @@ -314,7 +313,6 @@ async def create_and_store_revocation_registry( tag: str, max_cred_num: int, tails_base_path: str, - issuance_type: str = None, ) -> Tuple[str, str, str]: """ Create a new revocation registry and store it in the wallet. @@ -326,7 +324,6 @@ async def create_and_store_revocation_registry( tag: the unique revocation registry tag max_cred_num: the number of credentials supported in the registry tails_base_path: where to store the tails file - issuance_type: optionally override the issuance type Returns: A tuple of the revocation registry ID, JSON, and entry JSON @@ -350,8 +347,8 @@ async def create_and_store_revocation_registry( cred_def_id, json.dumps( { + "issuance_type": "ISSUANCE_BY_DEFAULT", "max_cred_num": max_cred_num, - "issuance_type": issuance_type or DEFAULT_ISSUANCE_TYPE, } ), tails_writer, diff --git a/aries_cloudagent/revocation/indy.py b/aries_cloudagent/revocation/indy.py index a733e0b997..70c4049e71 100644 --- a/aries_cloudagent/revocation/indy.py +++ b/aries_cloudagent/revocation/indy.py @@ -24,7 +24,6 @@ async def init_issuer_registry( self, cred_def_id: str, issuer_did: str, - issuance_by_default: bool = True, max_cred_num: int = None, revoc_def_type: str = None, tag: str = None, @@ -42,11 +41,6 @@ async def init_issuer_registry( record = IssuerRevRegRecord( cred_def_id=cred_def_id, issuer_did=issuer_did, - issuance_type=( - IssuerRevRegRecord.ISSUANCE_BY_DEFAULT - if issuance_by_default - else IssuerRevRegRecord.ISSUANCE_ON_DEMAND - ), max_cred_num=max_cred_num, revoc_def_type=revoc_def_type, tag=tag, diff --git a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py index 4fc5ad9d12..5fd30de753 100644 --- a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py @@ -47,16 +47,12 @@ class Meta: CACHE_ENABLED = False TAG_NAMES = { "cred_def_id", - "issuance_type", "issuer_did", "revoc_def_type", "revoc_reg_id", "state", } - ISSUANCE_BY_DEFAULT = "ISSUANCE_BY_DEFAULT" - ISSUANCE_ON_DEMAND = "ISSUANCE_ON_DEMAND" - REVOC_DEF_TYPE_CL = "CL_ACCUM" STATE_INIT = "init" @@ -72,7 +68,6 @@ def __init__( state: str = None, cred_def_id: str = None, error_msg: str = None, - issuance_type: str = None, issuer_did: str = None, max_cred_num: int = None, revoc_def_type: str = None, @@ -92,7 +87,6 @@ def __init__( ) self.cred_def_id = cred_def_id self.error_msg = error_msg - self.issuance_type = issuance_type or self.ISSUANCE_BY_DEFAULT self.issuer_did = issuer_did self.max_cred_num = max_cred_num or DEFAULT_REGISTRY_SIZE self.revoc_def_type = revoc_def_type or self.REVOC_DEF_TYPE_CL @@ -164,7 +158,6 @@ async def generate_registry(self, context: InjectionContext): self.tag, self.max_cred_num, tails_hopper_dir, - self.issuance_type, ) except IssuerError as err: raise RevocationError() from err @@ -383,17 +376,6 @@ class Meta: description="Error message", example="Revocation registry undefined", ) - issuance_type = fields.Str( - required=False, - description="Issuance type (ISSUANCE_BY_DEFAULT or ISSUANCE_ON_DEMAND)", - example=IssuerRevRegRecord.ISSUANCE_BY_DEFAULT, - validate=validate.OneOf( - [ - IssuerRevRegRecord.ISSUANCE_BY_DEFAULT, - IssuerRevRegRecord.ISSUANCE_ON_DEMAND, - ] - ), - ) issuer_did = fields.Str(required=False, description="Issuer DID", **INDY_DID) max_cred_num = fields.Int( required=False, diff --git a/aries_cloudagent/revocation/models/revocation_registry.py b/aries_cloudagent/revocation/models/revocation_registry.py index 6341df299c..47d1dc37c9 100644 --- a/aries_cloudagent/revocation/models/revocation_registry.py +++ b/aries_cloudagent/revocation/models/revocation_registry.py @@ -69,11 +69,11 @@ def from_definition( } if public_def: init["tails_public_uri"] = tails_location - rev_reg = cls(reg_id, **init) # currently ignored: def version, public keys + rev_reg = cls(reg_id, **init) # ignores def ver, issuance type, public keys rev_reg.tails_local_path = rev_reg.get_receiving_tails_local_path() else: init["tails_local_path"] = tails_location - rev_reg = cls(reg_id, **init) # currently ignored: def version, public keys + rev_reg = cls(reg_id, **init) # ignores def ver, issuance type, public keys return rev_reg diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index 8cdafd2413..e3ebdc0a4b 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -33,11 +33,6 @@ class RevRegCreateRequestSchema(Schema): credential_definition_id = fields.Str( description="Credential definition identifier", **INDY_CRED_DEF_ID ) - issuance_by_default = fields.Boolean( - description="Create registry with all indexes issued", - required=False, - default=True, - ) max_cred_num = fields.Int( description="Maximum credential numbers", example=100, required=False ) @@ -129,7 +124,6 @@ async def revocation_create_registry(request: web.BaseRequest): credential_definition_id = body.get("credential_definition_id") max_cred_num = body.get("max_cred_num") - issuance_by_default = body.get("issuance_by_default", True) # check we published this cred def storage = await context.inject(BaseStorage) @@ -149,7 +143,6 @@ async def revocation_create_registry(request: web.BaseRequest): registry_record = await revoc.init_issuer_registry( credential_definition_id, issuer_did, - issuance_by_default=issuance_by_default, max_cred_num=max_cred_num, ) except RevocationNotSupportedError as e: diff --git a/aries_cloudagent/revocation/tests/test_indy.py b/aries_cloudagent/revocation/tests/test_indy.py index 82fb77688c..a42c6f8ffe 100644 --- a/aries_cloudagent/revocation/tests/test_indy.py +++ b/aries_cloudagent/revocation/tests/test_indy.py @@ -49,7 +49,6 @@ async def test_init_issuer_registry(self): assert result.cred_def_id == CRED_DEF_ID assert result.issuer_did == self.test_did - assert result.issuance_type == IssuerRevRegRecord.ISSUANCE_BY_DEFAULT assert result.max_cred_num == DEFAULT_REGISTRY_SIZE assert result.revoc_def_type == IssuerRevRegRecord.REVOC_DEF_TYPE_CL assert result.tag is None diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index cdc5087455..76f400ed50 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -224,8 +224,10 @@ async def create_and_publish_revocation_registry( log_msg(f"Revocation Registry ID: {revocation_registry_id}") assert tails_hash == my_tails_hash - tails_file_url = f"{self.public_tails_url}/revocation/registry/{revocation_registry_id}/tails-file" - + tails_file_url = ( + f"{self.public_tails_url}/revocation/registry/" + f"{revocation_registry_id}/tails-file" + ) if os.getenv("PUBLIC_TAILS_URL"): tails_file_url = f"{self.public_tails_url}/{revocation_registry_id}" tails_file_external_url = ( From 315ecf56e10eff14b4b69d8b96880702a17940f8 Mon Sep 17 00:00:00 2001 From: sklump Date: Mon, 13 Jul 2020 15:37:08 +0000 Subject: [PATCH 2/2] black tweak Signed-off-by: sklump --- aries_cloudagent/revocation/routes.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index e3ebdc0a4b..6aeac9ca8f 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -141,9 +141,7 @@ async def revocation_create_registry(request: web.BaseRequest): issuer_did = credential_definition_id.split(":")[0] revoc = IndyRevocation(context) registry_record = await revoc.init_issuer_registry( - credential_definition_id, - issuer_did, - max_cred_num=max_cred_num, + credential_definition_id, issuer_did, max_cred_num=max_cred_num, ) except RevocationNotSupportedError as e: raise web.HTTPBadRequest(reason=e.message) from e