The generic functionality of the event_vote page has been replicated in the sense that if access is denied to event_setup or event_decrypt, a client is not directed to a page that they don't have access to. Instead, they're kept on the same page and are told why access to that page has been denied. Furthermore, the POSTing of data to the back-end on both of these updated page is now done using Ajax requests where dialogs update the user rather than redirecting to a page the user doesn't have access to.
This commit is contained in:
parent
b35495462b
commit
bd9c35102e
6 changed files with 311 additions and 178 deletions
|
@ -22,6 +22,7 @@
|
|||
<script src="{% static 'js/event_vote.js' %}" type="text/javascript"></script>
|
||||
<script src="{% static 'js/vote_audit.js' %}" type="text/javascript"></script>
|
||||
<script src="{% static 'js/encrypt.js' %}" type="text/javascript"></script>
|
||||
<script src="{% static 'js/event_setup.js' %}" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript" src="{% static 'js/core/rand.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/core/rom_curve.js' %}"></script>
|
||||
|
@ -66,73 +67,6 @@
|
|||
|
||||
}
|
||||
|
||||
function getBytes(arr) {
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
arr[i] = parseInt(arr[i]);
|
||||
}
|
||||
|
||||
return new Uint8Array(arr);
|
||||
}
|
||||
|
||||
//new function
|
||||
demosEncrypt.decryptSubmitCiphers = function() {
|
||||
|
||||
};
|
||||
|
||||
//new function
|
||||
demosEncrypt.generateKeys = function() {
|
||||
var parameter = $("#event-param").val();
|
||||
var tempParams = JSON.parse(JSON.parse(parameter).crypto);
|
||||
//the full objects need to be initalised as per the library, then copy the values we need into it
|
||||
//I follow Bingsheng's code as to what objects are used in the parameter object
|
||||
var ctx = new CTX("BN254CX"); //new context we can use
|
||||
var n = new ctx.BIG();
|
||||
var g1 = new ctx.ECP();
|
||||
var g2 = new ctx.ECP2();
|
||||
|
||||
//copying the values
|
||||
n.copy(tempParams.n);
|
||||
g1.copy(tempParams.g1);
|
||||
g2.copy(tempParams.g2);
|
||||
|
||||
var params = {
|
||||
n:n,
|
||||
g1:g1,
|
||||
g2:g2
|
||||
}
|
||||
|
||||
var PKbytes = [];
|
||||
var SKbytes = [];
|
||||
|
||||
var keypair = keyGen(params);
|
||||
keypair.PK.toBytes(PKbytes);
|
||||
keypair.SK.toBytes(SKbytes);
|
||||
|
||||
var PKB64Encoded = "";
|
||||
for(let i = 0; i < PKbytes.length; i++) {
|
||||
PKB64Encoded += btoa(PKbytes[i]);
|
||||
}
|
||||
|
||||
var SKB64Encoded = "";
|
||||
for(let j = 0; j < SKbytes.length; j++) {
|
||||
SKB64Encoded += btoa(SKbytes[j]);
|
||||
}
|
||||
|
||||
$('input#public-key').val(PKB64Encoded);
|
||||
$('input#secret-key').val(SKB64Encoded);
|
||||
|
||||
//mostly code from before here
|
||||
var blob = new Blob([SKB64Encoded], {type : 'text/plain'});
|
||||
|
||||
var dlBtn = $('a#download-btn');
|
||||
var url = URL.createObjectURL(blob);
|
||||
var fileName = $(dlBtn).attr("href", url);
|
||||
|
||||
$(dlBtn).attr("download", "sk-{% block sk-file-name %}{% endblock %}".replace(/[\W]/g, "-"));
|
||||
$(dlBtn).attr("disabled", false);
|
||||
$("#public-submit").attr("disabled", false);
|
||||
}
|
||||
|
||||
//these other functions might not be used
|
||||
//I don't think this is used
|
||||
demosEncrypt.downloadSecretKey = function() {
|
||||
|
|
Reference in a new issue