From de7886b0bc0b296d35da36167ebaaad9f2179d52 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Thu, 11 Apr 2024 11:38:02 -0600 Subject: [PATCH] some refactoring change name of MapCodex to MapDom to be consistent for uses that are not Codexes fixed missing code entry for SealLast and updated references --- src/keri/core/coring.py | 6 +-- src/keri/core/counting.py | 39 ++++++++++++++-- src/keri/core/eventing.py | 12 ++--- src/keri/core/serdering.py | 29 +++++++++--- src/keri/core/signing.py | 21 +++++++++ src/keri/core/structing.py | 89 +++++++++++++++++++----------------- tests/core/test_coring.py | 6 +-- tests/core/test_counting.py | 28 +++++++++++- tests/core/test_serdering.py | 6 +-- tests/core/test_structing.py | 60 ++++++++++++++++++------ 10 files changed, 217 insertions(+), 79 deletions(-) diff --git a/src/keri/core/coring.py b/src/keri/core/coring.py index 599b948d7..f4cda654e 100644 --- a/src/keri/core/coring.py +++ b/src/keri/core/coring.py @@ -210,8 +210,8 @@ def randomNonce(): @dataclass -class MapDom: - """Base class for dataclasses that support map syntax +class MapHood: + """Base class for mutable dataclasses that support map syntax Adds support for dunder methods for map syntax dc[name]. Converts exceptions from attribute syntax to raise map syntax when using map syntax. @@ -241,7 +241,7 @@ def __delitem__(self, name): @dataclass(frozen=True) -class MapCodex: +class MapDom: """Base class for frozen dataclasses (codexes) that support map syntax Adds support for dunder methods for map syntax dc[name]. Converts exceptions from attribute syntax to raise map syntax when using diff --git a/src/keri/core/counting.py b/src/keri/core/counting.py index 62ea757ca..a79cf6a28 100644 --- a/src/keri/core/counting.py +++ b/src/keri/core/counting.py @@ -16,7 +16,7 @@ from .. import kering from ..kering import (Versionage, Vrsn_1_0, Vrsn_2_0) -from ..core.coring import Sizage, MapCodex +from ..core.coring import Sizage, MapDom @@ -45,7 +45,7 @@ def __iter__(self): @dataclass(frozen=True) -class CounterCodex_1_0(MapCodex): +class CounterCodex_1_0(MapDom): """ CounterCodex is codex hard (stable) part of all counter derivation codes. Only provide defined codes. @@ -77,7 +77,7 @@ def __iter__(self): CtrDex_1_0 = CounterCodex_1_0() @dataclass(frozen=True) -class CounterCodex_2_0(MapCodex): +class CounterCodex_2_0(MapDom): """ CounterCodex is codex hard (stable) part of all counter derivation codes. Only provide defined codes. @@ -134,6 +134,8 @@ class CounterCodex_2_0(MapCodex): BigMerkleRootSealSingles: str = '-0W' # Merkle Tree Root Digest Seal Single(s), dig of sealed data. BackerRegistrarSealCouples: str = '-X' # Backer Registrar Seal Couple(s), brid+dig of sealed data. BigBackerRegistrarSealCouples: str = '-0X' # Big Backer Registrar Seal Couple(s), brid+dig of sealed data. + SealSourceLastSingles: str = '-Y' # Seal Source Couple(s), pre of last source sealing or sealed event. + BigSealSourceLastSingles: str = '-0Y' # Big Seal Source Couple(s), pre of last source sealing or sealed event. ESSRPayloadGroup: str = '-Z' # ESSR Payload Group. BigESSRPayloadGroup: str = '-0Z' # Big ESSR Payload Group. KERIACDCGenusVersion: str = '--AAA' # KERI ACDC Stack CESR Protocol Genus Version (Universal) @@ -157,6 +159,35 @@ def __iter__(self): AllTags = AllTagage() # uses defaults +@dataclass(frozen=True) +class SealCodex_2_0(MapDom): + """ + SealCodex_2_0 is codex of seal counter derivation codes. + Only provide defined codes. + Undefined are left out so that inclusion(exclusion) via 'in' operator works. + + As subclass of MapCodex can get codes with item syntax using tag variables. + Example: codex[tag] + """ + SealSourceCouples: str = '-Q' # Seal Source Couple(s), snu+dig of source sealing or sealed event. + BigSealSourceCouples: str = '-0Q' # Seal Source Couple(s), snu+dig of source sealing or sealed event. + SealSourceTriples: str = '-R' # Seal Source Triple(s), pre+snu+dig of source sealing or sealed event. + BigSealSourceTriples: str = '-0R' # Seal Source Triple(s), pre+snu+dig of source sealing or sealed event. + DigestSealSingles: str = '-V' # Digest Seal Single(s), dig of sealed data. + BigDigestSealSingles: str = '-0V' # Big Digest Seal Single(s), dig of sealed data. + MerkleRootSealSingles: str = '-W' # Merkle Tree Root Digest Seal Single(s), dig of sealed data. + BigMerkleRootSealSingles: str = '-0W' # Merkle Tree Root Digest Seal Single(s), dig of sealed data. + BackerRegistrarSealCouples: str = '-X' # Backer Registrar Seal Couple(s), brid+dig of sealed data. + BigBackerRegistrarSealCouples: str = '-0X' # Big Backer Registrar Seal Couple(s), brid+dig of sealed data. + SealSourceLastSingles: str = '-Y' # Seal Source Couple(s), pre of last source sealing event. + BigSealSourceLastSingles: str = '-0Y' # Big Seal Source Couple(s), pre of last source sealing event. + + def __iter__(self): + return iter(astuple(self)) # enables value not key inclusion test with "in" + +SealDex_2_0 = SealCodex_2_0() + + class Counter: """ Counter is fully qualified cryptographic material primitive base class for @@ -373,6 +404,8 @@ class Counter: '-0X': Sizage(hs=3, ss=5, fs=8, ls=0), '-Y': Sizage(hs=2, ss=2, fs=4, ls=0), '-0Y': Sizage(hs=3, ss=5, fs=8, ls=0), + '-Z': Sizage(hs=2, ss=2, fs=4, ls=0), + '-0Z': Sizage(hs=3, ss=5, fs=8, ls=0), '--AAA': Sizage(hs=5, ss=3, fs=8, ls=0), }, }, diff --git a/src/keri/core/eventing.py b/src/keri/core/eventing.py index 772fd03ab..0a4bd9535 100644 --- a/src/keri/core/eventing.py +++ b/src/keri/core/eventing.py @@ -76,12 +76,6 @@ # d = digest qb64 of backer metadata anchored to event usually SAID of data SealBacker = namedtuple("SealBacker", 'bi d') -# Event Seal: triple (i, s, d) -# i = pre is qb64 of identifier prefix of KEL for event, -# s = sn of event as lowercase hex string no leading zeros, -# d = SAID digest qb64 of event -SealEvent = namedtuple("SealEvent", 'i s d') - # Last Estalishment Event Seal: uniple (i,) # i = pre is qb64 of identifier prefix of KEL from which to get last est, event # used to indicate to get the latest keys available from KEL for 'i' @@ -95,6 +89,12 @@ # use SealSourceCouples count code for attachment SealTrans = namedtuple("SealTrans", 's d') +# Event Seal: triple (i, s, d) +# i = pre is qb64 of identifier prefix of KEL for event, +# s = sn of event as lowercase hex string no leading zeros, +# d = SAID digest qb64 of event +SealEvent = namedtuple("SealEvent", 'i s d') + # Following are not seals only used in database # State Establishment Event (latest current) : quadruple (s, d, br, ba) diff --git a/src/keri/core/serdering.py b/src/keri/core/serdering.py index 5b211b404..07b6e5c72 100644 --- a/src/keri/core/serdering.py +++ b/src/keri/core/serdering.py @@ -38,9 +38,9 @@ from .coring import (Matter, Saider, Verfer, Diger, Number, Tholder, Tagger, Ilker, Traitor, Verser, ) -from .counting import GenDex, AllTags, Counter +from .counting import GenDex, AllTags, Counter, SealDex_2_0 -from .structing import Sealer +from .structing import Sealer, ClanDom @@ -347,8 +347,10 @@ class Serder: # Spans dict keyed by version (Versionage instance) of version string span (size) Spans = {Vrsn_1_0: VER1FULLSPAN, Vrsn_2_0: VER2FULLSPAN} - # should be same set of codes as in coring.DigestCodex coring.DigDex so - # .digestive property works. Use unit tests to ensure codex sets match + # Maps digest codes to Digestages of algorithms for computing digest. + # Should be based on the same set of codes as in coring.DigestCodex + # coring.DigDex so .digestive property works. + # Use unit tests to ensure codex elements sets match Digests = { DigDex.Blake3_256: Digestage(klas=blake3.blake3, size=None, length=None), DigDex.Blake2b_256: Digestage(klas=hashlib.blake2b, size=32, length=None), @@ -361,6 +363,18 @@ class Serder: DigDex.SHA2_512: Digestage(klas=hashlib.sha512, size=None, length=None), } + # map seal clan names to seal counter code for grouping seals in anchor list + ClanSeals = dict() + ClanSeals[ClanDom.SealDigest.__name__] = SealDex_2_0.DigestSealSingles + ClanSeals[ClanDom.SealRoot.__name__] = SealDex_2_0.MerkleRootSealSingles + ClanSeals[ClanDom.SealBacker.__name__] = SealDex_2_0.BackerRegistrarSealCouples + ClanSeals[ClanDom.SealLast.__name__] = SealDex_2_0.SealSourceLastSingles + ClanSeals[ClanDom.SealTrans.__name__] = SealDex_2_0.SealSourceCouples + ClanSeals[ClanDom.SealEvent.__name__] = SealDex_2_0.SealSourceTriples + + # map seal counter code to seal clan name for parsing seal groups in anchor list + SealClans = {} + #override in subclass to enforce specific protocol Protocol = None # class based message protocol, None means any in Protocols is ok Proto = Protocols.keri # default message protocol type for makify on base Serder @@ -1284,14 +1298,17 @@ def _dumps(self, sad): case "a": # list of seals or field map of attributes frame = bytearray() for e in v: # list of seal dicts + # need support for grouping consecutive seals of same type with same counter + try: sealer = Sealer(crew=e) frame.extend(sealer.qb64b) + # lookup counter type by sealer.clan.name except kering.InvalidValueError: pass #unknown seal type so serialize as field map - pass + #if tuple(v) == eventing.SealEvent._fields: #eseal = eventing.SealEvent(**v) # convert to namedtuple #SealSourceCouples: str = '-Q' # Seal Source Couple(s), snu+dig of source sealing or sealed event. @@ -1305,7 +1322,7 @@ def _dumps(self, sad): #tuple(d) #('a', 'b') - #frame.extend(Anchor(seal=e).qb64b) + #frame.extend(Sealer(seal=e).qb64b) # else: generic seal no count type (v, Mapping): #for l, e in v.items(): #pass diff --git a/src/keri/core/signing.py b/src/keri/core/signing.py index f3571016f..f956a4d02 100644 --- a/src/keri/core/signing.py +++ b/src/keri/core/signing.py @@ -364,6 +364,27 @@ class Salter(Matter): Salter is Matter subclass to maintain random salt for secrets (private keys) Its .raw is random salt, .code as cipher suite for salt + To initialize with deterministic salt pass in 16 bytes for raw: + salter = Salter(raw=b'0123456789abcdef') + + To create a deterministic secret, seed, or private key from salt + call .signer: + signer = salter.signer(code=MtrDex.Ed25519_Seed, + transferable=True, + path="", + tier=None, + temp=False) + + To create a deterministic set of secrets or seeds or private keys from salt + call signers: + signers = salter.signers(count=1, + start=0, + path="", + code=MtrDex.Ed25519_Seed, + transferable=True, + tier=None, + temp=False) + Attributes: .level is str security level code. Provides default level diff --git a/src/keri/core/structing.py b/src/keri/core/structing.py index 5c1a77176..cb7e1fea8 100644 --- a/src/keri/core/structing.py +++ b/src/keri/core/structing.py @@ -17,7 +17,7 @@ from ..help import nonStringSequence from . import coring -from .coring import (MapCodex, Matter, Diger, Prefixer, Number) +from .coring import (MapDom, Matter, Diger, Prefixer, Number) # ToDo Change seal namedtuple definitions to NamedTuple subclasses so can @@ -48,12 +48,6 @@ # d = digest qb64 of backer metadata anchored to event usually SAID of data SealBacker = namedtuple("SealBacker", 'bi d') -# Event Seal: triple (i, s, d) -# i = pre is qb64 of identifier prefix of KEL for event, -# s = sn of event as lowercase hex string no leading zeros, -# d = SAID digest qb64 of event -SealEvent = namedtuple("SealEvent", 'i s d') - # Last Establishment Event Seal: uniple (i,) # i = pre is qb64 of identifier prefix of KEL from which to get last est, event # used to indicate to get the latest keys available from KEL for 'i' @@ -67,6 +61,12 @@ # use SealSourceCouples count code for attachment SealTrans = namedtuple("SealTrans", 's d') +# Event Seal: triple (i, s, d) +# i = pre is qb64 of identifier prefix of KEL for event, +# s = sn of event as lowercase hex string no leading zeros, +# d = SAID digest qb64 of event +SealEvent = namedtuple("SealEvent", 'i s d') + # Following are not seals only used in database @@ -86,7 +86,7 @@ @dataclass(frozen=True) -class EmptyClanCodex(MapCodex): +class EmptyClanCodex(MapDom): """ SealClanDom is dataclass of namedtuple seal class references (clans) each indexed by its class name. @@ -107,7 +107,7 @@ def __iter__(self): @dataclass(frozen=True) -class EmptyCastCodex(MapCodex): +class EmptyCastCodex(MapDom): """ SealCastCodex is dataclass of namedtuple instances (seal casts) whose values are named primitive class references @@ -130,9 +130,9 @@ def __iter__(self): @dataclass(frozen=True) -class SealClanCodex(MapCodex): +class SealClanDom(MapDom): """ - SealClanCodex is dataclass of namedtuple seal class references (clans) each + SealClanDom is dataclass of namedtuple seal class references (clans) each indexed by its class name. Only provide defined classes. @@ -141,25 +141,25 @@ class SealClanCodex(MapCodex): As subclass of MapCodex can get class reference with item syntax using name variables. - Example: SealClanDex[name] + Example: ClanDom[name] """ SealDigest: type[NamedTuple] = SealDigest # SealDigest class reference SealRoot: type[NamedTuple] = SealRoot # SealRoot class reference SealBacker: type[NamedTuple] = SealBacker # SealBacker class reference - SealEvent: type[NamedTuple] = SealEvent # SealEvent class reference - SealLast: type[NamedTuple] = SealLast # SealLast class reference - SealTrans: type[NamedTuple] = SealTrans # SealTrans class reference + SealLast: type[NamedTuple] = SealLast # SealLast class reference single + SealTrans: type[NamedTuple] = SealTrans # SealTrans class reference couple + SealEvent: type[NamedTuple] = SealEvent # SealEvent class reference triple def __iter__(self): return iter(astuple(self)) # enables value not key inclusion test with "in" -SealClanDex = SealClanCodex() # create instance +ClanDom = SealClanDom() # create instance @dataclass(frozen=True) -class SealCastCodex(MapCodex): +class SealCastDom(MapDom): """ - SealCastCodex is dataclass of namedtuple instances (seal casts) whose values + SealCastDom is dataclass of namedtuple instances (seal casts) whose values are named primitive class references indexed by its namedtuple class name. @@ -170,19 +170,19 @@ class SealCastCodex(MapCodex): As subclass of MapCodex can get namedtuple instance with item syntax using name variables. - Example: SealCastDom[name] + Example: CastDom[name] """ SealDigest: NamedTuple = SealDigest(d=Diger) # SealDigest class reference SealRoot: NamedTuple = SealRoot(rd=Diger) # SealRoot class reference SealBacker: NamedTuple = SealBacker(bi=Prefixer, d=Diger) # SealBacker class reference - SealEvent: NamedTuple = SealEvent(i=Prefixer, s=Number, d=Diger) # SealEvent class reference - SealLast: NamedTuple = SealLast(i=Prefixer) # SealLast class reference - SealTrans: NamedTuple = SealTrans(s=Number, d=Diger) # SealTrans class reference + SealLast: NamedTuple = SealLast(i=Prefixer) # SealLast class reference single + SealTrans: NamedTuple = SealTrans(s=Number, d=Diger) # SealTrans class reference couple + SealEvent: NamedTuple = SealEvent(i=Prefixer, s=Number, d=Diger) # SealEvent class reference triple def __iter__(self): return iter(astuple(self)) # enables value not key inclusion test with "in" -SealCastDex = SealCastCodex() # create instance +CastDom = SealCastDom() # create instance @@ -254,9 +254,10 @@ class Structor: """ Clans = EmptyClanDex # known namedtuple clans. Override in subclass with non-empty Casts = EmptyCastDex # known namedtuple casts. Override in subclass with non-empty - # Create .Names dict that maps clan/cast fields names to its namedtuple - # class type name so can look up a know clan or cast given a matching set - # of either field names from a namedtuple or keys from a dict. + # Create .Names dict that maps tuple of clan/cast fields names to its namedtuple + # class type name so can look up a know clan or cast given a matching tuple + # of either field names from a namedtuple or keys from a dict. The tuple of + # field names is a mark of the structor type. Maps mark to class name. Names = {tuple(clan._fields): clan.__name__ for clan in Clans} @@ -308,22 +309,22 @@ def __init__(self, data=None, *, clan=None, cast=None, crew=None, clan = crew.__class__ if not clan and isinstance(cast, Mapping): # get clan from cast - names = tuple(cast) # create custom clan based on cast - if (cname := self.Names.get(names)): # get known else None + mark = tuple(cast) # create custom clan based on cast mark + if (cname := self.Names.get(mark)): # get known else None clan = self.Clans[cname] cast = self.Casts[cname] else: # create custom clan from cast - clan = namedtuple("_".join(names), names) # custom clan + clan = namedtuple("_".join(mark), mark) # custom clan if not clan and isinstance(crew, Mapping): # get clan from crew - names = tuple(crew) # create custom clan based on cast - if (cname := self.Names.get(names)): # get known else None + mark = tuple(crew) # create custom clan based on crew mark + if (cname := self.Names.get(mark)): # get known else None clan = self.Clans[cname] cast = self.Casts[cname] else: # create custom clan from crew - clan = namedtuple("_".join(names), names) # custom clan from cast keys + clan = namedtuple("_".join(mark), mark) # custom clan from cast keys if clan: if not (issubclass(clan, tuple) and hasattr(clan, "_fields")): @@ -335,17 +336,15 @@ def __init__(self, data=None, *, clan=None, cast=None, crew=None, if cast: if not isinstance(cast, clan): if isinstance(cast, tuple) and hasattr(cast, "_fields"): - if cast._fields != clan._fields: + if cast._fields != clan._fields: # fields is mark raise InvalidValueError(f"Mismatching fields clan=" f"{clan._fields} and cast=" f"{cast._fields}.") cast = clan(**cast._asdict()) # convert to clan - - elif isinstance(cast, Mapping): - if tuple(cast) != clan._fields: + if tuple(cast) != clan._fields: # fields is mark raise InvalidValueError(f"Mismatching fields clan=" f"{clan._fields} and keys cast=" f"{tuple(cast)}.") @@ -359,7 +358,7 @@ def __init__(self, data=None, *, clan=None, cast=None, crew=None, raise InvalidValueError(f"Invalid {cast=}.") else: # get cast from known .Casts if possible - if (cname := self.Names.get(clan._fields)): + if (cname := self.Names.get(clan._fields)): # fields is mark cast = self.Casts[cname] # get known cast else: # cast missing or unobtainable raise InvalidValueError(f"Missing or unobtainable cast.") @@ -374,7 +373,7 @@ def __init__(self, data=None, *, clan=None, cast=None, crew=None, if crew: if not isinstance(crew, clan): if isinstance(crew, tuple) and hasattr(crew, "_fields"): - if crew._fields != clan._fields: + if crew._fields != clan._fields: # fields is mark raise InvalidValueError(f"Mismatching fields clan=" f"{clan._fields} and crew=" f"{crew._fields}.") @@ -382,7 +381,7 @@ def __init__(self, data=None, *, clan=None, cast=None, crew=None, crew = clan(**crew._asdict()) # convert to clan elif isinstance(crew, Mapping): - if tuple(crew) != clan._fields: + if tuple(crew) != clan._fields: # fields is mark raise InvalidValueError(f"Mismatching fields clan=" f"{clan._fields} and keys crew=" f"{tuple(crew)}.") @@ -458,6 +457,14 @@ def clan(self): """ return self.data.__class__ + @property + def name(self): + """Returns: + name (str): name of class of .data + + """ + return self.data.__class__.__name__ + @property def cast(self): """Return: @@ -556,8 +563,8 @@ class Sealer(Structor): """ - Clans = SealClanDex # known namedtuple clans. Override in subclass with non-empty - Casts = SealCastDex # known namedtuple casts. Override in subclass with non-empty + Clans = ClanDom # known namedtuple clans. Override in subclass with non-empty + Casts = CastDom # known namedtuple casts. Override in subclass with non-empty # Create .Names dict that maps clan/cast fields names to its namedtuple # class type name so can look up a know clan or cast given a matching set # of either field names from a namedtuple or keys from a dict. diff --git a/tests/core/test_coring.py b/tests/core/test_coring.py index f6ebf78b1..e2c49c800 100644 --- a/tests/core/test_coring.py +++ b/tests/core/test_coring.py @@ -52,7 +52,7 @@ IdxCrtSigDex, IdxBthSigDex, Indexer) -from keri.core.coring import MapDom, MapCodex +from keri.core.coring import MapHood, MapDom @@ -60,7 +60,7 @@ def test_mapdom(): """Test MapDom base dataclass""" @dataclass - class TestMapDom(MapDom): + class TestMapDom(MapHood): """ """ @@ -151,7 +151,7 @@ def test_mapcodex(): @dataclass(frozen=True) - class TestMapCodex(MapCodex): + class TestMapCodex(MapDom): """ """ diff --git a/tests/core/test_counting.py b/tests/core/test_counting.py index da1c21aeb..39534f68d 100644 --- a/tests/core/test_counting.py +++ b/tests/core/test_counting.py @@ -21,7 +21,7 @@ from keri.core import counting -from keri.core.counting import GenDex, Sizage, MapCodex, Counter +from keri.core.counting import GenDex, Sizage, MapDom, Counter from keri.core.counting import Versionage, Vrsn_1_0, Vrsn_2_0, AllTags @@ -130,6 +130,8 @@ def test_codexes_tags(): 'BigMerkleRootSealSingles': '-0W', 'BackerRegistrarSealCouples': '-X', 'BigBackerRegistrarSealCouples': '-0X', + 'SealSourceLastSingles': '-Y', + 'BigSealSourceLastSingles': '-0Y', 'ESSRPayloadGroup': '-Z', 'BigESSRPayloadGroup': '-0Z', 'KERIACDCGenusVersion': '--AAA' @@ -206,6 +208,8 @@ def test_codexes_tags(): 'BigMerkleRootSealSingles': 'BigMerkleRootSealSingles', 'BackerRegistrarSealCouples': 'BackerRegistrarSealCouples', 'BigBackerRegistrarSealCouples': 'BigBackerRegistrarSealCouples', + 'SealSourceLastSingles': 'SealSourceLastSingles', + 'BigSealSourceLastSingles': 'BigSealSourceLastSingles', 'ESSRPayloadGroup': 'ESSRPayloadGroup', 'BigESSRPayloadGroup': 'BigESSRPayloadGroup', 'KERIACDCGenusVersion': 'KERIACDCGenusVersion' @@ -263,6 +267,8 @@ def test_codexes_tags(): 'BigMerkleRootSealSingles': 'BigMerkleRootSealSingles', 'BackerRegistrarSealCouples': 'BackerRegistrarSealCouples', 'BigBackerRegistrarSealCouples': 'BigBackerRegistrarSealCouples', + 'SealSourceLastSingles': 'SealSourceLastSingles', + 'BigSealSourceLastSingles': 'BigSealSourceLastSingles', 'ESSRPayloadGroup': 'ESSRPayloadGroup', 'BigESSRPayloadGroup': 'BigESSRPayloadGroup', 'KERIACDCGenusVersion': 'KERIACDCGenusVersion' @@ -270,6 +276,24 @@ def test_codexes_tags(): assert counting.AllTags.ControllerIdxSigs == 'ControllerIdxSigs' + assert asdict(counting.SealDex_2_0) == \ + { + 'SealSourceCouples': '-Q', + 'BigSealSourceCouples': '-0Q', + 'SealSourceTriples': '-R', + 'BigSealSourceTriples': '-0R', + 'DigestSealSingles': '-V', + 'BigDigestSealSingles': '-0V', + 'MerkleRootSealSingles': '-W', + 'BigMerkleRootSealSingles': '-0W', + 'BackerRegistrarSealCouples': '-X', + 'BigBackerRegistrarSealCouples': '-0X', + 'SealSourceLastSingles': '-Y', + 'BigSealSourceLastSingles': '-0Y', + } + + + """End Test""" @@ -388,6 +412,8 @@ def test_counter_class(): '-0X': Sizage(hs=3, ss=5, fs=8, ls=0), '-Y': Sizage(hs=2, ss=2, fs=4, ls=0), '-0Y': Sizage(hs=3, ss=5, fs=8, ls=0), + '-Z': Sizage(hs=2, ss=2, fs=4, ls=0), + '-0Z': Sizage(hs=3, ss=5, fs=8, ls=0), '--AAA': Sizage(hs=5, ss=3, fs=8, ls=0) }, }, diff --git a/tests/core/test_serdering.py b/tests/core/test_serdering.py index 31583a84f..472eee39b 100644 --- a/tests/core/test_serdering.py +++ b/tests/core/test_serdering.py @@ -2649,11 +2649,11 @@ def test_cesr_native_dumps(): raw = b'\x05\xaa\x8f-S\x9a\xe9\xfaU\x9c\x02\x9c\x9b\x08Hu' salter = core.Salter(raw=raw) - # replace with Salter.signers() - csigners = core.generateSigners(raw=salter.raw, count=3) - wsigners = core.generateSigners(raw=salter.raw, count=3, transferable=False) + csigners = salter.signers(count=3, transferable=True, temp=True) + wsigners = salter.signers(count=3, transferable=False, temp=True) + keys = [csigners[0].qb64] keys = ["EDGnGYIa5obfFUhxcAuUmM4fJyeRYj2ti3KGf87Bc70J"] serder = incept(keys, version=Vrsn_2_0) diff --git a/tests/core/test_structing.py b/tests/core/test_structing.py index a2ade17b8..b34cd6d0d 100644 --- a/tests/core/test_structing.py +++ b/tests/core/test_structing.py @@ -23,7 +23,7 @@ from keri.core.structing import (SealDigest, SealRoot, SealBacker, SealEvent, SealLast, SealTrans) from keri.core.structing import (Structor, EmptyClanDex, EmptyCastDex, - Sealer, SealClanDex, SealCastDex, ) + Sealer, ClanDom, CastDom, ) def test_structor_class(): @@ -59,6 +59,7 @@ def test_structor(): clan = SealDigest cast = SealDigest(d=Diger) crew = SealDigest(d=dig) + name = SealDigest.__name__ dcast = cast._asdict() dcrew = crew._asdict() @@ -76,6 +77,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.asdict == data._asdict() assert structor.asdict == {'d': diger} assert structor.qb64 == qb64 @@ -87,6 +89,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -95,6 +98,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -103,6 +107,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -111,6 +116,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -120,6 +126,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -129,6 +136,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -137,6 +145,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -146,6 +155,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -156,6 +166,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -164,6 +175,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -172,6 +184,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -180,6 +193,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -189,6 +203,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -198,6 +213,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -206,6 +222,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -214,7 +231,7 @@ def test_structor(): structor = Structor(cast=dcast, crew=dcrew) assert structor.data.__class__.__name__ == "d" assert structor.clan != clan - assert structor.clan.__name__ == "d" + assert structor.name == "d" assert structor.cast == cast # tuple compare is by field value not type assert structor.cast.__class__.__name__ == "d" assert structor.crew == crew @@ -229,6 +246,7 @@ def test_structor(): clan = SealEvent cast = SealEvent(i=Prefixer, s=Number, d=Diger) crew = SealEvent(i=aid, s=snq, d=dig) + name = SealEvent.__name__ dcast = cast._asdict() dcrew = crew._asdict() @@ -246,6 +264,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.asdict == data._asdict() assert structor.asdict == \ { @@ -262,6 +281,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -270,6 +290,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -278,6 +299,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -286,6 +308,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -295,6 +318,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -304,6 +328,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -312,6 +337,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -321,6 +347,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -331,6 +358,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -339,6 +367,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -347,6 +376,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -355,6 +385,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -365,6 +396,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -375,6 +407,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -383,6 +416,7 @@ def test_structor(): assert structor.clan == clan assert structor.cast == cast assert structor.crew == crew + assert structor.name == name assert structor.qb64 == qb64 assert structor.qb64b == qb64.encode() assert structor.qb2 == qb2 @@ -391,7 +425,7 @@ def test_structor(): structor = Structor(cast=dcast, crew=dcrew) assert structor.data.__class__.__name__ == "i_s_d" assert structor.clan != clan - assert structor.clan.__name__ == "i_s_d" + assert structor.name == "i_s_d" assert structor.cast == cast # tuple compare is by field value not type assert structor.cast.__class__.__name__ == "i_s_d" assert structor.crew == crew @@ -413,40 +447,40 @@ def test_seal_dexes(): test Seal Codexes """ - assert asdict(SealClanDex) == \ + assert asdict(ClanDom) == \ { 'SealDigest': SealDigest, 'SealRoot': SealRoot, 'SealBacker': SealBacker, - 'SealEvent': SealEvent, 'SealLast': SealLast, - 'SealTrans': SealTrans + 'SealTrans': SealTrans, + 'SealEvent': SealEvent, } - assert asdict(SealCastDex) == \ + assert asdict(CastDom) == \ { 'SealDigest': SealDigest(d=Diger), 'SealRoot': SealRoot(rd=Diger), 'SealBacker': SealBacker(bi=Prefixer, d=Diger), - 'SealEvent': SealEvent(i=Prefixer, s=Number, d=Diger), 'SealLast': SealLast(i=Prefixer), - 'SealTrans': SealTrans(s=Number, d=Diger) + 'SealTrans': SealTrans(s=Number, d=Diger), + 'SealEvent': SealEvent(i=Prefixer, s=Number, d=Diger), } def test_sealer_class(): """ test sealer class variables etc """ - assert Sealer.Clans == SealClanDex - assert Sealer.Casts == SealCastDex + assert Sealer.Clans == ClanDom + assert Sealer.Casts == CastDom assert Sealer.Names == \ { ('d',): 'SealDigest', ('rd',): 'SealRoot', ('bi', 'd'): 'SealBacker', - ('i', 's', 'd'): 'SealEvent', ('i',): 'SealLast', - ('s', 'd'): 'SealTrans' + ('s', 'd'): 'SealTrans', + ('i', 's', 'd'): 'SealEvent', } """End Test"""