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

81 lines
2.5 KiB
HTML
Raw Permalink Normal View History

{% extends templates['booth/base.html'] %}
{#
Eos - Verifiable elections
2019-01-14 17:54:31 +11:00
Copyright © 2017-2019 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/>.
#}
{% block content %}
<div class="ui basic segment" style="min-height: 4em;">
<div class="ui active text loader">Preparing your ballot. Please wait.</div>
</div>
{% endblock %}
{% block after %}
<script>
boothWorker.onmessage = function(msg) {
try {
rawAnswers = [];
for (var answer_json of booth.answers) {
2019-01-14 17:54:31 +11:00
rawAnswers.push(eosjs.eos.core.objects.EosObject.deserialise_and_unwrap(answer_json, null));
}
encryptedAnswers = [];
for (var encrypted_answer_json of msg.data.encrypted_answers) {
2019-01-14 17:54:31 +11:00
encryptedAnswers.push(eosjs.eos.core.objects.EosObject.deserialise_and_unwrap(encrypted_answer_json, null));
}
2019-01-14 17:54:31 +11:00
booth.ballot = eosjs.eos.base.election.Ballot();
booth.ballot.answers = rawAnswers;
booth.ballot.encrypted_answers = encryptedAnswers;
booth.ballot.election_id = election._id;
2019-01-14 17:54:31 +11:00
booth.ballot.election_hash = eosjs.eos.core.hashing.SHA256().update_obj(election).hash_as_b64();
if (should_do_fingerprint) {
// String.prototype.join confuses fingerprintjs2
var strjoin = String.prototype.join;
String.prototype.join = undefined;
new Fingerprint2().get(function(result, components) {
String.prototype.join = strjoin;
booth.fingerprint = components;
2017-12-11 13:56:31 +11:00
nextTemplate();
});
} else {
2017-12-11 13:53:25 +11:00
nextTemplate();
2017-12-11 13:56:31 +11:00
}
} catch (err) {
boothError(err);
throw err;
2017-12-11 13:53:25 +11:00
}
}
boothWorker.onerror = function(err) {
boothError(err);
throw err;
}
try {
boothWorker.postMessage({
"action": "generateEncryptedVote",
"static_base_url": "{{ static_base_url }}",
2019-01-14 17:54:31 +11:00
"election": eosjs.eos.core.objects.EosObject.serialise_and_wrap(election, null),
"answers": booth.answers
});
} catch (err) {
boothError(err);
throw err;
}
</script>
{% endblock %}