33from enum import Enum
44from typing import Any , List , Iterable , Optional , Protocol , runtime_checkable , Sequence
55
6- from .ballot_code import get_rotating_ballot_code
6+ from .ballot_code import get_ballot_code
77from .chaum_pedersen import (
88 ConstantChaumPedersenProof ,
99 DisjunctiveChaumPedersenProof ,
@@ -666,8 +666,8 @@ class CiphertextBallot(ElectionObjectBase, CryptoHashCheckable):
666666 manifest_hash : ElementModQ
667667 """Hash of the election manifest"""
668668
669- previous_code : ElementModQ
670- """Previous ballot code or seed """
669+ code_seed : ElementModQ
670+ """Seed for ballot code"""
671671
672672 contests : List [CiphertextBallotContest ]
673673 """List of contests for this ballot"""
@@ -690,7 +690,7 @@ def __eq__(self, other: Any) -> bool:
690690 and self .object_id == other .object_id
691691 and self .style_id == other .style_id
692692 and self .manifest_hash == other .manifest_hash
693- and self .previous_code == other .previous_code
693+ and self .code_seed == other .code_seed
694694 and _list_eq (self .contests , other .contests )
695695 and self .code == other .code
696696 and self .timestamp == other .timestamp
@@ -849,7 +849,7 @@ def make_ciphertext_ballot(
849849 object_id : str ,
850850 style_id : str ,
851851 manifest_hash : ElementModQ ,
852- previous_ballot_code : Optional [ElementModQ ],
852+ code_seed : Optional [ElementModQ ],
853853 contests : List [CiphertextBallotContest ],
854854 nonce : Optional [ElementModQ ] = None ,
855855 timestamp : Optional [int ] = None ,
@@ -864,7 +864,7 @@ def make_ciphertext_ballot(
864864 :param crypto_base_hash: Hash of the cryptographic election context
865865 :param contests: List of contests for this ballot
866866 :param timestamp: Timestamp at which the ballot encryption is generated in tick
867- :param previous_code: Previous ballot code or seed
867+ :param code_seed: Seed for ballot code
868868 :param nonce: optional nonce used as part of the encryption process
869869 """
870870
@@ -874,18 +874,16 @@ def make_ciphertext_ballot(
874874 contest_hash = create_ballot_hash (object_id , manifest_hash , contests )
875875
876876 timestamp = to_ticks (datetime .now ()) if timestamp is None else timestamp
877- if previous_ballot_code is None :
878- previous_ballot_code = manifest_hash
877+ if code_seed is None :
878+ code_seed = manifest_hash
879879 if ballot_code is None :
880- ballot_code = get_rotating_ballot_code (
881- previous_ballot_code , timestamp , contest_hash
882- )
880+ ballot_code = get_ballot_code (code_seed , timestamp , contest_hash )
883881
884882 return CiphertextBallot (
885883 object_id ,
886884 style_id ,
887885 manifest_hash ,
888- previous_ballot_code ,
886+ code_seed ,
889887 contests ,
890888 ballot_code ,
891889 timestamp ,
@@ -909,7 +907,7 @@ def make_ciphertext_submitted_ballot(
909907 object_id : str ,
910908 style_id : str ,
911909 manifest_hash : ElementModQ ,
912- previous_ballot_code : Optional [ElementModQ ],
910+ code_seed : Optional [ElementModQ ],
913911 contests : List [CiphertextBallotContest ],
914912 ballot_code : Optional [ElementModQ ],
915913 timestamp : Optional [int ] = None ,
@@ -921,7 +919,7 @@ def make_ciphertext_submitted_ballot(
921919 :param object_id: the object_id of this specific ballot
922920 :param style_id: The `object_id` of the `BallotStyle` in the `Election` Manifest
923921 :param manifest_hash: Hash of the election manifest
924- :param previous_code: Previous ballot code or seed
922+ :param code_seed: Seed for ballot code
925923 :param contests: List of contests for this ballot
926924 :param timestamp: Timestamp at which the ballot encryption is generated in tick
927925 :param state: ballot box state
@@ -934,12 +932,10 @@ def make_ciphertext_submitted_ballot(
934932 contest_hash = hash_elems (object_id , manifest_hash , * contest_hashes )
935933
936934 timestamp = to_ticks (datetime .utcnow ()) if timestamp is None else timestamp
937- if previous_ballot_code is None :
938- previous_ballot_code = manifest_hash
935+ if code_seed is None :
936+ code_seed = manifest_hash
939937 if ballot_code is None :
940- ballot_code = get_rotating_ballot_code (
941- previous_ballot_code , timestamp , contest_hash
942- )
938+ ballot_code = get_ballot_code (code_seed , timestamp , contest_hash )
943939
944940 # copy the contests and selections, removing all nonces
945941 new_contests : List [CiphertextBallotContest ] = []
@@ -954,7 +950,7 @@ def make_ciphertext_submitted_ballot(
954950 object_id ,
955951 style_id ,
956952 manifest_hash ,
957- previous_ballot_code ,
953+ code_seed ,
958954 new_contests ,
959955 ballot_code ,
960956 timestamp ,
@@ -974,7 +970,7 @@ def from_ciphertext_ballot(
974970 ballot .object_id ,
975971 ballot .style_id ,
976972 ballot .manifest_hash ,
977- ballot .previous_code ,
973+ ballot .code_seed ,
978974 ballot .contests ,
979975 ballot .code ,
980976 ballot .timestamp ,
0 commit comments