I really ought to be using branches
This commit is contained in:
parent
89533a54b1
commit
9ea59723a5
3 changed files with 36 additions and 17 deletions
|
@ -113,11 +113,11 @@ def edit_poll(request, event_id, poll_id):
|
||||||
|
|
||||||
|
|
||||||
def vote_audit(request):
|
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",
|
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
|
# 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():
|
if EncBallot.objects.filter(handle=handle_json).exists():
|
||||||
b = EncBallot.objects.get(handle=handle_json)
|
b = EncBallot.objects.get(handle=handle_json)
|
||||||
b.ballot = ballot_json
|
b.ballot = enc_ballot_json
|
||||||
b.save()
|
b.save()
|
||||||
else:
|
else:
|
||||||
b = EncBallot(handle=handle_json, ballot=enc_ballot_json)
|
b = EncBallot(handle=handle_json, ballot=enc_ballot_json)
|
||||||
|
|
|
@ -319,7 +319,6 @@ function showFirstQRCode(ballotA, ballotB) {
|
||||||
|
|
||||||
footer.prepend(nextButton);
|
footer.prepend(nextButton);
|
||||||
|
|
||||||
|
|
||||||
modalDialog.modal('show');
|
modalDialog.modal('show');
|
||||||
|
|
||||||
$('#next-button').click(function(e) {
|
$('#next-button').click(function(e) {
|
||||||
|
@ -450,6 +449,9 @@ function onAfterBallotSend(ballotID, SK) {
|
||||||
closeButton.removeClass('btn-danger');
|
closeButton.removeClass('btn-danger');
|
||||||
closeButton.addClass('btn-success');
|
closeButton.addClass('btn-success');
|
||||||
closeButton.text("Close");
|
closeButton.text("Close");
|
||||||
|
if(POLL_NUM == POLL_COUNT) {
|
||||||
|
$('#next-button').hide();
|
||||||
|
}
|
||||||
|
|
||||||
modalDialog.modal('show');
|
modalDialog.modal('show');
|
||||||
}
|
}
|
|
@ -1,17 +1,34 @@
|
||||||
$('#begin-test').click(function() {
|
$('#begin-test').click(function() {
|
||||||
var ballot = JSON.parse(sjcl.decrypt($('#SK').val(), $('#ballot').text()));
|
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;
|
var votes = ballot['encryptedVotes'];
|
||||||
votes.forEach(function(cT) {
|
$('#ballot-content').text(JSON.stringify(votes));
|
||||||
option++;
|
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 = "";
|
var encoding = "";
|
||||||
for (var i = 0; i < cT['C1'].length; i++) {
|
console.log(fragment);
|
||||||
cipherText = "("+cT['C1']+","+cT['C2']+")";
|
|
||||||
var m = cT['C2'][i] / Math.pow(cT['C1'][i], cT['r'][i]);
|
// 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";
|
encoding += (m) ? "1" : "0";
|
||||||
}
|
}
|
||||||
$('#ballot-result').text($('#ballot-result').text() + "\n\nOption "+option+": "+encoding);
|
|
||||||
})
|
// 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 ");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
Reference in a new issue