Fix calculation of maximum cryptotext size

This commit is contained in:
RunasSudo 2017-12-11 20:24:13 +10:30
parent fd6f5733a9
commit d71e9e4821
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 2 additions and 2 deletions

View File

@ -131,7 +131,7 @@ class ListChoiceQuestion(Question):
return ', '.join([flat_choices[choice].name for choice in answer.choices])
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
def flatten_choices(self):

View File

@ -24,7 +24,7 @@ function generateEncryptedVote(election, answers, should_do_fingerprint) {
for (var q_num = 0; q_num < answers.length; q_num++) {
answer_json = answers[q_num];
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));
}