Skip to content

Commit

Permalink
added ability to verify one's secret key
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Jul 31, 2010
1 parent 8c0f02a commit 029425d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
1 change: 1 addition & 0 deletions election_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
(r'^/trustees/(?P<trustee_uuid>[^/]+)/home$', trustee_home),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/sendurl$', trustee_send_url),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/keygenerator$', trustee_keygenerator),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/check-sk$', trustee_check_sk),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/upoad-pk$', trustee_upload_pk),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/decrypt-and-prove$', trustee_decrypt_and_prove),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/upload-decryption$', trustee_upload_decryption),
Expand Down
78 changes: 78 additions & 0 deletions templates/trustee_check_sk.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{% extends "helios/templates/cryptobase.html" %}

{% block content %}
<script>
function reset() {
$('#processing').hide();
$('#result').html("");
$('#input').hide();
$('#loading').show();
BigInt.setup(function() {
$('#loading').hide();
$('#input').show();
});
}

$(document).ready(function() {
reset();
});

var PK_HASH = "{{trustee.public_key_hash}}";

function check_sk(sk_value) {
$('#input').hide();
$('#processing').show();

try {
var secret_key = ElGamal.SecretKey.fromJSONObject(jQuery.secureEvalJSON(sk_value));

var pk_hash = b64_sha256(jQuery.toJSON(secret_key.pk));
var key_ok_p = (pk_hash == PK_HASH);
} catch (e) {
debugger;
var key_ok_p = false;
}

$('#processing').hide();

var reset_link = "<br /><a href='javascript:reset();'>try again</a>";
if (key_ok_p) {
$('#result').html("your secret key matches!");
} else {
$('#result').html("OH OH, your key is bad." + reset_link);
}
}
</script>
<h2 class="title">{{election.name}} &mdash; Trustee {{trustee.name}} &mdash; Check Secret Key</span></h2>

<p>
Your public key fingerprint is: <b>{{trustee.public_key_hash}}</b>
</p>

<div id="loading">
loading crypto functions...
</div>

<div id="input" style="display:none;">
<p>
To verify that you have the right secret key, paste it here:
<p>

<form onsubmit="check_sk(this.secret_key.value); return false;">
<textarea name="secret_key" cols="60" rows ="5" wrap="soft">
</textarea>
<br />
<input type="submit" value="check" />
</form>
</div>

<div id="processing" style="display:none;">
checking your secret key...
</div>

<div id="result">
</div>


<div id="applet_div"></div>
{% endblock %}
3 changes: 2 additions & 1 deletion templates/trustee_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ <h2 class="title">{{election.name}} &mdash; Trustee {{trustee.name}} Home</span>
<p>
{% if trustee.public_key_hash %}
You have successfully uploaded your public key.<br />
Your public key fingerprint is: <b>{{trustee.public_key_hash}}</b>
Your public key fingerprint is: <b>{{trustee.public_key_hash}}</b>.<br />
You can <a href="{% url helios.views.trustee_check_sk election.uuid, trustee.uuid %}">verify that you have the right secret key</a>.
{% else %}
<a href="{% url helios.views.trustee_keygenerator election.uuid, trustee.uuid %}">setup your key</a>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ def trustee_send_url(request, election, trustee_uuid):
def trustee_home(request, election, trustee):
return render_template(request, 'trustee_home', {'election': election, 'trustee':trustee})

@trustee_check
def trustee_check_sk(request, election, trustee):
return render_template(request, 'trustee_check_sk', {'election': election, 'trustee':trustee})

@trustee_check
def trustee_upload_pk(request, election, trustee):
if request.method == "POST":
Expand Down

0 comments on commit 029425d

Please sign in to comment.