@@ -49,7 +49,7 @@ class DecryptionDto:
4949 can_join : Optional [bool ]
5050 decryption_shares : list [Any ]
5151 plaintext_tally : Optional [str ]
52- plaintext_spoiled_ballots : Optional [ dict [str , str ] ]
52+ plaintext_spoiled_ballots : dict [str , str ]
5353 lagrange_coefficients : Optional [str ]
5454 ciphertext_tally : Optional [str ]
5555 completed_at_utc : Optional [datetime ]
@@ -69,7 +69,9 @@ def __init__(self, decryption: dict[str, Any]):
6969 self .guardians_joined = _get_list (decryption , "guardians_joined" )
7070 self .decryption_shares = _get_list (decryption , "decryption_shares" )
7171 self .plaintext_tally = decryption .get ("plaintext_tally" )
72- self .plaintext_spoiled_ballots = decryption .get ("plaintext_spoiled_ballots" )
72+ self .plaintext_spoiled_ballots = _get_dict (
73+ decryption , "plaintext_spoiled_ballots"
74+ )
7375 self .lagrange_coefficients = decryption .get ("lagrange_coefficients" )
7476 self .ciphertext_tally = decryption .get ("ciphertext_tally" )
7577 self .completed_at_utc = decryption .get ("completed_at" )
@@ -132,8 +134,6 @@ def get_plaintext_tally(self) -> PlaintextTally:
132134 return from_raw (PlaintextTally , self .plaintext_tally )
133135
134136 def get_plaintext_spoiled_ballots (self ) -> list [PlaintextTally ]:
135- if not self .plaintext_spoiled_ballots :
136- raise ValueError ("No plaintext spoiled ballots found" )
137137 return [
138138 from_raw (PlaintextTally , tally )
139139 for tally in self .plaintext_spoiled_ballots .values ()
@@ -157,6 +157,13 @@ def _get_list(decryption: dict[str, Any], name: str) -> list:
157157 return []
158158
159159
160+ def _get_dict (decryption : dict [str , Any ], name : str ) -> dict :
161+ value = decryption .get (name )
162+ if value :
163+ return dict (value )
164+ return {}
165+
166+
160167def _get_int (decryption : dict [str , Any ], name : str , default : int ) -> int :
161168 value = decryption .get (name )
162169 if value :
0 commit comments