Changed around line 1
+ document.getElementById('generate').addEventListener('click', function() {
+ const passphrase = document.getElementById('passphrase').value.trim();
+
+ if (passphrase === '') {
+ alert('Please enter a passphrase');
+ return;
+ }
+
+ // Simple SHA-256 implementation for demonstration purposes
+ function sha256(input) {
+ const encoder = new TextEncoder();
+ const data = encoder.encode(input);
+ return crypto.subtle.digest('SHA-256', data)
+ .then(hash => {
+ return Array.from(new Uint8Array(hash))
+ .map(byte => byte.toString(16).padStart(2, '0'))
+ .join('');
+ });
+ }
+
+ sha256(passphrase).then(hash => {
+ // For demonstration purposes, we'll use the hash as the private key
+ const privateKey = hash;
+ const publicKey = '03' + hash.slice(0, 64); // Simplified public key generation
+ const address = '1' + hash.slice(0, 40); // Simplified address generation
+
+ document.getElementById('privateKey').value = privateKey;
+ document.getElementById('publicKey').value = publicKey;
+ document.getElementById('address').value = address;
+ document.getElementById('result').classList.remove('hidden');
+ });
+ });