I really ought to be using branches

This commit is contained in:
Rumperuu 2018-08-29 14:29:27 +01:00
parent 89533a54b1
commit 9ea59723a5
3 changed files with 36 additions and 17 deletions

View File

@ -113,11 +113,11 @@ def edit_poll(request, event_id, poll_id):
def vote_audit(request):
encryptedBallot = get_object_or_404(EncBallot, handle=''+urllib.quote_plus(request.GET.get('handle', None)))
encrypted_ballot = get_object_or_404(EncBallot, handle=''+urllib.quote_plus(request.GET.get('handle', None)))
return render(request, "polls/vote_audit.html",
{
"ballot": encryptedBallot.ballot
"ballot": encrypted_ballot.ballot
})
@ -192,7 +192,7 @@ def event_vote(request, event_id, poll_id):
# Adds or replaces the encrypted un-submitted ballot to the database for the auditor app to pick up later
if EncBallot.objects.filter(handle=handle_json).exists():
b = EncBallot.objects.get(handle=handle_json)
b.ballot = ballot_json
b.ballot = enc_ballot_json
b.save()
else:
b = EncBallot(handle=handle_json, ballot=enc_ballot_json)

View File

@ -319,7 +319,6 @@ function showFirstQRCode(ballotA, ballotB) {
footer.prepend(nextButton);
modalDialog.modal('show');
$('#next-button').click(function(e) {
@ -450,6 +449,9 @@ function onAfterBallotSend(ballotID, SK) {
closeButton.removeClass('btn-danger');
closeButton.addClass('btn-success');
closeButton.text("Close");
if(POLL_NUM == POLL_COUNT) {
$('#next-button').hide();
}
modalDialog.modal('show');
}

View File

@ -1,17 +1,34 @@
$('#begin-test').click(function() {
var ballot = JSON.parse(sjcl.decrypt($('#SK').val(), $('#ballot').text()));
var votes = ballot['encryptedVotes'][0]['fragments'];
$('#ballot-content').text(JSON.stringify(votes));
var option = 0;
votes.forEach(function(cT) {
option++;
var encoding = "";
for (var i = 0; i < cT['C1'].length; i++) {
cipherText = "("+cT['C1']+","+cT['C2']+")";
var m = cT['C2'][i] / Math.pow(cT['C1'][i], cT['r'][i]);
encoding += (m) ? "1" : "0";
}
$('#ballot-result').text($('#ballot-result').text() + "\n\nOption "+option+": "+encoding);
})
var votes = ballot['encryptedVotes'];
$('#ballot-content').text(JSON.stringify(votes));
var voteNum = 0, optionNum = 0;
// For each encrypted vote within the ballot...
votes.forEach(function(vote) {
voteNum++;
$('#ballot-result').text($('#ballot-result').text() + "Vote " + voteNum + ": \n ");
// For each encrypted fragment within the vote (i.e. the presence of a vote for each option)...
vote['fragments'].forEach(function(fragment) {
optionNum++;
$('#ballot-result').text($('#ballot-result').text() + "Option " + optionNum + ": \n ");
var encoding = "";
console.log(fragment);
// For each pair of values in C1 and C2 and the randomness r, test whether C2/(C1)^r = g^0 or g^1, and
// record g's exponent.
for (var i = 0; i < fragment['C1'].length; i++) {
cipherText = "("+fragment['C1']+","+fragment['C2']+")";
var m = fragment['C2'][i] / Math.pow(fragment['C1'][i], fragment['r'][i]);
encoding += (m) ? "1" : "0";
}
// Somehow, this string of 1s and 0s here needs to become _one_ 1 or 0 to signify whether the option was
// voted for or not.
$('#ballot-result').text($('#ballot-result').text() + encoding + "\n ");
});
});
});