Skip to content

Commit

Permalink
Anoncreds create credential
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Dec 2, 2024
1 parent dd17d01 commit aed9986
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
23 changes: 4 additions & 19 deletions acapy_agent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
import json
import logging
import re
from typing import Dict, Optional, Sequence, Tuple, Union

from anoncreds import (
Expand Down Expand Up @@ -150,8 +149,8 @@ async def create_credential_request(
) = await asyncio.get_event_loop().run_in_executor(
None,
CredentialRequest.create,
None,
holder_did,
None,
credential_definition.to_native(),
secret,
AnonCredsHolder.MASTER_SECRET_ID,
Expand Down Expand Up @@ -231,25 +230,11 @@ async def _finish_store_credential(
rev_reg_def: Optional[dict] = None,
) -> str:
credential_data = cred_recvd.to_dict()
schema_id = cred_recvd.schema_id
schema_id_parts = re.match(r"^(\w+):2:([^:]+):([^:]+)$", schema_id)
if not schema_id_parts:
raise AnonCredsHolderError(f"Error parsing credential schema ID: {schema_id}")
cred_def_id = cred_recvd.cred_def_id
cdef_id_parts = re.match(r"^(\w+):3:CL:([^:]+):([^:]+)$", cred_def_id)
if not cdef_id_parts:
raise AnonCredsHolderError(
f"Error parsing credential definition ID: {cred_def_id}"
)

credential_id = credential_id or str(uuid4())
tags = {
"schema_id": schema_id,
"schema_issuer_did": schema_id_parts[1],
"schema_name": schema_id_parts[2],
"schema_version": schema_id_parts[3],
"issuer_did": cdef_id_parts[1],
"cred_def_id": cred_def_id,
"schema_id": cred_recvd.schema_id,
"issuer_did": credential_definition["issuerId"],
"cred_def_id": cred_recvd.cred_def_id,
"rev_reg_id": cred_recvd.rev_reg_id or "None",
}

Expand Down
6 changes: 3 additions & 3 deletions acapy_agent/anoncreds/models/credential_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Meta:

def __init__(
self,
prover_did: Optional[str] = None,
entropy: Optional[str] = None,
cred_def_id: Optional[str] = None,
blinded_ms: Optional[Mapping] = None,
blinded_ms_correctness_proof: Optional[Mapping] = None,
Expand All @@ -33,7 +33,7 @@ def __init__(
):
"""Initialize anoncreds credential request."""
super().__init__(**kwargs)
self.prover_did = prover_did
self.entropy = entropy
self.cred_def_id = cred_def_id
self.blinded_ms = blinded_ms
self.blinded_ms_correctness_proof = blinded_ms_correctness_proof
Expand All @@ -49,7 +49,7 @@ class Meta:
model_class = AnoncredsCredRequest
unknown = EXCLUDE

prover_did = fields.Str(
entropy = fields.Str(
required=True,
metadata={
"description": "Prover DID/Random String/UUID",
Expand Down

0 comments on commit aed9986

Please sign in to comment.