-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
93 lines (91 loc) · 2.37 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Public Key Generator</title>
<style>
body {
background: linear-gradient(135deg, #9d50bb, #6e48aa);
color: #fff;
font-family: 'Arial', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
position: relative;
}
.container {
background-color: rgba(106, 57, 171, 0.8);
padding: 30px;
border-radius: 15px;
text-align: center;
width: 620px;
}
h1,
label,
p {
font-size: 18px;
margin: 15px 0;
}
input {
width: 80%;
padding: 12px;
font-size: 18px;
border: none;
border-radius: 5px;
margin-top: 10px;
}
p {
color: #ffa07a;
font-weight: bold;
}
a {
position: absolute;
bottom: 10px;
right: 10px;
color: #fff;
font-size: 14px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Public Key Generator</h1>
<label for="dataInput">Enter private key (hex):</label>
<input type="text" id="dataInput" oninput="calculatePublicKey()" />
<p id="output"></p>
</div>
<a
href="https://github.com/brain-wallet/getpublickey"
target="_blank"
rel="noopener noreferrer"
>View Source</a
>
<script type="module">
import { getPublicKey } from 'https://esm.sh/nostr-tools'
window.calculatePublicKey = async () => {
const data = document.getElementById('dataInput').value
try {
const privateKeyBytes = new Uint8Array(
data.match(/.{1,2}/g).map(byte => parseInt(byte, 16))
)
const publicKey = getPublicKey(privateKeyBytes)
document.getElementById(
'output'
).innerText = `Public key: ${Array.from(publicKey)
.map(byte => byte.toString(16))
.join('')}`
} catch (err) {
document.getElementById('output').innerText = `Error: ${err.message}`
}
}
</script>
</body>
</html>