Skip to content

Commit

Permalink
Merge pull request #494 from SmithSamuelM/dev
Browse files Browse the repository at this point in the history
Add genera for ACDC to ProDex
  • Loading branch information
SmithSamuelM committed May 6, 2023
2 parents 79ee4a2 + d197756 commit ffc2172
Show file tree
Hide file tree
Showing 5 changed files with 539 additions and 174 deletions.
60 changes: 8 additions & 52 deletions src/keri/core/coring.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# "{:0{}x}".format(300, 6) # make num char in hex a variable
# '00012c'
VERFMT = "{}{:x}{:x}{}{:0{}x}_" # version format string
VERFULLSIZE = 17 # number of characters in full versions string
VERFULLSIZE = 17 # number of characters in full version string


def versify(proto=Protos.keri, version=None, kind=Serials.json, size=0):
Expand Down Expand Up @@ -4236,16 +4236,19 @@ def __iter__(self):

@dataclass(frozen=True)
class ProtocolGenusCodex:
"""ProtocolGenusCodex is codex of protocol genera.
"""ProtocolGenusCodex is codex of protocol genera for code table.
Only provide defined codes.
Undefined are left out so that inclusion(exclusion) via 'in' operator works.
"""
KERI: str = '--AAA' # KERI ACDC Protocol Stack
KERI: str = '--AAA' # KERI and ACDC Protocol Stacks share the same tables
ACDC: str = '--AAA' # KERI and ACDC Protocol Stacks share the same tables


def __iter__(self):
return iter(astuple(self))
return iter(astuple(self)) # enables inclusion test with "in"
# duplicate values above just result in multiple entries in tuple so
# in inclusion still works

ProDex = ProtocolGenusCodex() # Make instance

Expand Down Expand Up @@ -4719,6 +4722,7 @@ def __init__(self, raw=b'', ked=None, sad=None, kind=None, saidify=False,
else:
raise ValueError("Improper initialization need sad, raw or ked.")


def _clone(self, sad):
""" copy hidden attributes from sad """
self._raw = sad.raw
Expand Down Expand Up @@ -4801,54 +4805,6 @@ def compare(self, said=None):
raise ValueError("Both said and saider may not be None.")


#def verify(self, prefixed=False, versioned=True, code=None,
#kind=None, label=Saids.d, ignore=None, **kwa):
#"""
#ToDo: Make Sad verifiable against its own said field

#Returns:
#result (bool): True means derivation from sad with dummy label
#field value replacement for ._code matches .qb64. False otherwise
#If prefixed is True then also validates that label field of
#provided sad also matches .qb64. False otherwise
#If versioned is True and provided sad includes version field 'v'
#then also validates that version field 'v' of provided
#sad matches the version field of modified sad that results from
#the derivation process. The size chars in the version field
#are set to the size of the sad during derivation. False otherwise.

#Parameters:
#sad (dict): self addressed data to be serialized
#prefixed (bool): True means also verify if labeled field in
#sad matches own .qb64
#versioned (bool):
#code (str): digest type code from DigDex.
#kind (str): serialization algorithm of sad, one of Serials
#used to override that given by 'v' field if any in sad
#otherwise default is Serials.json
#label (str): Saidage value of said field label in which to inject dummy
#ignore (list): fields to ignore when generating SAID
#"""
#try:
## override ensure code is self.code
#raw, dsad = self._derive(sad=sad, code=self.code, kind=kind, label=label, ignore=ignore)
#saider = Saider(raw=raw, code=self.code, ignore=ignore, **kwa)
#if self.qb64b != saider.qb64b:
#return False # not match .qb64b

#if 'v' in sad and versioned:
#if sad['v'] != dsad['v']:
#return False # version fields not match

#if prefixed and sad[label] != self.qb64: # check label field
#return False # label id field not match .qb64

#except Exception as ex:
#return False

#return True


@property
def raw(self):
""" raw property getter """
Expand Down
2 changes: 1 addition & 1 deletion src/keri/end/ending.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def designature(value):

if "indexed" not in items:
raise ValueError("Missing indexed field in Signature header signage.")
indexed = items["indexed"] not in kering.FALSY # make bool
indexed = items["indexed"] not in kering.FALSEY # make bool
del items["indexed"]

if "signer" in items:
Expand Down
2 changes: 1 addition & 1 deletion src/keri/kering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import namedtuple


FALSY = (False, 0, "?0", "no", "false", "False", "off")
FALSEY = (False, 0, None, "?0", "no", "false", "False", "off")
TRUTHY = (True, 1, "?1", "yes" "true", "True", 'on')

Versionage = namedtuple("Versionage", "major minor")
Expand Down
23 changes: 14 additions & 9 deletions src/keri/vc/proving.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ def credential(schema,
rules=None,
version=Version,
kind=Serials.json):
""" Returns Credentialer of new credential
"""Utility function to create an ACDC. Creates dict SAD for credential from
parameters and Saidifyies it before creation.
Returns:
Creder: of new credential
Creates SAD for credential and Saidifyies it before creation.
Parameters:
schema (SAID): of schema for this credential
Expand All @@ -42,7 +45,7 @@ def credential(schema,
data (dict): of the values being assigned to the subject of this credential
private (bool): apply nonce used for privacy preserving ACDC
salt (string): salt for nonce
source (Optional[dict,list]): of source credentials to which this credential is chained
source (dict | list): of source credentials to which this credential is chained
rules (list): ACDC rules section for credential
version (Version): version instance
kind (Serials): serialization kind
Expand Down Expand Up @@ -132,14 +135,16 @@ class Creder(coring.Sadder):
"""

def __init__(self, raw=b'', ked=None, kind=None, sad=None, code=coring.MtrDex.Blake3_256):
""" Creates a serializer/deserializer for a ACDC Verifiable Credential in CESR Proof Format
""" Creates a serializer/deserializer for a ACDC Verifiable Credential
in CESR Proof Format
Requires either raw or (crd and kind) to load credential from serialized form or in memory
Requires either raw or (crd and kind) to load credential from serialized
form or in memory
Parameters:
raw (bytes): is raw credential
ked (dict): is populated credential
kind (is serialization kind
raw (bytes): raw credential
ked (dict): populated credential
kind (str): serialization kind
sad (Sadder): is clonable base class
code (MtrDex): is hashing codex
Expand All @@ -151,7 +156,7 @@ def __init__(self, raw=b'', ked=None, kind=None, sad=None, code=coring.MtrDex.Bl

@property
def crd(self):
""" issuer property getter"""
""" crd property getter"""
return self._ked

@property
Expand Down

0 comments on commit ffc2172

Please sign in to comment.