Ind.ie is now Small Technology Foundation.
Commit 311cd111 authored by Aral Balkan's avatar Aral Balkan

Now generating passphrases via Diceware using EFF’s word list

parent 14dc8ea8
const session25519 = require('session25519')
const diceware = require('eff-diceware-passphrase')
const generateEFFDicewarePassphrase = require('eff-diceware-passphrase')
// From libsodium.
function to_hex(input) {
......@@ -20,29 +20,42 @@ function to_hex(input) {
return str;
}
// Main
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('password').focus()
// HTML elements.
const passphraseForm = document.getElementById('passphraseForm')
const publicSigningKeyTextField = document.getElementById('publicSigningKey')
const privateSigningKeyTextArea = document.getElementById('privateSigningKey')
const publicEncryptionKeyTextField = document.getElementById('publicEncryptionKey')
const privateEncryptionKeyTextField = document.getElementById('privateEncryptionKey')
document.getElementById('passwordForm').addEventListener('submit', (event) => {
const form = event.target
const password = form.elements.password.value
const domain = form.elements.domain.value
function generatePassphrase () {
const passphrase = generateEFFDicewarePassphrase.entropy(100)
passphraseForm.elements.passphrase.value = passphrase.join(' ')
generateKeys()
}
const publicSigningKeyTextField = document.getElementById('publicSigningKey')
const privateSigningKeyTextArea = document.getElementById('privateSigningKey')
const publicEncryptionKeyTextField = document.getElementById('publicEncryptionKey')
const privateEncryptionKeyTextField = document.getElementById('privateEncryptionKey')
function generateKeys() {
const passphrase = passphraseForm.elements.passphrase.value
const domain = passphraseForm.elements.domain.value
session25519(domain, password, (error, keys) => {
if (error) { alert(error); return }
session25519(domain, passphrase, (error, keys) => {
if (error) { alert(error); return }
publicSigningKeyTextField.value = to_hex(keys.publicSignKey)
privateSigningKeyTextArea.value = to_hex(keys.secretSignKey)
publicEncryptionKeyTextField.value = to_hex(keys.publicKey)
privateEncryptionKeyTextField.value = to_hex(keys.secretKey)
})
}
// Main
document.addEventListener('DOMContentLoaded', () => {
publicSigningKeyTextField.value = to_hex(keys.publicSignKey)
privateSigningKeyTextArea.value = to_hex(keys.secretSignKey)
publicEncryptionKeyTextField.value = to_hex(keys.publicKey)
privateEncryptionKeyTextField.value = to_hex(keys.secretKey)
})
// Generate a passphrase at start
generatePassphrase()
// Update the passphrase (and keys) when the change button is pressed.
passphraseForm.addEventListener('submit', (event) => {
generatePassphrase()
event.preventDefault()
})
})
......@@ -4,21 +4,21 @@
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>Hypha Aspect Setup Spike 1</title>
<title>Hypha Spike: DAT 1</title>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<h1>Hypha Aspect Setup Spike 1</h1>
<h1>Hypha Spike: DAT 1</h1>
<form id='passwordForm'>
<form id='passphraseForm'>
<fieldset>
<label for='domain'>Domain</label>
<input type='text' id='domain' value='ar.al'>
<input type='text' id='domain' value='ar.al' readonly>
</fieldset>
<fieldset>
<label>Choose a strong password (min 6 words):</label>
<input type='text' id='password'>
<button id='submit' type='submit'>Submit</button>
<label>Passphrase:</label>
<input type='text' id='passphrase' readonly>
<button id='change' type='submit'>Change</button>
</fieldset>
</form>
......
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