Skip to content

Commit 9c17e01

Browse files
committed
added comments to include new syntax for Tholder
1 parent 540e781 commit 9c17e01

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/keri/core/coring.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5468,13 +5468,21 @@ class Tholder:
54685468
The b64 portion of limen with code stripped (Bexter.bext) of
54695469
[["1/2", "1/2", "1/4", "1/4", "1/4"], ["1", "1"]]
54705470
is '1s2c1s2c1s4c1s4c1s4a1c1' basically slash is 's', comma is 'c',
5471-
and ANDed clauses are delimited by 'a'.
5471+
ANDed clauses are delimited by 'a'.
5472+
Each clause top level weight may be optionally a weighted set of weights
5473+
delimited by 'k' for the weight on the set and 'v' for the weights in
5474+
the set.
5475+
[[{'1/3': ['1/2', '1/2', '1/2']}, '1/2', {'1/2': ['1', '1']}],
5476+
['1/2', {'1/2': ['1', '1']}]]
5477+
b'4AAKA1s3k1s2v1s2v1s2c1s2c1s2k1v1a1s2c1s2k1v1'
5478+
54725479
54735480
.sith is original signing threshold suitable for value to be serialized
54745481
as json, cbor, mgpk in key event message as either:
54755482
non-negative hex number str or
54765483
list of str rational number fractions >= 0 and <= 1 or
54775484
list of list of str rational number fractions >= 0 and <= 1
5485+
list of list of weighted map of weights
54785486
54795487
.thold is parsed signing threshold suitable for calculating satisfaction.
54805488
either as int or list of Fractions
@@ -5527,8 +5535,10 @@ def __init__(self, *, thold=None , limen=None, sith=None, **kwa):
55275535
the satisfaction of a threshold and is expressed as either:
55285536
int of threshold number (M of N)
55295537
fractional weight clauses which may be expressed as either:
5530-
an iterable of Fractions or
5531-
an iterable of iterables of Fractions.
5538+
sequence of either Fractions or tuples of Fraction and
5539+
sequence of Fractions
5540+
sequence of sequence of either Fractions or tuples of
5541+
Fraction and sequence of Fractions
55325542
55335543
limen is qualified signing threshold (current or next) expressed as either:
55345544
Number.qb64 or .qb64b of integer threshold or
@@ -5542,11 +5552,17 @@ def __init__(self, *, thold=None , limen=None, sith=None, **kwa):
55425552
non-negative hex string of threshold number (M-of-N threshold)
55435553
next threshold may be zero
55445554
fractional weight clauses which may be expressed as either:
5545-
an sequence of rational number fraction strings >= 0 and <= 1
5546-
an sequence of sequences of rational number fraction strings >= 0 and <= 1
5547-
JSON serialized str of either:
5548-
list of rational number fraction strings >= 0 and <= 1 or
5549-
list of list of rational number fraction strings >= 0 and <= 1
5555+
sequence of rational number fraction strings >= 0 and <= 1
5556+
sequence of either rational number fraction strings >= 0 and <= 1 or
5557+
map with key rational number string and value as sequence
5558+
of rational number fraction strings
5559+
rational number fraction string
5560+
sequence of sequences of rational number fraction strings >= 0 and <= 1
5561+
sequence of sequnces of either rational number fraction strings or
5562+
map with key rational number fraction string with value sequence of
5563+
rationaly number fraction strings
5564+
JSON serialized str of the above:
5565+
55505566
55515567
"""
55525568
if thold is not None:
@@ -5674,7 +5690,6 @@ def _processLimen(self, limen: str | bytes, **kwa):
56745690

56755691
thold.append(clause)
56765692

5677-
#thold = [[self.weight(w) for w in clause] for clause in thold]
56785693
self._processWeighted(thold=thold)
56795694

56805695
else:
@@ -5829,11 +5844,6 @@ def _processWeighted(self, thold=[]):
58295844
ta.append(bc)
58305845

58315846
bext = "a".join(["c".join(bc) for bc in ta])
5832-
5833-
#bext = [[f"{f.numerator}s{f.denominator}" if (0 < f < 1) else f"{int(f)}"
5834-
#for f in clause]
5835-
#for clause in thold]
5836-
#bext = "a".join(["c".join(clause) for clause in bext])
58375847
self._number = None
58385848
self._bexter = Bexter(bext=bext)
58395849

@@ -5935,15 +5945,6 @@ def _satisfy_weighted(self, indices):
59355945
if cw < 1: # each clause must sum to at least 1
59365946
return False
59375947

5938-
#for clause in self.thold:
5939-
#cw = 0 # init clause weight
5940-
#for w in clause:
5941-
#if sats[wio]: # verified signature so weight applies
5942-
#cw += w
5943-
#wio += 1
5944-
#if cw < 1: # each clause must sum to at least 1
5945-
#return False
5946-
59475948
return True # all clauses have cw >= 1 including final one, AND true
59485949

59495950
except Exception as ex:

0 commit comments

Comments
 (0)