Skip to content

Commit

Permalink
fix doc strings comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SmithSamuelM committed Aug 3, 2024
1 parent ce3c235 commit 2918f86
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,13 +1321,13 @@ def sign(self, ser, verfers=None, indexed=True, indices=None, ondices=None, **kw
ondices=ondices)

def decrypt(self, ser, verfers=None, **kwa):
"""Sign given serialization ser using appropriate keys.
"""Decrypt given serialization ser using appropriate keys.
Use provided verfers or .kever.verfers to lookup keys to sign.
Parameters:
ser (bytes): serialization to sign
ser (bytes): serialization to decrypt
verfers (list[Verfer] | None): Verfer instances to get pub verifier
keys to lookup private siging keys.
keys to lookup and convert to private decryption keys.
verfers None means use .kever.verfers. Assumes that when group
and verfers is not None then provided verfers must be .kever.verfers
Expand Down
7 changes: 4 additions & 3 deletions src/keri/app/keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,18 +1394,19 @@ def sign(self, ser, pubs=None, verfers=None, indexed=True,
cigars.append(signer.sign(ser)) # assigns .verfer to cigar
return cigars


def decrypt(self, ser, pubs=None, verfers=None):
"""
Returns list of signatures of ser if indexed as Sigers else as Cigars with
.verfer assigned.
Returns plain text of decrypted serialization
Parameters:
ser (bytes): serialization to sign
pubs (list[str] | None): of qb64 public keys to lookup private keys
one of pubs or verfers is required. If both then verfers is ignored.
verfers (list[Verfer] | None): Verfer instances of public keys
one of pubs or verfers is required. If both then verfers is ignored.
If not pubs then gets public key from verfer.qb64
If not pubs then gets public key from verfer.qb64 used to lookup
private keys
Returns:
bytes: decrypted data
Expand Down
44 changes: 38 additions & 6 deletions src/keri/core/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def annot(ims):


if not isinstance(ims, bytearray): # going to strip
ims = bytearray(ims) # so make bytearray copy
ims = bytearray(ims) # so make bytearray copy, converts str to bytearray

while ims: # right now just for KERI event messages
cold = sniff(ims) # check for spurious counters at front of stream
Expand Down Expand Up @@ -342,14 +342,22 @@ class Streamer:

def __init__(self, stream):
"""Initialize instance
Holds sniffable CESR stream as byte like string
either (bytes, bytearray, or memoryview)
Parameters:
stream (bytes | bytearray): sniffable CESR stream
stream (str | bytes | bytearray | memoryview): sniffable CESR stream
"""
self._stream = bytes(stream)
if hasattr(stream, "encode"):
stream = bytearray(stream.encode()) # convert str to bytearray
if not isinstance(stream, (bytes, bytearray, memoryview)):
raise kering.InvalidTypeError(f"Invalid stream type, not byteable.")

self._stream = stream


@property
Expand All @@ -360,7 +368,9 @@ def stream(self):

@property
def text(self):
"""expanded stream as qb64 text
"""expanded stream where all primitives and groups in stream are
individually expanded to qb64.
Requires parsing full depth to ensure expanded consistently.
Returns:
stream (bytes): expanded text qb64 version of stream
Expand All @@ -369,7 +379,9 @@ def text(self):

@property
def binary(self):
"""compacted stream as qb2 binary
"""compacted stream where all primitives and groups in stream are
individually compacted to qb2.
Requires parsing full depth to ensure compacted consistently
Returns:
stream (bytes): compacted binary qb2 version of stream
Expand All @@ -378,13 +390,33 @@ def binary(self):

@property
def texter(self):
"""expanded stream as Texter instance
"""stream as Texter instance.
Texter(text=self.stream)
Returns:
texter (Texter): Texter primitive of stream suitable wrapping
"""
return self._stream

@property
def bexter(self):
"""stream as Bexter instance.
Bexter of expanded text version of stream.
First expand to text which requires parsing then create bexter
Bexter(bext=self.text)
Because sniffable stream MUST NOT start with 'A' then there is no
length ambiguity. The only tritet collison of 'A' is with '-' but the
remaining 5 bits are guaranteed to always be different. So bexter must
check not just the starting tritet but the full starting byte to ensure
not 'A' as first byte.
Requires parsing to ensure qb64
Returns:
bexter (Bexter): Bexter primitive of stream suitable wrapping
"""
return self._stream




Expand Down

0 comments on commit 2918f86

Please sign in to comment.