@@ -575,7 +575,7 @@ def allot(
575
575
return shares
576
576
577
577
if isinstance (document , dict ):
578
- # Document is an array of shares obtained from the ``encrypt`` function
578
+ # Document contains shares obtained from the ``encrypt`` function
579
579
# that must be allotted to nodes.
580
580
if '$allot' in document :
581
581
if len (document .keys ()) != 1 :
@@ -585,10 +585,13 @@ def allot(
585
585
if isinstance (items , list ):
586
586
587
587
# Simple allotment.
588
- if all (isinstance (item , (int , str )) for item in items ):
588
+ if (
589
+ all (isinstance (item , int ) for item in items ) or
590
+ all (isinstance (item , str ) for item in items )
591
+ ):
589
592
return [{'$share' : item } for item in document ['$allot' ]]
590
593
591
- # More complex allotment with list of share lists .
594
+ # More complex allotment with nested lists of shares .
592
595
return [
593
596
{'$share' : [share ['$share' ] for share in shares ]}
594
597
for shares in allot ([{'$allot' : item } for item in items ])
@@ -684,17 +687,17 @@ def unify(
684
687
# Documents are shares.
685
688
if all ('$share' in document for document in documents ):
686
689
687
- # Simple share .
688
- if all (
689
- isinstance (document ['$share' ], ( int , str ))
690
- for document in documents
690
+ # Simple document shares .
691
+ if (
692
+ all ( isinstance (d ['$share' ], int ) for d in documents ) or
693
+ all ( isinstance ( d [ '$share' ], str ) for d in documents )
691
694
):
692
695
return decrypt (
693
696
secret_key ,
694
697
[document ['$share' ] for document in documents ]
695
698
)
696
699
697
- # Share consisting of list of shares.
700
+ # Document shares consisting of nested lists of shares.
698
701
return [
699
702
unify (
700
703
secret_key ,
0 commit comments