Commit 37684a7a authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add voter_id to NIZK proofs in ballots (client-side)

Backported from Helios-C branch. Only ballot generation code is
updated (not verification code).
parent f6dd7856
......@@ -35,7 +35,7 @@ function do_setup(message) {
function do_encrypt(message) {
console.log("encrypting answer for question " + ELECTION.questions[Q_NUM]);
var encrypted_answer = new HELIOS.EncryptedAnswer(ELECTION.questions[Q_NUM], message.answer, ELECTION.public_key);
var encrypted_answer = new HELIOS.EncryptedAnswer(ELECTION.questions[Q_NUM], message.answer, ELECTION.public_key, message.voter_id);
console.log("done encrypting");
......
......@@ -525,7 +525,7 @@ ElGamal.DLogProof.fromJSONObject = function(d) {
// a challenge generator based on a list of commitments of
// proofs of knowledge of plaintext. Just appends A and B with commas.
ElGamal.disjunctive_challenge_generator = function(commitments) {
ElGamal.disjunctive_challenge_generator = function(id) { return function(commitments) {
var strings_to_hash = [];
// go through all proofs and append the commitments
......@@ -537,8 +537,8 @@ ElGamal.disjunctive_challenge_generator = function(commitments) {
// console.log(strings_to_hash);
// STRINGS = strings_to_hash;
return new BigInt(hex_sha1(strings_to_hash.join(",")), 16);
};
return new BigInt(hex_sha1("prove|" + id + "|" + strings_to_hash.join(",")), 16);
}};
// a challenge generator for Fiat-Shamir
ElGamal.fiatshamir_challenge_generator = function(commitment) {
......
......@@ -216,7 +216,7 @@ UTILS.generate_plaintexts = function(pk, min, max) {
HELIOS.EncryptedAnswer = Class.extend({
init: function(question, answer, pk, progress) {
init: function(question, answer, pk, id, progress) {
// if nothing in the constructor
if (question == null)
return;
......@@ -226,7 +226,7 @@ HELIOS.EncryptedAnswer = Class.extend({
this.answer = answer;
// do the encryption
var enc_result = this.doEncryption(question, answer, pk, null, progress);
var enc_result = this.doEncryption(question, answer, pk, id, null, progress);
this.choices = enc_result.choices;
this.randomness = enc_result.randomness;
......@@ -234,7 +234,7 @@ HELIOS.EncryptedAnswer = Class.extend({
this.overall_proof = enc_result.overall_proof;
},
doEncryption: function(question, answer, pk, randomness, progress) {
doEncryption: function(question, answer, pk, id, randomness, progress) {
var choices = [];
var individual_proofs = [];
var overall_proof = null;
......@@ -278,7 +278,7 @@ HELIOS.EncryptedAnswer = Class.extend({
// generate proof
if (generate_new_randomness) {
// generate proof that this ciphertext is a 0 or a 1
individual_proofs[i] = choices[i].generateDisjunctiveProof(zero_one_plaintexts, plaintext_index, randomness[i], ElGamal.disjunctive_challenge_generator);
individual_proofs[i] = choices[i].generateDisjunctiveProof(zero_one_plaintexts, plaintext_index, randomness[i], ElGamal.disjunctive_challenge_generator(id));
}
if (progress)
......@@ -306,7 +306,7 @@ HELIOS.EncryptedAnswer = Class.extend({
if (question.min)
overall_plaintext_index -= question.min;
overall_proof = hom_sum.generateDisjunctiveProof(plaintexts, overall_plaintext_index, rand_sum, ElGamal.disjunctive_challenge_generator);
overall_proof = hom_sum.generateDisjunctiveProof(plaintexts, overall_plaintext_index, rand_sum, ElGamal.disjunctive_challenge_generator(id));
if (progress) {
for (var i=0; i<question.max; i++)
......
......@@ -167,6 +167,7 @@ BOOTH.setup_election = function(raw_json) {
// appears to be safer.
BOOTH.election = HELIOS.Election.fromJSONString(raw_json);
BOOTH.election.cast_url = "/election/cast?uuid=" + BOOTH.election.uuid
BOOTH.voter_id = "ID"; // placeholder for later
// FIXME: we shouldn't need to set both, but right now we are doing so
// because different code uses each one. Bah. Need fixing.
......@@ -205,6 +206,7 @@ BOOTH.launch_async_encryption_answer = function(question_num) {
BOOTH.workers[question_num].postMessage({
'type' : 'encrypt',
'answer' : BOOTH.ballot.answers[question_num],
'voter_id' : BOOTH.voter_id,
'id' : BOOTH.answer_timestamps[question_num]
});
};
......@@ -464,7 +466,7 @@ BOOTH.seal_ballot_raw = function() {
if (BOOTH.synchronous) {
BOOTH.progress = new UTILS.PROGRESS();
var progress_interval = setInterval("BOOTH.check_encryption_status()", 500);
BOOTH.encrypted_ballot = new HELIOS.EncryptedVote(BOOTH.election, BOOTH.ballot.answers, BOOTH.progress);
BOOTH.encrypted_ballot = new HELIOS.EncryptedVote(BOOTH.election, BOOTH.ballot.answers, BOOTH.progress, BOOTH.voter_id);
clearInterval(progress_interval);
BOOTH._after_ballot_encryption();
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment