Fix calculation of maximum cryptotext size
This commit is contained in:
parent
fd6f5733a9
commit
d71e9e4821
@ -131,7 +131,7 @@ class ListChoiceQuestion(Question):
|
|||||||
return ', '.join([flat_choices[choice].name for choice in answer.choices])
|
return ', '.join([flat_choices[choice].name for choice in answer.choices])
|
||||||
|
|
||||||
def max_bits(self):
|
def max_bits(self):
|
||||||
answer = self.answer_type(choices=list(range(len(self.choices))))
|
answer = self.answer_type(choices=list(range(self.max_choices)))
|
||||||
return len(EosObject.to_json(EosObject.serialise_and_wrap(answer))) * 8
|
return len(EosObject.to_json(EosObject.serialise_and_wrap(answer))) * 8
|
||||||
|
|
||||||
def flatten_choices(self):
|
def flatten_choices(self):
|
||||||
|
@ -24,7 +24,7 @@ function generateEncryptedVote(election, answers, should_do_fingerprint) {
|
|||||||
for (var q_num = 0; q_num < answers.length; q_num++) {
|
for (var q_num = 0; q_num < answers.length; q_num++) {
|
||||||
answer_json = answers[q_num];
|
answer_json = answers[q_num];
|
||||||
answer = eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(answer_json, null);
|
answer = eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(answer_json, null);
|
||||||
encrypted_answer = eosjs.eos.psr.election.__all__.BlockEncryptedAnswer.encrypt(election.public_key, answer, election.questions.__getitem__(q_num).max_bits());
|
encrypted_answer = eosjs.eos.psr.election.__all__.BlockEncryptedAnswer.encrypt(election.public_key, answer, election.questions.__getitem__(q_num).max_bits() + 32); // +32 bits for the length
|
||||||
encrypted_answers.push(eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(encrypted_answer, null));
|
encrypted_answers.push(eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(encrypted_answer, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user