Working prototype
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
@@ -10,9 +12,33 @@
|
||||
<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>
|
||||
{% endblock %}
|
||||
|
||||
<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 %}
|
||||
|
||||
18
abac/templates/upload_public_key.html.old
Normal file
18
abac/templates/upload_public_key.html.old
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends 'base.html' %}
|
||||
{% 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="submit" class="btn btn-primary">Upload Public Key</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user