diff --git a/src/keri/app/cli/commands/delegate/request.py b/src/keri/app/cli/commands/delegate/request.py index d10778cb7..85d6cbd0f 100644 --- a/src/keri/app/cli/commands/delegate/request.py +++ b/src/keri/app/cli/commands/delegate/request.py @@ -96,7 +96,7 @@ def requestDo(self, tymth, tock=0.0): exn, atc = delegating.delegateRequestExn(hab.mhab, delpre=delpre, evt=bytes(evt), aids=hab.smids) # delegate AID ICP and exn of delegation request EXN - srdr = coring.Serder(raw=evt) + srdr = serdering.SerderKERI(raw=evt) # coring.Serder(raw=evt) del evt[:srdr.size] self.postman.send(src=phab.pre, dest=delpre, topic="delegate", serder=srdr, attachment=evt) self.postman.send(src=phab.pre, dest=hab.kever.delegator, topic="delegate", serder=exn, attachment=atc) diff --git a/src/keri/app/cli/commands/ipex/grant.py b/src/keri/app/cli/commands/ipex/grant.py index 88cb9a3d2..0d3528a33 100644 --- a/src/keri/app/cli/commands/ipex/grant.py +++ b/src/keri/app/cli/commands/ipex/grant.py @@ -10,7 +10,7 @@ from keri.app import forwarding, connecting, habbing, grouping, indirecting, signing from keri.app.cli.common import existing from keri.app.notifying import Notifier -from keri.core import coring, parsing +from keri.core import coring, parsing, serdering from keri.peer import exchanging from keri.vc import protocoling from keri.vdr import credentialing @@ -108,7 +108,7 @@ def grantDo(self, tymth, tock=0.0): iss = self.rgy.reger.cloneTvtAt(creder.said) - iserder = coring.Serder(raw=bytes(iss)) + iserder = serdering.SerderKERI(raw=bytes(iss)) # coring.Serder(raw=bytes(iss)) seqner = coring.Seqner(sn=iserder.sn) serder = self.hby.db.findAnchoringSealEvent(creder.ked['i'], diff --git a/src/keri/app/cli/commands/multisig/join.py b/src/keri/app/cli/commands/multisig/join.py index f792f61a4..774459f27 100644 --- a/src/keri/app/cli/commands/multisig/join.py +++ b/src/keri/app/cli/commands/multisig/join.py @@ -450,7 +450,7 @@ def rpy(self, attrs): if approve: # Create and parse the event with "their" signatures - rserder = coring.Serder(ked=rpy) + rserder = serdering.SerderKERI(ked=rpy) anc = bytearray(rserder.raw) + pathed["rpy"] self.psr.parseOne(ims=bytes(anc)) @@ -512,7 +512,7 @@ def vcp(self, attrs): # Create and parse the event with "their" signatures registryName = input("Name for Registry: ") anc = embeds["anc"] - aserder = coring.Serder(ked=anc) + aserder = serdering.SerderKERI(ked=anc) anc = bytearray(aserder.raw) + pathed["anc"] self.psr.parseOne(ims=bytes(anc)) @@ -522,7 +522,7 @@ def vcp(self, attrs): self.psr.parseOne(ims=bytes(anc)) vcp = embeds["vcp"] - vserder = coring.Serder(ked=vcp) + vserder = serdering.SerderKERI(ked=vcp) try: self.rgy.tvy.processEvent(serder=vserder) except kering.MissingAnchorError: @@ -606,7 +606,7 @@ def iss(self, attrs): if approve: # Create and parse the event with "their" signatures anc = embeds["anc"] - aserder = coring.Serder(ked=anc) + aserder = serdering.SerderKERI(ked=anc) anc = bytearray(aserder.raw) + pathed["anc"] self.psr.parseOne(ims=bytes(anc)) @@ -616,7 +616,7 @@ def iss(self, attrs): self.psr.parseOne(ims=bytes(anc)) iss = embeds["iss"] - iserder = coring.Serder(ked=iss) + iserder = serdering.SerderKERI(ked=iss) try: self.rgy.tvy.processEvent(serder=iserder) except kering.MissingAnchorError: @@ -704,7 +704,7 @@ def rev(self, attrs): if approve: # Create and parse the event with "their" signatures anc = embeds["anc"] - aserder = coring.Serder(ked=anc) + aserder = serdering.SerderKERI(ked=anc) anc = bytearray(aserder.raw) + pathed["anc"] self.psr.parseOne(ims=bytes(anc)) @@ -714,7 +714,7 @@ def rev(self, attrs): self.psr.parseOne(ims=bytes(anc)) rev = embeds["rev"] - rserder = coring.Serder(ked=rev) + rserder = serdering.SerderKERI(ked=rev) try: self.rgy.tvy.processEvent(serder=rserder) except kering.MissingAnchorError: @@ -742,11 +742,11 @@ def rev(self, attrs): recp = creder.subject['i'] msgs = [] for msg in self.hby.db.clonePreIter(pre=creder.issuer): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) atc = msg[serder.size:] msgs.append((serder, atc)) for msg in self.rgy.reger.clonePreIter(pre=creder.said): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) atc = msg[serder.size:] msgs.append((serder, atc)) @@ -798,7 +798,7 @@ def exn(self, attrs): approve = yn in ('', 'y', 'Y') if approve: - eserder = coring.Serder(ked=eexn) + eserder = serdering.SerderKERI(ked=eexn) anc = bytearray(eserder.raw) + pathed["exn"] self.psr.parseOne(ims=bytes(anc)) diff --git a/src/keri/app/cli/commands/rollback.py b/src/keri/app/cli/commands/rollback.py index b35798f59..f7d573f45 100644 --- a/src/keri/app/cli/commands/rollback.py +++ b/src/keri/app/cli/commands/rollback.py @@ -91,7 +91,7 @@ def rollback(tymth, tock=0.0, **opts): ked['f'] = fner.numh ked['dt'] = helping.nowIso8601() - state = coring.Serder(ked=ked) + state = serdering.SerderKERI(ked=ked) # This is wrong key state is not Serder anymore hby.db.states.pin(keys=hab.pre, val=helping.datify(basing.KeyStateRecord, state.ked)) diff --git a/src/keri/app/cli/commands/status.py b/src/keri/app/cli/commands/status.py index c3f33fd9b..787bae9ad 100644 --- a/src/keri/app/cli/commands/status.py +++ b/src/keri/app/cli/commands/status.py @@ -10,7 +10,7 @@ from hio.base import doing from keri.app.cli.common import displaying, existing -from keri.core import coring +from keri.core import coring, serdering from keri.kering import ConfigurationError logger = help.ogler.getLogger() @@ -60,7 +60,7 @@ def status(tymth, tock=0.0, **opts): cloner = hab.db.clonePreIter(pre=hab.pre, fn=0) # create iterator at 0 for msg in cloner: - srdr = coring.Serder(raw=msg) + srdr = serdering.SerderKERI(raw=msg) print(srdr.pretty(size=10000)) print() diff --git a/src/keri/app/cli/commands/vc/create.py b/src/keri/app/cli/commands/vc/create.py index 0c1a9e743..0fa2a1908 100644 --- a/src/keri/app/cli/commands/vc/create.py +++ b/src/keri/app/cli/commands/vc/create.py @@ -8,7 +8,7 @@ from keri.core import serdering from keri.app import indirecting, habbing, grouping, connecting, forwarding, signing, notifying from keri.app.cli.common import existing -from keri.core import coring, eventing +from keri.core import coring, eventing, serdering from keri.help import helping from keri.peer import exchanging from keri.vc import proving @@ -220,7 +220,7 @@ def createDo(self, tymth, tock=0.0): else: anc = hab.interact(data=[rseal]) - aserder = coring.Serder(raw=anc) + aserder = serdering.SerderACDC(raw=anc) # coring.Serder(raw=anc) self.credentialer.issue(self.creder, iserder) self.registrar.issue(self.creder, iserder, aserder) diff --git a/src/keri/app/cli/commands/vc/registry/incept.py b/src/keri/app/cli/commands/vc/registry/incept.py index 8775a3242..77c774f9a 100644 --- a/src/keri/app/cli/commands/vc/registry/incept.py +++ b/src/keri/app/cli/commands/vc/registry/incept.py @@ -7,7 +7,7 @@ from keri.app.cli.common import existing from keri.app.habbing import GroupHab from keri.app.notifying import Notifier -from keri.core import coring +from keri.core import coring, serdering from keri.core.eventing import SealEvent from keri.peer import exchanging from keri.vdr import credentialing @@ -132,7 +132,7 @@ def inceptDo(self, tymth, tock=0.0, **kwa): else: anc = hab.interact(data=[rseal]) - aserder = coring.Serder(raw=bytes(anc)) + aserder = serdering.SerderKERI(raw=bytes(anc)) # coring.Serder(raw=bytes(anc)) self.registrar.incept(iserder=registry.vcp, anc=aserder) if isinstance(hab, GroupHab): diff --git a/src/keri/app/cli/commands/vc/registry/status.py b/src/keri/app/cli/commands/vc/registry/status.py index 846cb1704..f24f57a50 100644 --- a/src/keri/app/cli/commands/vc/registry/status.py +++ b/src/keri/app/cli/commands/vc/registry/status.py @@ -5,7 +5,7 @@ from keri.app import indirecting, habbing, grouping from keri.app.cli.common import existing -from keri.core import coring +from keri.core import coring, serdering from keri.vdr import credentialing logger = help.ogler.getLogger() @@ -98,7 +98,7 @@ def statusDo(self, tymth, tock=0.0): if self.verbose: cloner = reg.reger.clonePreIter(pre=reg.regk, fn=0) # create iterator at 0 for msg in cloner: - srdr = coring.Serder(raw=msg) + srdr = serdering.SerderKERI(raw=msg) print(srdr.pretty()) print() diff --git a/src/keri/app/cli/commands/vc/revoke.py b/src/keri/app/cli/commands/vc/revoke.py index 05e47c78b..ed2c41ec9 100644 --- a/src/keri/app/cli/commands/vc/revoke.py +++ b/src/keri/app/cli/commands/vc/revoke.py @@ -11,7 +11,7 @@ from keri.app import indirecting, habbing, grouping, forwarding, connecting, notifying from keri.app.cli.common import existing from keri.app.habbing import GroupHab -from keri.core import coring +from keri.core import coring, serdering from keri.core.eventing import SealEvent from keri.peer import exchanging from keri.vdr import credentialing, verifying @@ -119,7 +119,7 @@ def revokeDo(self, tymth, tock=0.0): else: anc = hab.interact(data=[rseal]) - aserder = coring.Serder(raw=bytes(anc)) + aserder = serdering.SerderKERI(raw=bytes(anc)) self.registrar.revoke(creder, rserder, aserder) senderHab = self.hab @@ -143,11 +143,11 @@ def revokeDo(self, tymth, tock=0.0): recp = creder.attrib['i'] msgs = [] for msg in self.hby.db.clonePreIter(pre=creder.issuer): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) atc = msg[serder.size:] msgs.append((serder, atc)) for msg in self.rgy.reger.clonePreIter(pre=creder.said): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) atc = msg[serder.size:] msgs.append((serder, atc)) diff --git a/src/keri/app/grouping.py b/src/keri/app/grouping.py index 51dd836cf..429f4fbf9 100644 --- a/src/keri/app/grouping.py +++ b/src/keri/app/grouping.py @@ -279,7 +279,7 @@ def multisigInceptExn(hab, smids, rmids, icp, delegator=None): """ rmids = rmids if rmids is not None else smids - serder = coring.Serder(raw=icp) + serder = serdering.SerderKERI(raw=icp) # coring.Serder(raw=icp) data = dict( gid=serder.pre, smids=smids, diff --git a/src/keri/core/coring.py b/src/keri/core/coring.py index 16b5ae16d..4d58794c3 100644 --- a/src/keri/core/coring.py +++ b/src/keri/core/coring.py @@ -5369,215 +5369,6 @@ def pretty(self, *, size=1024): return json.dumps(self.ked, indent=1)[:size if size is not None else None] -class Serder(Sadder): - """ - Serder is versioned protocol key event message serializer-deserializer class - - Only supports current version VERSION - - Has the following public properties: - - Inherited Properties: - raw (bytes): of serialized event only - ked (dict): self addressed data dict - kind (str): serialization kind coring.Serials such as JSON, CBOR, MGPK, CESR - size (int): number of bytes in serialization - version (Versionage): protocol version (Major, Minor) - proto (str): Protocolage value as protocol identifier such as KERI, ACDC - label (str): Saidage value as said field label - saider (Saider): of SAID of this SAD .ked['d'] if present - said (str): SAID of .saider qb64 - saidb (bytes): SAID of .saider qb64b - pretty (str): Pretty JSON of this SAD - - Properties: - .diger is Diger instance of digest of .raw - .dig is qb64 digest from .diger - .digb is qb64b digest from .diger - .verfers is list of Verfers converted from .ked["k"] - .werfers is list of Verfers converted from .ked["b"] - .tholder is Tholder instance from .ked["kt'] else None - .ntholder is Tholder instance from .ked["nt'] else None - sner (Number): instance converted from sequence number .ked["s"] hex str - sn (int): sequence number converted from .ked["s"] - fner (Number): instance converted from first seen ordinal number - .ked["f"] hex str if any otherwise None - fn (int): first seen ordinal number converted from .ked["f"] if any - otherwise None - .pre is qb64 str of identifier prefix from .ked["i"] - .preb is qb64b bytes of identifier prefix from .ked["i"] - - Inherited Hidden Attributes: - ._raw is bytes of serialized event only - ._ked is key event dict - ._kind is serialization kind string value (see namedtuple coring.Serials) - supported kinds are 'json', 'cbor', 'msgpack', 'binary' - ._size is int of number of bytes in serialed event only - ._version is Versionage instance of event version - ._proto (str): Protocolage value as protocol type identifier - ._saider (Saider): instance for this Sadder's SAID - - Note: - loads and jumps of json use str whereas cbor and msgpack use bytes - - """ - - def __init__(self, raw=b'', ked=None, kind=None, sad=None, code=MtrDex.Blake3_256): - """ - Deserialize if raw provided - Serialize if ked provided but not raw - When serializing if kind provided then use kind instead of field in ked - - Parameters: - raw is bytes of serialized event plus any attached signatures - ked is key event dict or None - if None its deserialized from raw - sad (Sadder) is clonable base class - kind is serialization kind string value or None (see namedtuple coring.Serials) - supported kinds are 'json', 'cbor', 'msgpack', 'binary' - if kind is None then its extracted from ked or raw - code is .diger default digest code - - """ - super(Serder, self).__init__(raw=raw, ked=ked, kind=kind, sad=sad, code=code) - - if self._proto != Protos.keri: - raise ValueError("Invalid protocol {}, must be KERI".format(self._proto)) - - - @property - def verfers(self): - """ - Returns list of Verfer instances as converted from .ked['k']. - One for each key. - verfers property getter - """ - if "k" in self.ked: # establishment event - keys = self.ked["k"] - else: # non-establishment event - keys = [] - - return [Verfer(qb64=key) for key in keys] - - @property - def digers(self): - """ - Returns list of Diger instances as converted from .ked['n']. - One for each next key digests. - digers property getter - """ - if "n" in self.ked: # establishment event - digs = self.ked["n"] - else: # non-establishment event - digs = [] - - return [Diger(qb64=dig) for dig in digs] - - @property - def werfers(self): - """ - Returns list of Verfer instances as converted from .ked['b']. - One for each backer (witness). - werfers property getter - """ - if "b" in self.ked: # inception establishment event - wits = self.ked["b"] - else: # non-establishment event - wits = [] - - return [Verfer(qb64=wit) for wit in wits] - - @property - def tholder(self): - """ - Returns Tholder instance as converted from .ked['kt'] or None if missing. - - """ - return Tholder(sith=self.ked["kt"]) if "kt" in self.ked else None - - @property - def ntholder(self): - """ - Returns Tholder instance as converted from .ked['nt'] or None if missing. - - """ - return Tholder(sith=self.ked["nt"]) if "nt" in self.ked else None - - @property - def sner(self): - """ - sner (Number of sequence number) property getter - Returns: - (Number): of .ked["s"] hex number str converted - """ - return Number(num=self.ked["s"]) # auto converts hex num str to int - - - @property - def sn(self): - """ - sn (sequence number) property getter - Returns: - sn (int): of .sner.num from .ked["s"] - """ - return (self.sner.num) - - - @property - def fner(self): - """ - fner (Number of first seen ordinal) property getter - Returns: - (Number): of .ked["f"] hex number str converted - """ - # auto converts hex num str to int - return Number(num=self.ked["f"]) if "f" in self.ked else None - - - @property - def fn(self): - """ - fn (first seen ordinal number) property getter - Returns: - fn (int): of .fner.num from .ked["f"] - """ - return (self.fner.num) - - - @property - def pre(self): - """ - Returns str qb64 of .ked["i"] (identifier prefix) - pre (identifier prefix) property getter - """ - return self.ked["i"] - - - @property - def preb(self): - """ - Returns bytes qb64b of .ked["i"] (identifier prefix) - preb (identifier prefix) property getter - """ - return self.pre.encode("utf-8") - - - @property - def est(self): # establishative - """ Returns True if Serder represents an establishment event """ - return self.ked["t"] in (Ilks.icp, Ilks.rot, Ilks.dip, Ilks.drt) - - - def pretty(self, *, size=1024): - """ - Returns str JSON of .ked with pretty formatting - - ToDo: add default size limit on pretty when used for syslog UDP MCU - like 1024 for ogler.logger - """ - return json.dumps(self.ked, indent=1)[:size if size is not None else None] - - class Tholder: """ diff --git a/src/keri/vdr/credentialing.py b/src/keri/vdr/credentialing.py index f6a388ce2..2a89d5334 100644 --- a/src/keri/vdr/credentialing.py +++ b/src/keri/vdr/credentialing.py @@ -13,7 +13,7 @@ from ..app import agenting from ..app.habbing import GroupHab from ..core import parsing, coring, scheming, serdering -from ..core.coring import Seqner, MtrDex, Serder +from ..core.coring import Seqner, MtrDex from ..core.eventing import SealEvent, TraitDex from ..db import dbing from ..db.dbing import snKey, dgKey @@ -371,7 +371,7 @@ def revoke(self, said, dt=None): raise kering.ValidationError("Invalid revoke of {} that has not been issued " "pre={}.".format(vci, self.regk)) ievt = self.reger.getTvt(dgKey(pre=vci, dig=vcser)) - iserder = Serder(raw=bytes(ievt)) + iserder = serdering.SerderKERI(raw=bytes(ievt)) #Serder(raw=bytes(ievt)) if self.noBackers: serder = eventing.revoke(vcdig=vci, regk=self.regk, dig=iserder.said, dt=dt) @@ -468,7 +468,7 @@ def revoke(self, said, dt=None): raise kering.ValidationError("Invalid revoke of {} that has not been issued " "pre={}.".format(vci, self.regk)) ievt = self.reger.getTvt(dgKey(pre=vci, dig=vcser)) - iserder = Serder(raw=bytes(ievt)) + iserder = serdering.serderACDC(raw=bytes(ievt)) # Serder(raw=bytes(ievt)) if self.noBackers: serder = eventing.revoke(vcdig=vci, regk=self.regk, dig=iserder.said, dt=dt) @@ -970,7 +970,7 @@ def sendArtifacts(hby, reger, postman, creder, recp): postman.send(serder=serder, attachment=atc) for msg in reger.clonePreIter(pre=creder.said): - serder = coring.Serder(raw=msg) + serder = serdering.SerderACDC(raw=msg) # coring.Serder(raw=msg) atc = msg[serder.size:] postman.send(serder=serder, attachment=atc) @@ -984,16 +984,16 @@ def sendRegistry(hby, reger, postman, creder, sender, recp): ikever = hby.db.kevers[issr] for msg in hby.db.cloneDelegation(ikever): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) # coring.Serder(raw=msg) atc = msg[serder.size:] postman.send(serder=serder, attachment=atc) for msg in hby.db.clonePreIter(pre=issr): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) # coring.Serder(raw=msg) atc = msg[serder.size:] postman.send(serder=serder, attachment=atc) for msg in reger.clonePreIter(pre=regk): - serder = coring.Serder(raw=msg) + serder = serdering.SerderKERI(raw=msg) # coring.Serder(raw=msg) atc = msg[serder.size:] postman.send(serder=serder, attachment=atc) diff --git a/tests/core/test_coring.py b/tests/core/test_coring.py index 924538fc4..7ec33df4a 100644 --- a/tests/core/test_coring.py +++ b/tests/core/test_coring.py @@ -5768,419 +5768,6 @@ def test_versify(): -def test_serder(): - """ - Test the support functionality for Serder key event serialization deserialization - deprecated - """ - with pytest.raises(ValueError): - serder = coring.Serder() - - e1 = dict(v=Vstrings.json, - d="", - i="ABCDEFG", - s="0001", - t="rot") - _, e1 = coring.Saider.saidify(sad=e1) - - serder = coring.Serder(ked=e1) - assert serder.ked == e1 - assert serder.kind == Serials.json - assert serder.version == Versionage(major=1, minor=0) - assert serder.said == 'EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F' - #'EgzrpOMEx_A-dvAruhmptnIbP2c55WZAd4fc1nGuyTwU' - assert serder.saidb == b'EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F' - assert serder.size == 111 - assert serder.verfers == [] - assert serder.raw == (b'{"v":"KERI10JSON00006f_","d":"EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F",' - b'"i":"ABCDEFG","s":"0001","t":"rot"}') - assert serder.sn == 1 - assert serder.pre == "ABCDEFG" - assert serder.preb == b"ABCDEFG" - - e1s = json.dumps(e1, separators=(",", ":"), ensure_ascii=False).encode("utf-8") - assert e1s == ((b'{"v":"KERI10JSON00006f_","d":"EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F",' - b'"i":"ABCDEFG","s":"0001","t":"rot"}')) - vs = versify(kind=Serials.json, size=len(e1s)) # use real length - assert vs == 'KERI10JSON00006f_' - e1["v"] = vs # has real length - pretty = serder.pretty() - assert pretty == ('{\n' - ' "v": "KERI10JSON00006f_",\n' - ' "d": "EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F",\n' - ' "i": "ABCDEFG",\n' - ' "s": "0001",\n' - ' "t": "rot"\n' - '}') - - e1s = json.dumps(e1, separators=(",", ":"), ensure_ascii=False).encode("utf-8") - with pytest.raises(ShortageError): # test too short - protos1, kind1, vers1, size1 = sniff(e1s[:VERFULLSIZE]) - - protos1, kind1, vers1, size1 = sniff(e1s[:MINSNIFFSIZE]) - assert protos1 == Protos.keri - assert kind1 == Serials.json - assert size1 == 111 - - protos1, kind1, vers1, size1 = sniff(e1s) - assert protos1 == Protos.keri - assert kind1 == Serials.json - assert size1 == 111 - e1ss = e1s + b'extra attached at the end.' - ked1, idnt1, knd1, vrs1, siz1 = serder._inhale(e1ss) - assert ked1 == e1 - assert idnt1 == Protos.keri - assert knd1 == kind1 - assert vrs1 == vers1 - assert siz1 == size1 - - with pytest.raises(ShortageError): # test too short - ked1, knd1, vrs1, siz1 = serder._inhale(e1ss[:size1 - 1]) - - raw1, idnt1, knd1, ked1, ver1 = serder._exhale(ked=e1) - assert raw1 == e1s - assert idnt1 == Protos.keri - assert knd1 == kind1 - assert ked1 == e1 - assert vrs1 == vers1 - - e2 = dict(e1) - e2["v"] = Vstrings.mgpk - e2s = msgpack.dumps(e2) - assert e2s == (b'\x85\xa1v\xb1KERI10MGPK000000_\xa1d\xd9,EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH' - b'3NZxrsk8F\xa1i\xa7ABCDEFG\xa1s\xa40001\xa1t\xa3rot') - vs = versify(kind=Serials.mgpk, size=len(e2s)) # use real length - assert vs == 'KERI10MGPK00005c_' - e2["v"] = vs # has real length - _, e2 = coring.Saider.saidify(sad=e2) - e2s = msgpack.dumps(e2) - - with pytest.raises(ShortageError): # test too short - ident2, kind2, vers2, size2 = sniff(e2s[:VERFULLSIZE]) - - ident2, kind2, vers2, size2 = sniff(e2s[:MINSNIFFSIZE]) - assert ident2 == Protos.keri - assert kind2 == Serials.mgpk - assert size2 == 92 - - ident2, kind2, vers2, size2 = sniff(e2s) - assert ident2 == Protos.keri - assert kind2 == Serials.mgpk - assert size2 == 92 - e2ss = e2s + b'extra attached at the end.' - ked2, idnt2, knd2, vrs2, siz2 = serder._inhale(e2ss) - assert ked2 == e2 - assert idnt2 == Protos.keri - assert knd2 == kind2 - assert vrs2 == vers2 - assert siz2 == size2 - - with pytest.raises(ShortageError): # test too short - ked2, knd2, vrs2, siz2 = serder._inhale(e2ss[:size2 - 1]) - - raw2, idnt2, knd2, ked2, ver2 = serder._exhale(ked=e2) - assert raw2 == e2s - assert idnt2 == Protos.keri - assert knd2 == kind2 - assert ked2 == e2 - assert vrs2 == vers2 - - e3 = dict(e1) - e3["v"] = Vstrings.cbor - e3s = cbor.dumps(e3) - assert e3s == (b'\xa5avqKERI10CBOR000000_adx,EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8Faig' - b'ABCDEFGasd0001atcrot') - vs = versify(kind=Serials.cbor, size=len(e3s)) # use real length - assert vs == 'KERI10CBOR00005c_' - e3["v"] = vs # has real length - _, e3 = coring.Saider.saidify(sad=e3) - e3s = cbor.dumps(e3) - - with pytest.raises(ShortageError): # test too short - ident3, kind3, vers3, size3 = sniff(e3s[:VERFULLSIZE]) - - ident3, kind3, vers3, size3 = sniff(e3s[:MINSNIFFSIZE]) - assert ident3 == Protos.keri - assert kind3 == Serials.cbor - assert size3 == 92 - - ident3, kind3, vers3, size3 = sniff(e3s) - assert ident3 == Protos.keri - assert kind3 == Serials.cbor - assert size3 == 92 - e3ss = e3s + b'extra attached at the end.' - ked3, idnt3, knd3, vrs3, siz3 = serder._inhale(e3ss) - assert ked3 == e3 - assert idnt3 == Protos.keri - assert knd3 == kind3 - assert vrs3 == vers3 - assert siz3 == size3 - - with pytest.raises(ShortageError): # test too short - ked3, knd3, vrs3, siz3 = serder._inhale(e3ss[:size3 - 1]) - - raw3, idnt3, knd3, ked3, ver3 = serder._exhale(ked=e3) - assert raw3 == e3s - assert idnt3 == Protos.keri - assert knd3 == kind3 - assert ked3 == e3 - assert vrs3 == vers3 - - e4 = dict(v=versify(proto=Protos.acdc, kind=Serials.json, size=0), - d="", - i="ABCDEFG", - s="0001", - t="rot") - _, e4 = coring.Saider.saidify(sad=e4) - - e4s = json.dumps(e4, separators=(",", ":"), ensure_ascii=False).encode("utf-8") - assert e4s == (b'{"v":"ACDC10JSON00006f_","d":"EMFw6MEBmwWU28-7wK4SJ2kasSzVgLKkAM7iwoqJJ07Z",' - b'"i":"ABCDEFG","s":"0001","t":"rot"}') - vs = versify(proto=Protos.acdc, kind=Serials.json, size=len(e4s)) # use real length - assert vs == 'ACDC10JSON00006f_' - e4["v"] = vs # has real length - serder = Sadder(ked=e4) - pretty = serder.pretty() - assert pretty == ('{\n' - ' "v": "ACDC10JSON00006f_",\n' - ' "d": "EMFw6MEBmwWU28-7wK4SJ2kasSzVgLKkAM7iwoqJJ07Z",\n' - ' "i": "ABCDEFG",\n' - ' "s": "0001",\n' - ' "t": "rot"\n' - '}') - - e4s = json.dumps(e4, separators=(",", ":"), ensure_ascii=False).encode("utf-8") - with pytest.raises(ShortageError): # test too short - ident4, kind4, vers4, size4 = sniff(e4s[:VERFULLSIZE]) - - ident4, kind4, vers4, size4 = sniff(e4s[:MINSNIFFSIZE]) - assert ident4 == Protos.acdc - assert kind4 == Serials.json - assert size4 == 111 - - ident4, kind4, vers4, size4 = sniff(e4s) - assert ident4 == Protos.acdc - assert kind4 == Serials.json - assert size4 == 111 - - evt1 = coring.Serder(raw=e1ss) - assert evt1.kind == kind1 - assert evt1.raw == e1s - assert evt1.ked == ked1 - assert evt1.size == size1 - assert evt1.raw == e1ss[:size1] - assert evt1.version == vers1 - assert evt1.sn == 1 - - # test digest properties .diger and .dig - assert evt1.saider.qb64 == evt1.said - assert evt1.saider.code == MtrDex.Blake3_256 - assert len(evt1.saider.raw) == 32 - assert len(evt1.said) == 44 - assert len(evt1.said) == Matter.Sizes[MtrDex.Blake3_256].fs - assert evt1.said == 'EIM66TjBMfwPnbwK7oZqbZyGz9nOeVmQHeH3NZxrsk8F' - assert evt1.saider.verify(evt1.ked) - - evt1 = coring.Serder(ked=ked1) - assert evt1.kind == kind1 - assert evt1.raw == e1s - assert evt1.ked == ked1 - assert evt1.size == size1 - assert evt1.raw == e1ss[:size1] - assert evt1.version == vers1 - assert evt1.saider.code == MtrDex.Blake3_256 - - evt2 = coring.Serder(raw=e2ss) - assert evt2.kind == kind2 - assert evt2.raw == e2s - assert evt2.ked == ked2 - assert evt2.version == vers2 - - evt2 = coring.Serder(ked=ked2) - assert evt2.kind == kind2 - assert evt2.raw == e2s - assert evt2.ked == ked2 - assert evt2.size == size2 - assert evt2.raw == e2ss[:size2] - assert evt2.version == vers2 - - evt3 = coring.Serder(raw=e3ss) - assert evt3.kind == kind3 - assert evt3.raw == e3s - assert evt3.ked == ked3 - assert evt3.version == vers3 - - evt3 = coring.Serder(ked=ked3) - assert evt3.kind == kind3 - assert evt3.raw == e3s - assert evt3.ked == ked3 - assert evt3.size == size3 - assert evt3.raw == e3ss[:size3] - assert evt3.version == vers3 - - # round trip - evt2 = coring.Serder(ked=evt1.ked) - assert evt2.kind == evt1.kind - assert evt2.raw == evt1.raw - assert evt2.ked == evt1.ked - assert evt2.size == evt1.size - assert evt2.version == vers2 - - # Test change in kind by Serder - ked1["v"] = Vstrings.mgpk - _, ked1 = coring.Saider.saidify(sad=ked1) - evt1 = coring.Serder(ked=ked1, kind=Serials.mgpk) # ked is json but kind mgpk - assert evt1.kind == kind2 - assert evt1.raw == e2s - assert evt1.ked == ked2 - assert evt1.size == size2 - assert evt1.raw == e2ss[:size2] - assert evt1.version == vers1 - assert evt1.said == 'EMvr339cs3EH-WcXfLDGOi-rRjNQxK46PqvBcgdAgg8p' - assert evt1.saider.verify(evt1.ked) - - # round trip - evt2 = coring.Serder(raw=evt1.raw) - assert evt2.kind == evt1.kind - assert evt2.raw == evt1.raw - assert evt2.ked == evt1.ked - assert evt2.size == evt1.size - assert evt2.version == vers2 - - ked1["v"] = Vstrings.cbor - _, ked1 = coring.Saider.saidify(sad=ked1) - evt1 = coring.Serder(ked=ked1, kind=Serials.cbor) # ked is json but kind mgpk - assert evt1.kind == kind3 - assert evt1.raw == e3s - assert evt1.ked == ked3 - assert evt1.size == size3 - assert evt1.raw == e3ss[:size3] - assert evt1.version == vers1 - - # round trip - evt2 = coring.Serder(raw=evt1.raw) - assert evt2.kind == evt1.kind - assert evt2.raw == evt1.raw - assert evt2.ked == evt1.ked - assert evt2.size == evt1.size - assert evt2.version == vers2 - - # use kind setter property - assert evt2.kind == Serials.cbor - evt2.kind = Serials.json - assert evt2.kind == Serials.json - proto, version, knd, size = deversify(evt2.ked["v"]) - assert proto == Protos.keri - assert knd == Serials.json - - # Test diger code - ked = {'v': "KERI10JSON00006a_", - 'd': 'HAg9_-rPd8oga-oyPghCEIlJZHKbYXcP86LQl0Yg2AvA', - 'i': 'ABCDEFG', 's': 1, - 't': 'rot'} - raw = ( - b'{"v":"KERI10JSON00006a_","d":"HAg9_-rPd8oga-oyPghCEIlJZHKbYXcP86LQl0Yg2AvA","i":"ABCDEFG","s":1,"t":"rot"}') - srdr = coring.Serder(raw=raw, code=MtrDex.SHA3_256) - assert srdr.kind == 'JSON' - assert srdr.raw == raw - assert srdr.ked == ked - assert srdr.saider.code == MtrDex.SHA3_256 - - # Test compare - ked = {'v': "KERI10JSON00006a_", - 'd': 'EADZ055vgh5utgSY3OOL1lW0m1pJ1W0Ia6-SVuGa0OqE', - 'i': 'ABCDEFG', 's': 1, - 't': 'rot'} - raw = ( - b'{"v":"KERI10JSON00006a_","d":"EADZ055vgh5utgSY3OOL1lW0m1pJ1W0Ia6-SVuGa0OqE","i":"ABCDEFG","s":1,"t":"rot"}') - srdr = coring.Serder(raw=raw) - assert srdr.kind == 'JSON' - assert srdr.raw == raw - assert srdr.ked == ked - assert srdr.saider.code == MtrDex.Blake3_256 - - # need tests will fully populated serder for icp rot dip drt - #aids = generatePublics(salt=None, count=3, transferable=False) - aids = ['BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI', - 'BC9Df6ssUZQFQZJYVUyfudw4WTQsugGcvVD_Z4ChFGE4', - 'BEejlxZytU7gjUwtgkmNKmBWiFPKSsXjk_uxzoun8dtK'] - - - #pre0 = aids[0] - #wit0 = aids[1] - #wit1 = aids[2] - #srdr = eventing.incept(keys=[pre0], wits=[wit0, wit1]) - #assert srdr.raw == (b'{"v":"KERI10JSON00015a_","t":"icp","d":"EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQK' - #b'VXvg7oqd","i":"BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI","s":"0","kt":"1' - #b'","k":["BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI"],"nt":"0","n":[],"bt":' - #b'"2","b":["BC9Df6ssUZQFQZJYVUyfudw4WTQsugGcvVD_Z4ChFGE4","BEejlxZytU7gjUwtgkm' - #b'NKmBWiFPKSsXjk_uxzoun8dtK"],"c":[],"a":[]}') - ## test for serder.verfers and serder.werfers - #assert srdr.pre == pre0 - #assert srdr.sn == 0 - #assert [verfer.qb64 for verfer in srdr.verfers] == [pre0] - #assert [werfer.qb64 for werfer in srdr.werfers] == [wit0, wit1] - - # test .said and .saidb properties - ked = { - "v": "KERI10JSON00011c_", - "t": "rep", - "d": "EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQKVXvg7oqd", - "dt": "2020-08-22T17:50:12.988921+00:00", - "r": "logs/processor", - "a": - { - "d": "EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQKVXvg7oqd", - "i": "BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI", - "name": "John Jones", - "role": "Founder", - } - } - srdr = coring.Serder(ked=ked) - assert srdr.said == 'EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQKVXvg7oqd' - assert srdr.saidb == b'EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQKVXvg7oqd' - - # test tholder - ked = dict(v="KERI10JSON000000_", # version string - t="icp", - d="", - i="BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI", # qb64 prefix - s="0", # hex string no leading zeros lowercase - kt="1", # hex string no leading zeros lowercase - k=["BC9Df6ssUZQFQZJYVUyfudw4WTQsugGcvVD_Z4ChFGE4"], # list of qb64 - n="", # hash qual Base64 - bt="0", # hex string no leading zeros lowercase - b=[], # list of qb64 may be empty - c=[], # list of config ordered mappings may be empty - a=[], # list of seal dicts - ) - _, ked = coring.Saider.saidify(sad=ked) - - srdr = coring.Serder(ked=ked) - assert srdr.tholder.sith == "1" - assert srdr.tholder.thold == 1 - assert srdr.sn == 0 - assert srdr.sner.num == srdr.sn - - # test validation in Serder.sn property - ked["s"] = "-1" - srdr = coring.Serder(ked=ked) - with pytest.raises(InvalidValueError): - sn = srdr.sn - - #ked["s"] = "0" * 33 - #srdr = coring.Serder(ked=ked) - #with pytest.raises(InvalidValueError): - #sn = srdr.sn - - ked["s"] = "15.34" - srdr = coring.Serder(ked=ked) - with pytest.raises(InvalidValueError): - sn = srdr.sn - - """Done Test """ - - def test_tholder(): """ Test Tholder signing threshold satisfier class diff --git a/tests/core/test_eventing.py b/tests/core/test_eventing.py index 20cb09cd2..a4e298e7a 100644 --- a/tests/core/test_eventing.py +++ b/tests/core/test_eventing.py @@ -14,7 +14,7 @@ from keri.app.keeping import openKS, Manager from keri.core import coring, eventing, parsing, serdering from keri.core.coring import (Diger, MtrDex, Matter, IdrDex, Indexer, - CtrDex, Counter, Salter, Serder, Siger, Cigar, + CtrDex, Counter, Salter, Siger, Cigar, Seqner, Verfer, Signer, Prefixer, generateSigners, IdxSigDex, DigDex) from keri.core.eventing import Kever, Kevery @@ -4457,7 +4457,7 @@ def test_process_nontransferable(): assert aid0.verify(ked=ked0) # Serialize ked0 - tser0 = Serder(ked=ked0) + tser0 = serdering.SerderKERI(sad=ked0) # sign serialization tsig0 = skp0.sign(tser0.raw, index=0) @@ -4472,7 +4472,7 @@ def test_process_nontransferable(): msgb0 = bytearray(tser0.raw + cnt0.qb64b + tsig0.qb64b) # deserialize packet - rser0 = Serder(raw=msgb0) + rser0 = serdering.SerderKERI(raw=msgb0) assert rser0.raw == tser0.raw del msgb0[:rser0.size] # strip off event from front @@ -4524,18 +4524,6 @@ def test_process_transferable(): toad = 0 # no witnesses nsigs = 1 # one attached signature unspecified index - #ked0 = dict(v=versify(kind=Serials.json, size=0), - #t=Ilks.icp, - #d="", - #i="", # qual base 64 prefix - #s="{:x}".format(sn), # hex string no leading zeros lowercase - #kt="{:x}".format(sith), # hex string no leading zeros lowercase - #k=keys, # list of signing keys each qual Base64 - #n=nxt, # hash qual Base64 - #wt="{:x}".format(toad), # hex string no leading zeros lowercase - #w=[], # list of qual Base64 may be empty - #c=[], - #) ked0 = dict(v=versify(kind=Serials.json, size=0), # version string t=Ilks.icp, @@ -4553,17 +4541,16 @@ def test_process_transferable(): ) - # Derive AID from ked + # Use non digestive AID aid0 = Prefixer(ked=ked0, code=MtrDex.Ed25519) assert aid0.code == MtrDex.Ed25519 assert aid0.qb64 == skp0.verfer.qb64 - _, ked0 = coring.Saider.saidify(sad=ked0) - # update ked with pre ked0["i"] = aid0.qb64 + _, ked0 = coring.Saider.saidify(sad=ked0) # Serialize ked0 - tser0 = Serder(ked=ked0) + tser0 = serdering.SerderKERI(sad=ked0) # sign serialization tsig0 = skp0.sign(tser0.raw, index=0) @@ -4578,7 +4565,7 @@ def test_process_transferable(): msgb0 = bytearray(tser0.raw + cnt0.qb64b + tsig0.qb64b) # deserialize packet - rser0 = Serder(raw=msgb0) + rser0 = serdering.SerderKERI(raw=msgb0) assert rser0.raw == tser0.raw del msgb0[:rser0.size] # strip off event from front @@ -4604,7 +4591,7 @@ def test_process_transferable(): assert raid0.verify(ked=rser0.ked) # verify nxt digest from event is still valid - digers=rser0.digers + digers=rser0.ndigers #assert rnxt1.includes(keys=nxtkeys) """ Done Test """ @@ -4674,23 +4661,24 @@ def test_process_manual(): k=[aidmat.qb64], # list of signing keys each qual Base64 nt=nxtsith, n=nxts, - wt="{:x}".format(toad), # hex string no leading zeros lowercase - w=[], # list of qual Base64 may be empty - c=[], # list of config ordered mappings may be empty + bt="{:x}".format(toad), # hex string no leading zeros lowercase + b=[], # list of qual Base64 may be empty + c=[], # list of config traits may be empty + a=[], # list of seals ordered mappings may be empty ) _, ked0 = coring.Saider.saidify(sad=ked0) - txsrdr = Serder(ked=ked0, kind=Serials.json) - assert txsrdr.raw == (b'{"v":"KERI10JSON000124_","t":"icp","d":"EKlLyOddVoxzsk8UaJFvYA2YDusEenTpaYXk' - b'MLtCpUbh","i":"DK-WsHD7MKfQpBjJ3B2GwjqY9z90G94uzMs7irCiT-dL","s":"0","kt":"1' - b'","k":["DK-WsHD7MKfQpBjJ3B2GwjqY9z90G94uzMs7irCiT-dL"],"nt":"1","n":["EDcWJG' - b'2wb0EXMZTzs4DgMwAWN_Qn2E6oMkTtX2C8E_4R"],"wt":"0","w":[],"c":[]}') + txsrdr = serdering.SerderKERI(sad=ked0, kind=Serials.json) + assert txsrdr.raw == (b'{"v":"KERI10JSON00012b_","t":"icp","d":"EKYHED-wvkYDZv4tNUF9qiC1kgnnGLS9YUU8' + b'PCWig_n4","i":"DK-WsHD7MKfQpBjJ3B2GwjqY9z90G94uzMs7irCiT-dL","s":"0","kt":"1' + b'","k":["DK-WsHD7MKfQpBjJ3B2GwjqY9z90G94uzMs7irCiT-dL"],"nt":"1","n":["EDcWJG' + b'2wb0EXMZTzs4DgMwAWN_Qn2E6oMkTtX2C8E_4R"],"bt":"0","b":[],"c":[],"a":[]}') - assert txsrdr.size == 292 + assert txsrdr.size == 299 txdig = blake3.blake3(txsrdr.raw).digest() txdigmat = coring.Saider(sad=ked0, code=MtrDex.Blake3_256) - assert txdigmat.qb64 == 'EKlLyOddVoxzsk8UaJFvYA2YDusEenTpaYXkMLtCpUbh' + assert txdigmat.qb64 == 'EKYHED-wvkYDZv4tNUF9qiC1kgnnGLS9YUU8PCWig_n4' assert txsrdr.said == txdigmat.qb64 @@ -4701,17 +4689,16 @@ def test_process_manual(): assert not result # None if verifies successfully else raises ValueError txsigmat = Siger(raw=sig0raw, code=IdrDex.Ed25519_Sig, index=index) - assert txsigmat.qb64 == ('AAClimpgQX2jFTbYlTebmxIVRpE1SzPCcHdyNm-EsBJAOUVXH' - 'bdRBd6wbpePWsuEcWIK-k9kbX-PagPVG6lsKhcP') + assert txsigmat.qb64 == 'AAAbwxAS2DuLS4HLaiv9hHd6YEolpPjMKYRdXY3VwmWKh5gW5J2QBsZ1cMmdrlyIlgvqTQEViicNv9mHHOvj9ZAB' assert len(txsigmat.qb64) == 88 assert txsigmat.index == index msgb = txsrdr.raw + txsigmat.qb64.encode("utf-8") - assert len(msgb) == 380 # 292 + 88 + assert len(msgb) == 387 # 299 + 88 # Recieve side - rxsrdr = Serder(raw=msgb) + rxsrdr = serdering.SerderKERI(raw=msgb) assert rxsrdr.size == txsrdr.size assert rxsrdr.ked == ked0 diff --git a/tests/peer/test_exchanging.py b/tests/peer/test_exchanging.py index b3eed7420..378f08acb 100644 --- a/tests/peer/test_exchanging.py +++ b/tests/peer/test_exchanging.py @@ -4,7 +4,7 @@ """ from keri.app import habbing, forwarding, storing, signing -from keri.core import coring +from keri.core import coring, serdering from keri.peer import exchanging from keri.vdr.eventing import incept @@ -119,7 +119,7 @@ def test_hab_exchange(mockHelpingNowUTC): b'rTWp4llIzVzBM7VVsDOgXVJdoiVXutsWJEbDJ2pMdjXjNi1xKALBSZ1ZgRoUsD--' b'LgUQkXIdjLoQ19XPvJMJ') - exn = coring.Serder(raw=msg) + exn = serdering.SerderKERI(raw=msg) hab2 = hby.makeHab(name="respondant") regser = incept(hab2.pre, diff --git a/tests/vdr/test_eventing.py b/tests/vdr/test_eventing.py index df41c766c..c2cbeefed 100644 --- a/tests/vdr/test_eventing.py +++ b/tests/vdr/test_eventing.py @@ -8,7 +8,7 @@ from keri.app import habbing, keeping from keri.core import coring, serdering from keri.core import eventing as keventing -from keri.core.coring import versify, Serials, Ilks, MtrDex, Prefixer, Serder, Signer, Seqner +from keri.core.coring import versify, Serials, Ilks, MtrDex, Prefixer, Signer, Seqner, Saider from keri.db import basing from keri.db.dbing import snKey, dgKey from keri.kering import Version, EmptyMaterialError, DerivationError, MissingAnchorError, ValidationError, \ @@ -478,13 +478,14 @@ def test_tever_escrow(mockCoringRandomNonce): rseal = keventing.SealEvent(regk, vcp.ked["s"], vcp.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) with pytest.raises(MissingWitnessSignatureError): - Tever(serder=vcp, seqner=seqner, saider=diger, db=db, reger=reg) + Tever(serder=vcp, seqner=seqner, saider=saider, db=db, reger=reg) dgkey = dgKey(pre=regk, dig=vcp.said) vcp = reg.getTvt(dgkey) @@ -518,12 +519,13 @@ def test_tever_no_backers(mockHelpingNowUTC, mockCoringRandomNonce): rseal = keventing.SealEvent(i=regk, s=vcp.ked["s"], d=vcp.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev = Tever(serder=vcp, seqner=seqner, saider=diger, db=db, reger=reg) + tev = Tever(serder=vcp, seqner=seqner, saider=saider, db=db, reger=reg) assert tev.prefixer.qb64 == vcp.pre assert tev.sn == 0 @@ -544,13 +546,14 @@ def test_tever_no_backers(mockHelpingNowUTC, mockCoringRandomNonce): vrt = eventing.rotate(regk, dig=vcp.said) rseal = keventing.SealEvent(regk, vrt.ked["s"], vrt.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) # should raise validation err because rotation is not supported with pytest.raises(ValidationError): - tev.update(serder=vrt, seqner=seqner, saider=diger) + tev.update(serder=vrt, seqner=seqner, saider=saider) vcdig = b'EEBp64Aw2rsjdJpAR0e2qCq3jX7q7gLld3LjAwZgaLXU' @@ -559,11 +562,12 @@ def test_tever_no_backers(mockHelpingNowUTC, mockCoringRandomNonce): # successfully anchor to a rotation event rseal = keventing.SealEvent(iss.ked["i"], iss.ked["s"], iss.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev.update(iss, seqner=seqner, saider=diger) + tev.update(iss, seqner=seqner, saider=saider) vci = vcdig dgkey = dgKey(pre=vci, dig=iss.said) @@ -579,11 +583,12 @@ def test_tever_no_backers(mockHelpingNowUTC, mockCoringRandomNonce): # successfully anchor to a rotation event rseal = keventing.SealEvent(rev.ked["i"], rev.ked["s"], rev.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev.update(rev, seqner=seqner, saider=diger) + tev.update(rev, seqner=seqner, saider=saider) dgkey = dgKey(pre=vci, dig=rev.said) assert bytes(reg.getTvt(dgkey)) == (b'{"v":"KERI10JSON000120_","t":"rev","d":"EGjtu2bIII28dwxA0BH8KeXCN03U7TN3SkLD' b'1KZi77pj","i":"EEBp64Aw2rsjdJpAR0e2qCq3jX7q7gLld3LjAwZgaLXU","s":"1","ri":"E' @@ -617,12 +622,13 @@ def test_tever_backers(mockHelpingNowUTC, mockCoringRandomNonce): rseal = keventing.SealEvent(i=regk, s=vcp.ked["s"], d=vcp.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev = Tever(serder=vcp, seqner=seqner, saider=diger, bigers=[valCigar], db=db, reger=reg) + tev = Tever(serder=vcp, seqner=seqner, saider=saider, bigers=[valCigar], db=db, reger=reg) dgkey = dgKey(pre=regk, dig=vcp.said) assert bytes(reg.getTvt(dgkey)) == (b'{"v":"KERI10JSON00013d_","t":"vcp","d":"EBgdJt_ASWeq7HjOmut2E8vQL8P1c9VTPDA0' @@ -651,11 +657,12 @@ def test_tever_backers(mockHelpingNowUTC, mockCoringRandomNonce): # successfully anchor to a rotation event rseal = keventing.SealEvent(regk, vrt.ked["s"], vrt.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev.update(serder=vrt, seqner=seqner, saider=diger, bigers=[valCigar, debCigar]) + tev.update(serder=vrt, seqner=seqner, saider=saider, bigers=[valCigar, debCigar]) assert tev.baks == ['BPmRWtx8nwSzRdJ0zTvP5uBb0t3BSjjstDk0gTayFfjV', 'BJLT5kDB54CewL9oqnWdPBC5vxZV30u3i6o9HVcWMhZd'] @@ -669,11 +676,12 @@ def test_tever_backers(mockHelpingNowUTC, mockCoringRandomNonce): # successfully anchor to a rotation event rseal = keventing.SealEvent(bis.ked["i"], bis.ked["s"], bis.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tev.update(bis, seqner=seqner, saider=diger, bigers=[valCigar, debCigar]) + tev.update(bis, seqner=seqner, saider=saider, bigers=[valCigar, debCigar]) vci = vcdig dgkey = dgKey(pre=vci, dig=bis.said) @@ -699,14 +707,15 @@ def test_tevery(): rseal = keventing.SealEvent(i=regk, s=vcp.ked["s"], d=vcp.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) tvy = Tevery(reger=reg, db=db) - tvy.processEvent(serder=vcp, seqner=seqner, saider=diger) + tvy.processEvent(serder=vcp, seqner=seqner, saider=saider) assert regk in tvy.tevers tev = tvy.tevers[regk] @@ -715,7 +724,7 @@ def test_tevery(): # send vcp again, get error with pytest.raises(LikelyDuplicitousError): - tvy.processEvent(serder=vcp, seqner=seqner, saider=diger) + tvy.processEvent(serder=vcp, seqner=seqner, saider=saider) # process issue vc event vcdig = b'EEBp64Aw2rsjdJpAR0e2qCq3jX7q7gLld3LjAwZgaLXU' @@ -725,11 +734,12 @@ def test_tevery(): # successfully anchor to a rotation event rseal = keventing.SealEvent(iss.ked["i"], iss.ked["s"], iss.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tvy.processEvent(serder=iss, seqner=seqner, saider=diger) + tvy.processEvent(serder=iss, seqner=seqner, saider=saider) status = tev.vcState(vcdig.decode("utf-8")) assert status.et == Ilks.iss assert status.s == '0' @@ -740,11 +750,12 @@ def test_tevery(): # successfully anchor to a rotation event rseal = keventing.SealEvent(rev.ked["i"], rev.ked["s"], rev.said) rot = hab.rotate(data=[rseal._asdict()]) - rotser = Serder(raw=rot) + rotser = serdering.SerderKERI(raw=rot) seqner = Seqner(sn=int(rotser.ked["s"], 16)) - diger = rotser.saider + #diger = rotser.saider + saider = Saider(qb64=rotser.said) - tvy.processEvent(serder=rev, seqner=seqner, saider=diger) + tvy.processEvent(serder=rev, seqner=seqner, saider=saider) status = tev.vcState(vcdig.decode("utf-8")) assert status.et == Ilks.rev assert status.s == '1'