You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.7 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block content %}
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<h2>Upload Public Key</h2>
<form method="post" class="mt-3">
{% csrf_token %}
<div class="form-group">
<label for="public_key">Paste your public key here:</label>
<textarea id="public_key" name="public_key" class="form-control" rows="6" required></textarea>
</div>
<button type="button" id="generateKey" class="btn btn-secondary">Generate Key</button>
<button type="submit" class="btn btn-primary">Upload Public Key</button>
</form>
</div>
</div>
</div>
<script src="{% static 'abac/jsbn.js' %}"></script>
<script src="{% static 'abac/jsbn2.js' %}"></script>
<script src="{% static 'abac/prng4.js' %}"></script>
<script src="{% static 'abac/rng.js' %}"></script>
<script src="{% static 'abac/paillier.js' %}"></script>
<script>
document.getElementById('generateKey').addEventListener('click', function() {
var keys = paillier.generateKeys(2048); // Generate a 2048-bit key pair
var publicKey = keys.pub.n.toString(); // Extract the public key 'n' value
var privateKey = {
lambda: keys.sec.lambda.toString(),
x: keys.sec.x.toString()
};
// Update the public_key textarea with the public key
document.getElementById('public_key').value = publicKey;
// Store keys in local web storage
localStorage.setItem('publicKey', publicKey);
localStorage.setItem('privateKey', JSON.stringify(privateKey));
});
</script>
{% endblock %}