Skip to content

Commit

Permalink
Update to match latest CESR 1.1 changes in KERIpy. (#139)
Browse files Browse the repository at this point in the history
Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Dec 1, 2023
1 parent 97c63d0 commit 9dda515
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 113 deletions.
6 changes: 3 additions & 3 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
forwarding, querying, connecting, grouping
from keri.app.grouping import Counselor
from keri.app.keeping import Algos
from keri.core import coring, parsing, eventing, routing
from keri.core import coring, parsing, eventing, routing, serdering
from keri.core.coring import Ilks, randomNonce
from keri.db import dbing
from keri.db.basing import OobiRecord
Expand Down Expand Up @@ -803,7 +803,7 @@ def on_post(self, req, rep):
if "icp" not in body:
raise falcon.HTTPBadRequest(title="invalid inception",
description=f'required field "icp" missing from body')
icp = eventing.Serder(ked=body["icp"])
icp = serdering.SerderKERI(sad=body["icp"])

if "sig" not in body:
raise falcon.HTTPBadRequest(title="invalid inception",
Expand Down Expand Up @@ -962,7 +962,7 @@ def on_get(req, rep):
if not (raw := agent.hby.db.getEvt(key=dgkey)):
raise falcon.HTTPInternalServerError(f"Missing event for dig={dig}.")

serder = coring.Serder(raw=bytes(raw))
serder = serdering.SerderKERI(raw=bytes(raw))
events.append(serder.ked)

rep.status = falcon.HTTP_200
Expand Down
20 changes: 10 additions & 10 deletions src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from keri import kering
from keri.app import habbing
from keri.app.keeping import Algos
from keri.core import coring, eventing
from keri.core import coring, serdering
from keri.core.coring import Ilks
from keri.db import dbing
from keri.help import ogler
Expand Down Expand Up @@ -100,7 +100,7 @@ def on_get(self, _, rep, caid):
state = asdict(agent.hby.kevers[agent.caid].state())
key = dbing.dgKey(state['i'], state['ee']['d']) # digest key
msg = agent.hby.db.getEvt(key)
eserder = coring.Serder(raw=bytes(msg))
eserder = serdering.SerderKERI(raw=bytes(msg))

body = dict(
agent=asdict(agent.hby.kevers[agent.pre].state()),
Expand Down Expand Up @@ -151,7 +151,7 @@ def on_put(self, req, rep, caid):
if "keys" not in body:
raise falcon.HTTPBadRequest(description="required field 'keys' missing from body")

rot = coring.Serder(ked=body["rot"])
rot = serdering.SerderKERI(sad=body["rot"])
sigs = body["sigs"]

ctrlHab = agent.hby.habByName(caid, ns="agent")
Expand Down Expand Up @@ -209,7 +209,7 @@ def interact(req, rep, agent, caid):

ked = body['ixn']
sigs = body['sigs']
ixn = coring.Serder(ked=ked)
ixn = serdering.SerderKERI(sad=ked)
sigers = [coring.Siger(qb64=sig) for sig in sigs]

ctrlHab = agent.hby.habByName(caid, ns="agent")
Expand Down Expand Up @@ -308,7 +308,7 @@ def on_post(req, rep):
name = httping.getRequiredParam(body, "name")
sigs = httping.getRequiredParam(body, "sigs")

serder = coring.Serder(ked=icp)
serder = serdering.SerderKERI(sad=icp)

sigers = [coring.Siger(qb64=sig) for sig in sigs]

Expand Down Expand Up @@ -500,7 +500,7 @@ def rotate(agent, name, body):
raise falcon.HTTPBadRequest(title="invalid rotation",
description=f"required field 'sigs' missing from request")

serder = coring.Serder(ked=rot)
serder = serdering.SerderKERI(sad=rot)
sigers = [coring.Siger(qb64=sig) for sig in sigs]

hab.rotate(serder=serder, sigers=sigers)
Expand Down Expand Up @@ -566,7 +566,7 @@ def interact(agent, name, body):
raise falcon.HTTPBadRequest(title="invalid interaction",
description=f"required field 'sigs' missing from request")

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

hab.interact(serder=serder, sigers=sigers)
Expand Down Expand Up @@ -772,7 +772,7 @@ def on_post(req, rep, name, aid=None, role=None):
rpy = httping.getRequiredParam(body, "rpy")
rsigs = httping.getRequiredParam(body, "sigs")

rserder = coring.Serder(ked=rpy)
rserder = serdering.SerderKERI(sad=rpy)
data = rserder.ked['a']
pre = data['cid']
role = data['role']
Expand All @@ -787,7 +787,7 @@ def on_post(req, rep, name, aid=None, role=None):
description=f"error trying to create end role for unknown local AID {pre}")

rsigers = [coring.Siger(qb64=rsig) for rsig in rsigs]
tsg = (hab.kever.prefixer, coring.Seqner(sn=hab.kever.sn), hab.kever.serder.saider, rsigers)
tsg = (hab.kever.prefixer, coring.Seqner(sn=hab.kever.sn), coring.Saider(qb64=hab.kever.serder.said), rsigers)
try:
agent.hby.rvy.processReply(rserder, tsgs=[tsg])
except kering.UnverifiedReplyError:
Expand Down Expand Up @@ -932,7 +932,7 @@ def on_post(req, rep, name):
exn = body["exn"]
sig = body["sig"]
recpt = body["recipient"]
serder = coring.Serder(ked=exn)
serder = serdering.SerderKERI(sad=exn)

ims = bytearray(serder.raw)
ims.extend(sig.encode("utf-8"))
Expand Down
55 changes: 27 additions & 28 deletions src/keria/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
services and endpoint for ACDC credential managements
"""
import json
from dataclasses import asdict

import falcon
from keri import kering
from keri.app import signing
from keri.app.habbing import SignifyGroupHab
from keri.core import coring, scheming
from keri.core import coring, scheming, serdering
from keri.core.eventing import SealEvent
from keri.db import dbing
from keri.vc import proving

from keria.core import httping, longrunning

Expand Down Expand Up @@ -88,7 +88,7 @@ def on_get(req, rep, name):
name=registry.name,
regk=registry.regk,
pre=registry.hab.pre,
state=registry.tever.state().ked
state=asdict(registry.tever.state())
)
res.append(rd)

Expand Down Expand Up @@ -152,10 +152,10 @@ def on_post(self, req, rep, name):

rname = httping.getRequiredParam(body, "name")
ked = httping.getRequiredParam(body, "vcp")
vcp = coring.Serder(ked=ked)
vcp = serdering.SerderKERI(sad=ked)

ked = httping.getRequiredParam(body, "ixn")
ixn = coring.Serder(ked=ked)
ixn = serdering.SerderKERI(sad=ked)

hab = agent.hby.habByName(name)
if hab is None:
Expand All @@ -173,7 +173,7 @@ def on_post(self, req, rep, name):

seqner = coring.Seqner(sn=ixn.sn)
prefixer = coring.Prefixer(qb64=ixn.pre)
agent.registrar.incept(hab, registry, prefixer=prefixer, seqner=seqner, saider=ixn.saider)
agent.registrar.incept(hab, registry, prefixer=prefixer, seqner=seqner, saider=coring.Saider(qb64=ixn.said))
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.registry,
metadata=dict(anchor=anchor, depends=op))

Expand Down Expand Up @@ -474,12 +474,12 @@ def on_post(self, req, rep, name):
if hab is None:
raise falcon.HTTPNotFound(description="name is not a valid reference to an identifier")

creder = proving.Creder(ked=httping.getRequiredParam(body, "acdc"))
iserder = coring.Serder(ked=httping.getRequiredParam(body, "iss"))
creder = serdering.SerderACDC(sad=httping.getRequiredParam(body, "acdc"))
iserder = serdering.SerderKERI(sad=httping.getRequiredParam(body, "iss"))
if "ixn" in body:
anc = coring.Serder(ked=httping.getRequiredParam(body, "ixn"))
anc = serdering.SerderKERI(sad=httping.getRequiredParam(body, "ixn"))
else:
anc = coring.Serder(ked=httping.getRequiredParam(body, "rot"))
anc = serdering.SerderKERI(sad=httping.getRequiredParam(body, "rot"))

regk = iserder.ked['ri']
if regk not in agent.rgy.tevers:
Expand All @@ -495,7 +495,7 @@ def on_post(self, req, rep, name):
agent.registrar.issue(regk, iserder, anc)
agent.credentialer.issue(creder=creder, serder=iserder)
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.credential,
metadata=dict(ced=creder.ked, depends=op))
metadata=dict(ced=creder.sad, depends=op))

except kering.ConfigurationError as e:
rep.status = falcon.HTTP_400
Expand Down Expand Up @@ -579,7 +579,7 @@ def on_get(req, rep, name, said):
def outputCred(hby, rgy, said):
out = bytearray()
creder, prefixer, seqner, saider = rgy.reger.cloneCred(said=said)
chains = creder.chains
chains = creder.edge
saids = []
for key, source in chains.items():
if key == 'd':
Expand All @@ -595,28 +595,28 @@ def outputCred(hby, rgy, said):

issr = creder.issuer
for msg in hby.db.clonePreIter(pre=issr):
serder = coring.Serder(raw=msg)
serder = serdering.SerderKERI(raw=msg)
atc = msg[serder.size:]
out.extend(serder.raw)
out.extend(atc)

if "i" in creder.subject:
subj = creder.subject["i"]
if "i" in creder.attrib:
subj = creder.attrib["i"]
for msg in hby.db.clonePreIter(pre=subj):
serder = coring.Serder(raw=msg)
serder = serdering.SerderKERI(raw=msg)
atc = msg[serder.size:]
out.extend(serder.raw)
out.extend(atc)

if creder.status is not None:
for msg in rgy.reger.clonePreIter(pre=creder.status):
serder = coring.Serder(raw=msg)
if creder.regi is not None:
for msg in rgy.reger.clonePreIter(pre=creder.regi):
serder = serdering.SerderKERI(raw=msg)
atc = msg[serder.size:]
out.extend(serder.raw)
out.extend(atc)

for msg in rgy.reger.clonePreIter(pre=creder.said):
serder = coring.Serder(raw=msg)
serder = serdering.SerderKERI(raw=msg)
atc = msg[serder.size:]
out.extend(serder.raw)
out.extend(atc)
Expand Down Expand Up @@ -651,7 +651,7 @@ def on_delete(self, req, rep, name, said):
if hab is None:
raise falcon.HTTPNotFound(description="name is not a valid reference to an identifier")

rserder = coring.Serder(ked=httping.getRequiredParam(body, "rev"))
rserder = serdering.SerderKERI(sad=httping.getRequiredParam(body, "rev"))

regk = rserder.ked['ri']
if regk not in agent.rgy.tevers:
Expand All @@ -672,7 +672,6 @@ def on_delete(self, req, rep, name, said):
try:
agent.registrar.revoke(regk, rserder, anc)
except Exception as e:
print(e)
raise falcon.HTTPBadRequest(description=f"invalid revocation event.")

rep.status = falcon.HTTP_200
Expand Down Expand Up @@ -731,7 +730,7 @@ def incept(self, hab, registry, prefixer=None, seqner=None, saider=None):
if not isinstance(hab, SignifyGroupHab):

seqner = coring.Seqner(sn=hab.kever.sner.num)
saider = hab.kever.serder.saider
saider = coring.Saider(qb64=hab.kever.serder.said)
registry.anchorMsg(pre=registry.regk, regd=registry.regd, seqner=seqner, saider=saider)
self.witDoer.msgs.append(dict(pre=hab.pre, sn=seqner.sn))
self.rgy.reger.tpwe.add(keys=(registry.regk, rseq.qb64), val=(hab.kever.prefixer, seqner, saider))
Expand Down Expand Up @@ -761,7 +760,7 @@ def issue(self, regk, iserder, anc):

if not isinstance(hab, SignifyGroupHab): # not a multisig group
seqner = coring.Seqner(sn=hab.kever.sner.num)
saider = hab.kever.serder.saider
saider = coring.Saider(qb64=hab.kever.serder.said)
registry.anchorMsg(pre=vcid, regd=iserder.said, seqner=seqner, saider=saider)

print("Waiting for TEL event witness receipts")
Expand Down Expand Up @@ -800,7 +799,7 @@ def revoke(self, regk, rserder, anc):
if not isinstance(hab, SignifyGroupHab):

seqner = coring.Seqner(sn=hab.kever.sner.num)
saider = hab.kever.serder.saider
saider = coring.Saider(qb64=hab.kever.serder.said)
registry.anchorMsg(pre=vcid, regd=rserder.said, seqner=seqner, saider=saider)

print("Waiting for TEL event witness receipts")
Expand Down Expand Up @@ -932,7 +931,7 @@ def validate(self, creder):
bool: true if credential is valid against a known schema
"""
schema = creder.crd['s']
schema = creder.sad['s']
scraw = self.verifier.resolver.resolve(schema)
if not scraw:
raise kering.ConfigurationError("Credential schema {} not found. It must be loaded with data oobi before "
Expand Down Expand Up @@ -960,7 +959,8 @@ def issue(self, creder, serder):
self.rgy.reger.cmse.put(keys=(creder.said, seqner.qb64), val=creder)

try:
self.verifier.processCredential(creder=creder, prefixer=prefixer, seqner=seqner, saider=serder.saider)
self.verifier.processCredential(creder=creder, prefixer=prefixer, seqner=seqner,
saider=coring.Saider(qb64=serder.said))
except kering.MissingRegistryError:
pass

Expand All @@ -977,7 +977,6 @@ def processCredentialMissingSigEscrow(self):
# Remove from this escrow
self.rgy.reger.cmse.rem(keys=(said, snq))

hab = self.hby.habs[creder.issuer]
# place in escrow to diseminate to other if witnesser and if there is an issuee
self.rgy.reger.ccrd.put(keys=(creder.said,), val=creder)

Expand Down
13 changes: 7 additions & 6 deletions src/keria/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import falcon
from keri.app import habbing
from keri.core import coring, eventing
from keri.core import coring, eventing, serdering
from keri.kering import SerializeError

from keria.core import httping, longrunning

Expand Down Expand Up @@ -50,7 +51,7 @@ def on_post(req, rep, name):

# grab all of the required parameters
ked = httping.getRequiredParam(body, "exn")
serder = coring.Serder(ked=ked)
serder = serdering.SerderKERI(sad=ked)
sigs = httping.getRequiredParam(body, "sigs")
atc = httping.getRequiredParam(body, "atc")

Expand Down Expand Up @@ -131,13 +132,13 @@ def on_post(req, rep, name):

hab = agent.hby.joinSignifyGroupHab(gid, name=name, mhab=mhab, smids=smids, rmids=rmids)
try:
hab.make(serder=coring.Serder(ked=rot), sigers=sigers)
hab.make(serder=serdering.SerderKERI(sad=rot), sigers=sigers)
agent.inceptGroup(pre=gid, mpre=mhab.pre, verfers=verfers, digers=digers)
except ValueError as e:
except (ValueError, SerializeError) as e:
agent.hby.deleteHab(name=name)
raise falcon.HTTPBadRequest(description=f"{e.args[0]}")

serder = coring.Serder(ked=rot)
serder = serdering.SerderKERI(sad=rot)
agent.groups.append(dict(pre=hab.pre, serder=serder, sigers=sigers, smids=smids, rmids=rmids))
op = agent.monitor.submit(serder.pre, longrunning.OpTypes.group, metadata=dict(sn=0))

Expand Down Expand Up @@ -184,7 +185,7 @@ def on_get(req, rep, said):

for d in exns:
exn = d['exn']
serder = coring.Serder(ked=exn)
serder = serdering.SerderKERI(sad=exn)

route = serder.ked['r']
payload = serder.ked['a']
Expand Down
Loading

0 comments on commit 9dda515

Please sign in to comment.