Update for Tanscrypt 3.6.58
Transcrypt bug 413 closed
This commit is contained in:
parent
d9f1291bea
commit
85c8f4638f
@ -40,8 +40,8 @@ class Ballot(EmbeddedObject):
|
|||||||
def deaudit(self):
|
def deaudit(self):
|
||||||
encrypted_answers_deaudit = EosList()
|
encrypted_answers_deaudit = EosList()
|
||||||
|
|
||||||
for i in range(len(self.encrypted_answers)):
|
for encrypted_answer in self.encrypted_answers:
|
||||||
encrypted_answers_deaudit.append(self.encrypted_answers[i].deaudit())
|
encrypted_answers_deaudit.append(encrypted_answer.deaudit())
|
||||||
|
|
||||||
return Ballot(encrypted_answers=encrypted_answers_deaudit, election_id=self.election_id, election_hash=self.election_hash)
|
return Ballot(encrypted_answers=encrypted_answers_deaudit, election_id=self.election_id, election_hash=self.election_hash)
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class ApprovalQuestion(Question):
|
|||||||
max_choices = IntField()
|
max_choices = IntField()
|
||||||
|
|
||||||
def pretty_answer(self, answer):
|
def pretty_answer(self, answer):
|
||||||
return ', '.join([self.choices[answer.choices[i]] for i in range(len(answer.choices))])
|
return ', '.join([self.choices[choice] for choice in answer.choices])
|
||||||
|
|
||||||
class ApprovalAnswer(Answer):
|
class ApprovalAnswer(Answer):
|
||||||
choices = ListField(IntField())
|
choices = ListField(IntField())
|
||||||
@ -117,7 +117,7 @@ class PreferentialQuestion(Question):
|
|||||||
max_choices = IntField()
|
max_choices = IntField()
|
||||||
|
|
||||||
def pretty_answer(self, answer):
|
def pretty_answer(self, answer):
|
||||||
return ', '.join([self.choices[answer.choices[i]] for i in range(len(answer.choices))])
|
return ', '.join([self.choices[choice] for choice in answer.choices])
|
||||||
|
|
||||||
class PreferentialAnswer(Answer):
|
class PreferentialAnswer(Answer):
|
||||||
choices = ListField(IntField())
|
choices = ListField(IntField())
|
||||||
|
@ -103,8 +103,7 @@ class Workflow(EmbeddedObject):
|
|||||||
|
|
||||||
def get_tasks(self, descriptor):
|
def get_tasks(self, descriptor):
|
||||||
#yield from (task for task in self.tasks if task.satisfies(descriptor))
|
#yield from (task for task in self.tasks if task.satisfies(descriptor))
|
||||||
for i in range(len(self.tasks)):
|
for task in self.tasks:
|
||||||
task = self.tasks[i]
|
|
||||||
if task.satisfies(descriptor):
|
if task.satisfies(descriptor):
|
||||||
yield task
|
yield task
|
||||||
|
|
||||||
@ -141,10 +140,10 @@ class TaskDecryptVotes(WorkflowTask):
|
|||||||
if len(voter.votes) > 0:
|
if len(voter.votes) > 0:
|
||||||
vote = voter.votes[-1]
|
vote = voter.votes[-1]
|
||||||
ballot = vote.ballot
|
ballot = vote.ballot
|
||||||
for i in range(len(ballot.encrypted_answers)):
|
for q_num in range(len(ballot.encrypted_answers)):
|
||||||
plaintexts, answer = ballot.encrypted_answers[i].decrypt()
|
plaintexts, answer = ballot.encrypted_answers[q_num].decrypt()
|
||||||
election.results[i].plaintexts.append(plaintexts)
|
election.results[q_num].plaintexts.append(plaintexts)
|
||||||
election.results[i].answers.append(answer)
|
election.results[q_num].answers.append(answer)
|
||||||
|
|
||||||
self.exit()
|
self.exit()
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ class BitStream(EosObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def unmap(cls, value, func, block_size):
|
def unmap(cls, value, func, block_size):
|
||||||
bs = cls()
|
bs = cls()
|
||||||
for i in range(len(value)):
|
for item in value:
|
||||||
bs.write(func(value[i]), block_size)
|
bs.write(func(item), block_size)
|
||||||
bs.seek(0)
|
bs.seek(0)
|
||||||
return bs
|
return bs
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class BlockEncryptedAnswer(EncryptedAnswer):
|
|||||||
if sk is None:
|
if sk is None:
|
||||||
sk = self.recurse_parents(PSRElection).sk
|
sk = self.recurse_parents(PSRElection).sk
|
||||||
|
|
||||||
plaintexts = EosList([sk.decrypt_and_prove(self.blocks[i]) for i in range(len(self.blocks))])
|
plaintexts = EosList([sk.decrypt_and_prove(block) for block in self.blocks])
|
||||||
|
|
||||||
bs = BitStream.unmap(plaintexts, lambda plaintext: plaintext.message, sk.public_key.nbits())
|
bs = BitStream.unmap(plaintexts, lambda plaintext: plaintext.message, sk.public_key.nbits())
|
||||||
m = bs.read_string()
|
m = bs.read_string()
|
||||||
@ -51,8 +51,8 @@ class BlockEncryptedAnswer(EncryptedAnswer):
|
|||||||
def deaudit(self):
|
def deaudit(self):
|
||||||
blocks_deaudit = EosList()
|
blocks_deaudit = EosList()
|
||||||
|
|
||||||
for i in range(len(self.blocks)):
|
for block in self.blocks:
|
||||||
blocks_deaudit.append(self.blocks[i].deaudit())
|
blocks_deaudit.append(block.deaudit())
|
||||||
|
|
||||||
return BlockEncryptedAnswer(blocks=blocks_deaudit)
|
return BlockEncryptedAnswer(blocks=blocks_deaudit)
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ class MixingTrustee(Trustee):
|
|||||||
|
|
||||||
sha = SHA256()
|
sha = SHA256()
|
||||||
trustees = self.recurse_parents(Election).mixing_trustees
|
trustees = self.recurse_parents(Election).mixing_trustees
|
||||||
for i in range(len(trustees)):
|
for trustee in trustees:
|
||||||
sha.update_text(EosObject.to_json(MixingTrustee._fields['mixed_questions'].element_field.serialise(trustees[i].mixed_questions[question_num])))
|
sha.update_text(EosObject.to_json(MixingTrustee._fields['mixed_questions'].element_field.serialise(trustee.mixed_questions[question_num])))
|
||||||
for i in range(self._instance[1]):
|
for i in range(self._instance[1]):
|
||||||
sha.update_text(EosObject.to_json(MixingTrustee._fields['response'].element_field.serialise(trustees[i].response[question_num])))
|
sha.update_text(EosObject.to_json(MixingTrustee._fields['response'].element_field.serialise(trustees[i].response[question_num])))
|
||||||
return sha.hash_as_bigint()
|
return sha.hash_as_bigint()
|
||||||
|
@ -142,9 +142,9 @@ class BlockEGTestCase(EosTestCase):
|
|||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
pt = BigInt('11010010011111010100101', 2)
|
pt = BigInt('11010010011111010100101', 2)
|
||||||
ct = BitStream(pt).multiple_of(self.sk.public_key.nbits()).map(self.sk.public_key.encrypt, self.sk.public_key.nbits())
|
ct = BitStream(pt).multiple_of(self.sk.public_key.nbits()).map(self.sk.public_key.encrypt, self.sk.public_key.nbits())
|
||||||
for i in range(len(ct)):
|
for ct_block in ct:
|
||||||
self.assertTrue(ct[i].gamma < self.test_group.p)
|
self.assertTrue(ct_block.gamma < self.test_group.p)
|
||||||
self.assertTrue(ct[i].delta < self.test_group.p)
|
self.assertTrue(ct_block.delta < self.test_group.p)
|
||||||
m = BitStream.unmap(ct, self.sk.decrypt, self.sk.public_key.nbits()).read()
|
m = BitStream.unmap(ct, self.sk.decrypt, self.sk.public_key.nbits()).read()
|
||||||
self.assertEqualJSON(pt, m)
|
self.assertEqualJSON(pt, m)
|
||||||
|
|
||||||
@ -164,13 +164,13 @@ class MixnetTestCase(EosTestCase):
|
|||||||
|
|
||||||
# Generate plaintexts
|
# Generate plaintexts
|
||||||
pts = []
|
pts = []
|
||||||
for i in range(4):
|
for _ in range(4):
|
||||||
pts.append(sk.public_key.group.random_Zq_element())
|
pts.append(sk.public_key.group.random_Zq_element())
|
||||||
|
|
||||||
# Encrypt plaintexts
|
# Encrypt plaintexts
|
||||||
answers = []
|
answers = []
|
||||||
for i in range(len(pts)):
|
for pt in pts:
|
||||||
bs = BitStream(pts[i])
|
bs = BitStream(pt)
|
||||||
bs.multiple_of(sk.public_key.nbits())
|
bs.multiple_of(sk.public_key.nbits())
|
||||||
ct = bs.map(sk.public_key.encrypt, sk.public_key.nbits())
|
ct = bs.map(sk.public_key.encrypt, sk.public_key.nbits())
|
||||||
answers.append(BlockEncryptedAnswer(blocks=ct))
|
answers.append(BlockEncryptedAnswer(blocks=ct))
|
||||||
@ -184,8 +184,8 @@ class MixnetTestCase(EosTestCase):
|
|||||||
|
|
||||||
# Decrypt shuffle
|
# Decrypt shuffle
|
||||||
msgs = []
|
msgs = []
|
||||||
for i in range(len(shuffled_answers)):
|
for shuffled_answer in shuffled_answers:
|
||||||
bs = BitStream.unmap(shuffled_answers[i].blocks, sk.decrypt, sk.public_key.nbits())
|
bs = BitStream.unmap(shuffled_answer.blocks, sk.decrypt, sk.public_key.nbits())
|
||||||
m = bs.read()
|
m = bs.read()
|
||||||
msgs.append(m)
|
msgs.append(m)
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ class ElectionTestCase(EosTestCase):
|
|||||||
voter = Voter(name=['Alice', 'Bob', 'Charlie'][i])
|
voter = Voter(name=['Alice', 'Bob', 'Charlie'][i])
|
||||||
election.voters.append(voter)
|
election.voters.append(voter)
|
||||||
|
|
||||||
for i in range(3):
|
for _ in range(3):
|
||||||
mixing_trustee = InternalMixingTrustee()
|
mixing_trustee = InternalMixingTrustee()
|
||||||
election.mixing_trustees.append(mixing_trustee)
|
election.mixing_trustees.append(mixing_trustee)
|
||||||
|
|
||||||
@ -339,8 +339,7 @@ class PVSSTestCase(EosTestCase):
|
|||||||
# IRL: Send hi=F[0] commitments around
|
# IRL: Send hi=F[0] commitments around
|
||||||
|
|
||||||
# Send shares around
|
# Send shares around
|
||||||
for i in range(len(setup.participants)):
|
for participant in setup.participants:
|
||||||
participant = setup.participants[i]
|
|
||||||
for j in range(len(setup.participants)):
|
for j in range(len(setup.participants)):
|
||||||
other = setup.participants[j]
|
other = setup.participants[j]
|
||||||
share = participant.get_share_for(j)
|
share = participant.get_share_for(j)
|
||||||
@ -361,7 +360,7 @@ class PVSSTestCase(EosTestCase):
|
|||||||
# Verify share received by other from participant
|
# Verify share received by other from participant
|
||||||
share_dec = other.shares_received[i]
|
share_dec = other.shares_received[i]
|
||||||
g_share_dec_expected = ONE
|
g_share_dec_expected = ONE
|
||||||
for k in range(0, setup.threshold):
|
for k in range(setup.threshold):
|
||||||
g_share_dec_expected = (g_share_dec_expected * pow(participant.F[k], pow(j + 1, k), setup.group.p)) % setup.group.p
|
g_share_dec_expected = (g_share_dec_expected * pow(participant.F[k], pow(j + 1, k), setup.group.p)) % setup.group.p
|
||||||
if pow(setup.group.g, share_dec, setup.group.p) != g_share_dec_expected:
|
if pow(setup.group.g, share_dec, setup.group.p) != g_share_dec_expected:
|
||||||
raise Exception('Share not consistent with commitments')
|
raise Exception('Share not consistent with commitments')
|
||||||
|
@ -9,15 +9,16 @@ idna==2.6
|
|||||||
itsdangerous==0.24
|
itsdangerous==0.24
|
||||||
Jinja2==2.10
|
Jinja2==2.10
|
||||||
MarkupSafe==1.0
|
MarkupSafe==1.0
|
||||||
mypy==0.521
|
mypy==0.550
|
||||||
oauthlib==2.0.6
|
oauthlib==2.0.6
|
||||||
|
psutil==5.4.1
|
||||||
psycopg2==2.7.3.2
|
psycopg2==2.7.3.2
|
||||||
PyExecJS==1.4.1
|
PyExecJS==1.4.1
|
||||||
pymongo==3.5.1
|
pymongo==3.5.1
|
||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
requests-oauthlib==0.8.0
|
requests-oauthlib==0.8.0
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
Transcrypt==3.6.50
|
Transcrypt==3.6.58
|
||||||
typed-ast==1.0.4
|
typed-ast==1.1.0
|
||||||
urllib3==1.22
|
urllib3==1.22
|
||||||
Werkzeug==0.12.2
|
Werkzeug==0.12.2
|
||||||
|
Loading…
Reference in New Issue
Block a user