Skip to content

Commit

Permalink
Complete unit test for multisig issuer and holder credential creation…
Browse files Browse the repository at this point in the history
…, GRANT and ADMIT resulting in the credential saving in the holder's database after the ADMIT message is processed. (#166)

Re-ordering some of the logic in mutlsig grant and admit request handlers to be consistent.

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Jan 12, 2024
1 parent eb163c5 commit 781ea7a
Show file tree
Hide file tree
Showing 3 changed files with 557 additions and 154 deletions.
25 changes: 16 additions & 9 deletions src/keria/app/ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
raise falcon.HTTPBadRequest(description=f"invalid exn request message {serder.said}")

grant, _ = exchanging.cloneMessage(agent.hby, admitked['p'])
if grant is None:
raise falcon.HTTPBadRequest(description=f"attempt to admit an invalid grant {admitked['p']}")

embeds = grant.ked['e']
acdc = embeds["acdc"]
issr = acdc['i']
Expand Down Expand Up @@ -225,20 +228,13 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
if grant['r'] != "/ipex/grant":
raise falcon.HTTPBadRequest(description=f"invalid route for embedded ipex grant {ked['r']}")

holder = grant['a']['i']
serder = serdering.SerderKERI(sad=grant)
ims = bytearray(serder.raw) + atc.encode("utf-8")
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=holder, topic="credential"))
agent.grants.append(dict(said=grant['d'], pre=hab.pre))

# use that data to create th Serder and Sigers for the exn
serder = serdering.SerderKERI(sad=ked)
sigers = [coring.Siger(qb64=sig) for sig in sigs]

# Now create the stream to send, need the signer seal
kever = hab.kever
seal = eventing.SealEvent(i=hab.pre, s="{:x}".format(kever.lastEst.s), d=kever.lastEst.d)
kever = hab.mhab.kever
seal = eventing.SealEvent(i=hab.mhab.pre, s="{:x}".format(kever.lastEst.s), d=kever.lastEst.d)

ims = eventing.messagize(serder=serder, sigers=sigers, seal=seal)

Expand All @@ -247,3 +243,14 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
# make a copy and parse
agent.hby.psr.parseOne(ims=bytearray(ims))
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=rec, topic='credential'))
holder = grant['a']['i']

exn, pathed = exchanging.cloneMessage(agent.hby, serder.said)
if not exn:
raise falcon.HTTPBadRequest(description=f"invalid exn request message {serder.said}")

serder = serdering.SerderKERI(sad=grant)
ims = bytearray(serder.raw) + pathed['exn']
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=holder, topic="credential"))
agent.grants.append(dict(said=grant['d'], pre=hab.pre, rec=holder))
2 changes: 1 addition & 1 deletion src/keria/peer/exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def on_post(req, rep, name):

for recp in rec: # Have to verify we already know all the recipients.
if recp not in agent.hby.kevers:
raise falcon.HTTPBadRequest(f"attempt to send to unknown AID={recp}")
raise falcon.HTTPBadRequest(description=f"attempt to send to unknown AID={recp}")

# use that data to create th Serder and Sigers for the exn
serder = serdering.SerderKERI(sad=ked)
Expand Down
Loading

0 comments on commit 781ea7a

Please sign in to comment.