diff --git a/eos/base/election.py b/eos/base/election.py index 2f8cff6..7c22723 100644 --- a/eos/base/election.py +++ b/eos/base/election.py @@ -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): diff --git a/eosweb/core/static/js/booth_worker.js b/eosweb/core/static/js/booth_worker.js index d1fc56e..b51f93d 100644 --- a/eosweb/core/static/js/booth_worker.js +++ b/eosweb/core/static/js/booth_worker.js @@ -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)); }