Skip to content

Credential and Task Protocols

DIDAgent adds protocols to a node:

from keri_system.didcomm import DIDAgent

agent = DIDAgent(node, [{"type": "http", "uri": "https://me.example/didcomm"}], mediator=None).start()

Issue a credential

thread = agent.offer(holder_aid, schema, {"role": "member"})
agent.thread(thread)["state"]

The holder requests the offered credential, verifies it, stores it and acknowledges. States are offered, issuing, issued and done. accept_issuers limits whose offers are accepted.

Request a proof

def done(verdict, reasons, facts): ...
thread = agent.request_proof(holder_aid, schema, route="/present", callback=done)

The holder answers with the credential and a signature over the verifier, the challenge and the credential, so a presentation cannot be reused.

Run tasks

@agent.executor("/echo")
def echo(m):
    return {"echo": m["payload"]}

thread = agent.task(peer_aid, "/echo", {"x": 1}, credential=bundle)
Verdict Effect
accept The executor runs and the result is returned
escalate The request waits for a person. The sender is told that it is pending
reject The sender receives the reasons

Verdicts combine credentials, policy, an optional reputation function and the escalate routes. With reputation, a score below 0.2 rejects and one below 0.5 escalates.

An executor can return {"credential": {"schema", "attributes"}, "result": {...}} to issue a credential with the result.

Review escalated requests

for item in agent.escalated():
    agent.review(item["id"], accept=True)

Own protocols

@agent.protocol("https://example.org/offer/1.0/propose")
def propose(message, sender):
    ...

Return a message created with keri_system.didcomm.message to reply.