blob: 8288fd1d813e748c018276a5a083ac9d70649cfe (
plain) (
blame)
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
|
package main
import (
"crypto/ed25519"
"crypto/rand"
"encoding/hex"
"fmt"
"os"
)
func wipe(b []byte) {
for i := range b {
b[i] = 0
}
}
func main() {
publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to generate ED25519 key: %s", err)
os.Exit(1)
}
defer wipe(privateKey)
enc := hex.NewEncoder(os.Stdout)
print("Public ")
enc.Write(publicKey)
print("\nPrivate ")
enc.Write(privateKey.Seed())
println()
}
|