Skip to content

Commit 2265843

Browse files
Fix element mod p hash and use enum name in hash (#217)
1 parent a272c24 commit 2265843

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/electionguard/election.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def crypto_hash(self) -> ElementModQ:
175175
A hash representation of the object
176176
"""
177177
return hash_elems(
178-
self.object_id, self.name, str(self.type), self.contact_information
178+
self.object_id, self.name, str(self.type.name), self.contact_information
179179
)
180180

181181

@@ -363,7 +363,7 @@ def crypto_hash(self) -> ElementModQ:
363363
self.object_id,
364364
self.sequence_order,
365365
self.electoral_district_id,
366-
str(self.vote_variation),
366+
str(self.vote_variation.name),
367367
self.ballot_title,
368368
self.ballot_subtitle,
369369
self.name,
@@ -566,7 +566,7 @@ def crypto_hash(self) -> ElementModQ:
566566

567567
return hash_elems(
568568
self.election_scope_id,
569-
str(self.type),
569+
str(self.type.name),
570570
to_ticks(self.start_date),
571571
to_ticks(self.end_date),
572572
self.name,

src/electionguard/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def to_hex(self) -> str:
8888
Converts from the element to the hex representation of bytes. This is preferable to directly
8989
accessing `elem`, whose representation might change.
9090
"""
91-
h = format(self.elem, "02x")
91+
h = format(self.elem, "02X")
9292
if len(h) % 2:
9393
h = "0" + h
9494
return h

0 commit comments

Comments
 (0)