Updated various parts of the application to improve usability. Started laying some of the ground work for a bulletin board. Added informative emails that keep voters, trustees and organisers updated with the state of an event.
This commit is contained in:
parent
59d3b26e95
commit
25a7f72160
7 changed files with 138 additions and 57 deletions
|
@ -1,3 +1,8 @@
|
|||
// -------------- Global vars --------------------
|
||||
var filesHandleSK = document.getElementById('files_sk_upload');
|
||||
var CSRF = $( "input[name='csrfmiddlewaretoken']" ).val();
|
||||
|
||||
// -------------- Helper fns --------------------
|
||||
//SK checking algorithm - If PK and SK matches, it returns True; otherwise, it returns false.
|
||||
// Written by Bingsheng Zhang
|
||||
function skCheck(ctx, params, SK, PK) {
|
||||
|
@ -5,6 +10,29 @@ function skCheck(ctx, params, SK, PK) {
|
|||
return D.equals(PK)
|
||||
}
|
||||
|
||||
function csrfSafeMethod(method) {
|
||||
// these HTTP methods do not require CSRF protection
|
||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||
}
|
||||
|
||||
function showDialog(titleTxt, bodyTxt) {
|
||||
var modalDialog = $('#modalDialog');
|
||||
var title = modalDialog.find('.modal-title');
|
||||
var body = modalDialog.find('.modal-body');
|
||||
|
||||
title.text(titleTxt);
|
||||
var bodyText = bodyTxt;
|
||||
|
||||
var p = document.createElement("p");
|
||||
p.innerHTML = bodyText;
|
||||
body.empty();
|
||||
body.append( p );
|
||||
|
||||
modalDialog.modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
||||
function validateSKFromString(SKStr) {
|
||||
// Re-create the SK from the string byte definition
|
||||
let ctx = new CTX("BN254CX");
|
||||
|
@ -38,20 +66,44 @@ function validateSKFromString(SKStr) {
|
|||
return skCheck(ctx, params, sk, pk);
|
||||
}
|
||||
|
||||
function showDialog(titleTxt, bodyTxt) {
|
||||
var modalDialog = $('#modalDialog');
|
||||
var title = modalDialog.find('.modal-title');
|
||||
var body = modalDialog.find('.modal-body');
|
||||
function decryptSubmitCiphers() {
|
||||
var skString = $('#secret-key').val();
|
||||
|
||||
title.text(titleTxt);
|
||||
var bodyText = bodyTxt;
|
||||
if (!skString) {
|
||||
showDialog('Error', 'You haven\'t supplied your secret key. Please go back and upload this from file.');
|
||||
}
|
||||
else {
|
||||
// Rebuild the trustee's secret key
|
||||
var ctx = new CTX("BN254CX");
|
||||
var skBytes = skString.split(",");
|
||||
var sk = new ctx.BIG.fromBytes(skBytes);
|
||||
|
||||
var p = document.createElement("p");
|
||||
p.innerHTML = bodyText;
|
||||
body.empty();
|
||||
body.append( p );
|
||||
var inputs = $("form input[type=text]");
|
||||
|
||||
modalDialog.modal('show');
|
||||
inputs.each(function() { //for each ciphertext to decrypt
|
||||
let input = $(this);
|
||||
console.log(input.attr('name'));
|
||||
|
||||
var ciphertext = {
|
||||
C1: null,
|
||||
C2: null
|
||||
};
|
||||
|
||||
var temp = JSON.parse(input.val());
|
||||
var c1Bytes = getBytes(temp.C1.split(','));
|
||||
ciphertext.C1 = new ctx.ECP.fromBytes(c1Bytes);
|
||||
|
||||
var c2Bytes = getBytes(temp.C2.split(','));
|
||||
ciphertext.C2 = new ctx.ECP.fromBytes(c2Bytes);
|
||||
|
||||
// Perform partial decryption where the method returns an object containing an ECP()
|
||||
var partial = partDec(sk, ciphertext);
|
||||
|
||||
var bytes = [];
|
||||
partial.D.toBytes(bytes);
|
||||
input.val(bytes.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function processFileSKChange(event) {
|
||||
|
@ -85,8 +137,6 @@ function processFileSKChange(event) {
|
|||
}
|
||||
}
|
||||
|
||||
var filesHandleSK = document.getElementById('files_sk_upload');
|
||||
|
||||
if(filesHandleSK) {
|
||||
filesHandleSK.addEventListener('change', processFileSKChange, false);
|
||||
}
|
Reference in a new issue