4040
4141
4242def compute_decryption_share (
43- guardian : Guardian , tally : CiphertextTally , context : CiphertextElectionContext ,
43+ guardian : Guardian ,
44+ tally : CiphertextTally ,
45+ context : CiphertextElectionContext ,
46+ scheduler : Optional [Scheduler ] = None ,
4447) -> Optional [TallyDecryptionShare ]:
4548 """
4649 Compute a decryptions share for a guardian
@@ -51,12 +54,17 @@ def compute_decryption_share(
5154 :return: a `TallyDecryptionShare` or `None` if there is an error
5255 """
5356
54- contests = compute_decryption_share_for_cast_contests (guardian , tally , context )
57+ if not scheduler :
58+ scheduler = Scheduler ()
59+
60+ contests = compute_decryption_share_for_cast_contests (
61+ guardian , tally , context , scheduler
62+ )
5563 if contests is None :
5664 return None
5765
5866 spoiled_ballots = compute_decryption_share_for_spoiled_ballots (
59- guardian , tally , context
67+ guardian , tally , context , scheduler
6068 )
6169
6270 if spoiled_ballots is None :
@@ -76,6 +84,7 @@ def compute_compensated_decryption_share(
7684 tally : CiphertextTally ,
7785 context : CiphertextElectionContext ,
7886 decrypt : AuxiliaryDecrypt = rsa_decrypt ,
87+ scheduler : Optional [Scheduler ] = None ,
7988) -> Optional [CompensatedTallyDecryptionShare ]:
8089 """
8190 Compute a compensated decryptions share for a guardian
@@ -86,15 +95,17 @@ def compute_compensated_decryption_share(
8695 :context: The public election encryption context
8796 :return: a `TallyDecryptionShare` or `None` if there is an error
8897 """
98+ if not scheduler :
99+ scheduler = Scheduler ()
89100
90101 contests = compute_compensated_decryption_share_for_cast_contests (
91- guardian , missing_guardian_id , tally , context , decrypt
102+ guardian , missing_guardian_id , tally , context , decrypt , scheduler
92103 )
93104 if contests is None :
94105 return None
95106
96107 spoiled_ballots = compute_compensated_decryption_share_for_spoiled_ballots (
97- guardian , missing_guardian_id , tally , context , decrypt
108+ guardian , missing_guardian_id , tally , context , decrypt , scheduler
98109 )
99110
100111 if spoiled_ballots is None :
@@ -110,13 +121,17 @@ def compute_compensated_decryption_share(
110121
111122
112123def compute_decryption_share_for_cast_contests (
113- guardian : Guardian , tally : CiphertextTally , context : CiphertextElectionContext ,
124+ guardian : Guardian ,
125+ tally : CiphertextTally ,
126+ context : CiphertextElectionContext ,
127+ scheduler : Optional [Scheduler ] = None ,
114128) -> Optional [Dict [CONTEST_ID , CiphertextDecryptionContest ]]:
115129 """
116130 Compute the decryption for all of the cast contests in the Ciphertext Tally
117131 """
118132 contests : Dict [CONTEST_ID , CiphertextDecryptionContest ] = {}
119- scheduler = Scheduler ()
133+ if not scheduler :
134+ scheduler = Scheduler ()
120135
121136 for contest in tally .cast .values ():
122137 selections : Dict [SELECTION_ID , CiphertextDecryptionSelection ] = {}
@@ -153,11 +168,13 @@ def compute_compensated_decryption_share_for_cast_contests(
153168 tally : CiphertextTally ,
154169 context : CiphertextElectionContext ,
155170 decrypt : AuxiliaryDecrypt = rsa_decrypt ,
171+ scheduler : Optional [Scheduler ] = None ,
156172) -> Optional [Dict [CONTEST_ID , CiphertextCompensatedDecryptionContest ]]:
157173 """
158174 Compute the compensated decryption for all of the cast contests in the Ciphertext Tally
159175 """
160- scheduler = Scheduler ()
176+ if not scheduler :
177+ scheduler = Scheduler ()
161178 contests : Dict [CONTEST_ID , CiphertextCompensatedDecryptionContest ] = {}
162179
163180 for contest in tally .cast .values ():
@@ -193,13 +210,17 @@ def compute_compensated_decryption_share_for_cast_contests(
193210
194211
195212def compute_decryption_share_for_spoiled_ballots (
196- guardian : Guardian , tally : CiphertextTally , context : CiphertextElectionContext ,
213+ guardian : Guardian ,
214+ tally : CiphertextTally ,
215+ context : CiphertextElectionContext ,
216+ scheduler : Optional [Scheduler ] = None ,
197217) -> Optional [Dict [BALLOT_ID , BallotDecryptionShare ]]:
198218 """
199219 Compute the decryption for all spoiled ballots in the Ciphertext Tally
200220 """
201221 spoiled_ballots : Dict [BALLOT_ID , BallotDecryptionShare ] = {}
202- scheduler = Scheduler ()
222+ if not scheduler :
223+ scheduler = Scheduler ()
203224
204225 for spoiled_ballot in tally .spoiled_ballots .values ():
205226 computed_share = compute_decryption_share_for_ballot (
@@ -262,15 +283,16 @@ def compute_compensated_decryption_share_for_spoiled_ballots(
262283 tally : CiphertextTally ,
263284 context : CiphertextElectionContext ,
264285 decrypt : AuxiliaryDecrypt = rsa_decrypt ,
286+ scheduler : Optional [Scheduler ] = None ,
265287) -> Optional [Dict [BALLOT_ID , CompensatedBallotDecryptionShare ]]:
266288 """
267289 Compute the decryption for all spoiled ballots in the Ciphertext Tally
268290 """
269291 spoiled_ballots : Dict [BALLOT_ID , CompensatedBallotDecryptionShare ] = {}
270- scheduler = Scheduler ()
292+ if not scheduler :
293+ scheduler = Scheduler ()
271294
272295 for spoiled_ballot in tally .spoiled_ballots .values ():
273- contests : Dict [CONTEST_ID , CiphertextCompensatedDecryptionContest ] = {}
274296 compensated_ballot = compute_compensated_decryption_share_for_ballot (
275297 guardian , missing_guardian_id , spoiled_ballot , context , decrypt , scheduler
276298 )
@@ -380,7 +402,7 @@ def compute_compensated_decryption_share_for_selection(
380402 decrypt : AuxiliaryDecrypt = rsa_decrypt ,
381403) -> Optional [CiphertextCompensatedDecryptionSelection ]:
382404 """
383- Compute a compensated decryption share for a specific selection using the
405+ Compute a compensated decryption share for a specific selection using the
384406 avialable guardian's share of the missing guardian's private key polynomial
385407
386408 :param available_guardian: The available guardian that will partially decrypt the selection
@@ -537,7 +559,7 @@ def reconstruct_decryption_contests(
537559 lagrange_coefficients : Dict [AVAILABLE_GUARDIAN_ID , ElementModQ ],
538560) -> Dict [CONTEST_ID , CiphertextDecryptionContest ]:
539561 """
540- Recontruct the missing Decryption Share for a missing guardian
562+ Recontruct the missing Decryption Share for a missing guardian
541563 from the collection of compensated decryption shares
542564
543565 :param missing_guardian_id: The guardian id for the missing guardian
0 commit comments