-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to verify one's secret key
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} — Trustee {{trustee.name}} — 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters