<p>There was an error loading the election data. Please check the election URL and try again. If the problem persists, contact the election administrator.</p>
<p>Your vote has <spanclass="superem">not</span> yet been cast. If you are satisfied with your ballot, you must return to the voting booth by closing this page and following the instructions.</p>
//auditResultInner.innerHTML += '<p><iclass="checkmark icon"></i> Data is in ballot format.</p>';
if (!eosjs.isinstance(auditBallot, eosjs.eos.base.election.__all__.Ballot)) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: The data is not in ballot format.</p>';
return false;
}
if (!auditBallot.answers || !auditBallot.answers.__len__ || auditBallot.answers.__len__() === 0) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: The data is not in audit ballot format.</p>';
return false;
}
auditResultInner.innerHTML += '<p><iclass="checkmark icon"></i> The data is in audit ballot format.</p>';
if (auditBallot.election_id !== election._id) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: The ballot corresponds to a different election.</p>';
return false;
}
auditResultInner.innerHTML += '<p><iclass="checkmark icon"></i> The ballot election ID is correct.</p>';
if (auditBallot.election_hash !== eosjs.eos.core.hashing.__all__.SHA256().update_obj(election).hash_as_b64()) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: The ballot corresponds to a different election.</p>';
return false;
}
auditResultInner.innerHTML += '<p><iclass="checkmark icon"></i> The ballot election hash is correct.</p>';
for (var questionNum = 0; questionNum <auditBallot.encrypted_answers.__len__();questionNum++){
auditResultInner.innerHTML += '<p><iclass="info circle icon"></i> Question number ' + (questionNum + 1) + ':</p>';
// Compute expected plaintexts
var pt = eosjs.eos.core.objects.__all__.EosObject.to_json(eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(auditBallot.answers.__getitem__(questionNum)));
var bs = eosjs.eos.psr.bitstream.__all__.BitStream();
var encryptedAnswer = auditBallot.encrypted_answers.__getitem__(questionNum);
for (var blockNum = 0; blockNum <encryptedAnswer.blocks.__len__();blockNum++){
var block = encryptedAnswer.blocks.__getitem__(blockNum);
// TODO: Implement this in Python
if (!block.randomness) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: Block ' + blockNum + ' ciphertext is not a valid audit ciphertext.</p>';
return false;
}
if (!block.is_signature_valid()) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: Block ' + blockNum + ' signature is not valid.</p>';
return false;
}
if (block.randomness.__lt__(eosjs.eos.core.bigint.__all__.ONE) || block.randomness.__gt__(election.public_key.group.p.__sub__(eosjs.eos.core.bigint.__all__.TWO))) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: Block ' + blockNum + ' randomness is not valid.</p>';
return false;
}
if (!block.is_randomness_valid()) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: Block ' + blockNum + ' randomness does not match ciphertext.</p>';
return false;
}
if (!block.m0.__eq__(election.public_key.message_to_m0(messages[blockNum]))) {
auditResultInner.innerHTML += '<p><iclass="remove icon"></i> Error: Block ' + blockNum + ' plaintext does not match claimed plaintext.</p>';
var auditContents = document.querySelector("#audit_contents");
auditContents.className = "ui warning message";
var auditContentsInner = document.querySelector("#audit_contents_inner");
auditContentsInner.innerHTML = '';
auditContentsInner.innerHTML += '<p><iclass="info circle icon"></i><b>Please check that the following details match your intended selections:</b></p>';
for (var questionNum = 0; questionNum <auditBallot.encrypted_answers.__len__();questionNum++){
auditContentsInner.innerHTML += '<p><iclass="info circle icon"></i><b>Please check that the ballot fingerprint you recorded matches the following computed ballot fingerprint: <spanclass="hash">' + eosjs.eos.core.hashing.__all__.SHA256().update_obj(auditBallot).hash_as_b64(true) + '</span>.</b></p>';
auditContentsInner.innerHTML += '<p><iclass="checkmark icon"></i> If the selections are correct, and the ballot fingerprint matches, then the ballot has been prepared correctly.</p>';