Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jsyro opened this issue Sep 7, 2023 · 0 comments
Open

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

Jsyro opened this issue Sep 7, 2023 · 0 comments

Comments

@Jsyro
Copy link
Contributor

Jsyro commented Sep 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant