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

added approval endpoint for delegator after they anchor seal in their KEL #247

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ def on_post(self, req, rep, name):
op = self.rotate(agent, name, body)
elif body.get("ixn") is not None:
op = self.interact(agent, name, body)
elif body.get("approveDelegation") is not None:
op = self.approveDelegation(agent, name, body)
else:
raise falcon.HTTPBadRequest(title="invalid request",
description=f"required field 'rot' or 'ixn' missing from request")
Expand Down Expand Up @@ -655,7 +657,39 @@ def interact(agent, name, body):
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.done,
metadata=dict(response=serder.ked))
return op

@staticmethod
def approveDelegation(agent, name, body):
hab = agent.hby.habByName(name)
if hab is None:
raise falcon.HTTPNotFound(title=f"No AID {name} found")

ixn = body.get("approveDelegation")
if ixn is None:
raise falcon.HTTPBadRequest(title="invalid interaction",
description=f"required field 'approveDelegation' missing from request")

sigs = body.get("sigs")
if sigs is None or len(sigs) == 0:
raise falcon.HTTPBadRequest(title="invalid interaction",
description=f"required field 'sigs' missing from approveDelegation request")

serder = serdering.SerderKERI(sad=ixn)
sigers = [core.Siger(qb64=sig) for sig in sigs]

kever = hab.kevers[hab.pre]

gatePre = ixn['a'][0]['i']
gateSaid = ixn['a'][0]['d']

seqner = coring.Seqner(sn=serder.sn)
couple = seqner.qb64b + serder.saidb
dgkey = dbing.dgKey(coring.Saider(qb64=gatePre).qb64b, coring.Saider(qb64=gateSaid).qb64b)
hab.db.setAes(dgkey, couple) # authorizer event seal (delegator/issuer)

op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.done,
metadata=dict(response=serder.ked))
return op

def info(hab, rm, full=False):
data = dict(
Expand Down
4 changes: 1 addition & 3 deletions src/keria/app/delegating.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def processEscrows(self):

def processUnanchoredEscrow(self):
"""
Process escrow of partially signed multisig group KEL events. Message
processing will send this local controllers signature to all other participants
then this escrow waits for signatures from all other participants
Process escrow of unanchored events that have been delegated and are waiting for delegator anchor or approval.

"""
for (pre, said), serder in self.hby.db.dune.getItemIter(): # group partial witness escrow
Expand Down
Loading