Skip to content

recipient_key cannot be referenced as id's are randomly generated #63

@Jsyro

Description

@Jsyro

What

pydid's DIDCommV1Service.recipient_keys are required to be DIDUrl, referencing a verificationMethod (ideally in the same document) however those id's are randomly generated.

Why

To use the didurl, a consumer of this API must repair the reference by making assumptions about the structure of the document. See my workaround implemented in acapy openwallet-foundation/acapy#2472 (comment)

def _resolve_peer_did_with_service_key_reference(
    peer_did_2: Union[str, DID]
) -> DIDDocument:
    try:
        doc = resolve_peer_did(peer_did_2)
        ## WORKAROUND LIBRARY NOT REREFERENCING RECEIPIENT_KEY
        services = doc.service
        signing_keys = [
            vm
            for vm in doc.verification_method or []
            if vm.type == "Ed25519VerificationKey2020"
        ]
        if services and signing_keys:
            services[0].__dict__["recipient_keys"] = [signing_keys[0].id]
        else:
            raise Exception("no recipient_key signing_key pair")
    except Exception as e:
        raise ValueError("pydantic validation error:" + str(e))
    return doc

Success Criteria

After resolve_peer_did, calling dereference on the service.recipient_key should work with no modification. My example is one possible solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions