Eos/eosweb/core/static/nunjucks/booth/encrypt.html

78 lines
2.4 KiB
HTML
Raw Normal View History

{#
Eos - Verifiable elections
Copyright © 2017 RunasSudo (Yingtong Li)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
<div class="ui active text loader">Preparing your ballot. Please wait.</div>
<script>
boothWorker.onmessage = function(msg) {
try {
2017-11-28 22:43:32 +11:00
rawAnswers = [];
for (var answer_json of booth.answers) {
rawAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(answer_json, null));
}
encryptedAnswers = [];
2017-12-11 13:53:25 +11:00
for (var encrypted_answer_json of msg.data.encrypted_answers) {
encryptedAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(encrypted_answer_json, null));
}
2017-11-28 22:43:32 +11:00
booth.ballot = eosjs.eos.base.election.__all__.Ballot();
2017-11-28 22:43:32 +11:00
booth.ballot.answers = rawAnswers;
booth.ballot.encrypted_answers = encryptedAnswers;
booth.ballot.election_id = election._id;
booth.ballot.election_hash = eosjs.eos.core.hashing.__all__.SHA256().update_obj(election).hash_as_b64();
2017-12-11 13:53:25 +11:00
if (should_do_fingerprint) {
// String.prototype.join confuses fingerprintjs2
var strjoin = String.prototype.join;
String.prototype.join = undefined;
2017-12-11 13:56:31 +11:00
try {
new Fingerprint2().get(function(result, components) {
String.prototype.join = strjoin;
booth.fingerprint = components;
nextTemplate();
});
} catch (ex) {
console.error(ex);
2017-12-11 13:53:25 +11:00
nextTemplate();
2017-12-11 13:56:31 +11:00
}
2017-12-11 13:53:25 +11:00
} else {
nextTemplate();
}
} catch (err) {
boothError(err);
throw err;
}
}
boothWorker.onerror = function(err) {
boothError(err);
throw err;
}
try {
boothWorker.postMessage({
"action": "generateEncryptedVote",
"static_base_url": "{{ static_base_url }}",
"election": eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(election, null),
2017-12-11 13:53:25 +11:00
"answers": booth.answers
});
} catch (err) {
boothError(err);
throw err;
}
</script>