Skip to content

Commit 948b525

Browse files
committed
Added Go utility to generate keys
1 parent 7f5d46f commit 948b525

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

install/generate-ed25519-keys.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
/*
4+
To run this code and generate a new Ed25519 key pair, use the following command:
5+
go run install/generate-ed25519-keys.go
6+
*/
7+
8+
import (
9+
"crypto/ed25519"
10+
"encoding/base64"
11+
"fmt"
12+
"log"
13+
)
14+
15+
func main() {
16+
// Generate a new Ed25519 key pair using rand.Reader as default
17+
publicKey, privateKey, err := ed25519.GenerateKey(nil)
18+
if err != nil {
19+
log.Fatal("Failed to generate key pair:", err)
20+
}
21+
22+
// The private key contains both seed and public key (64 bytes total)
23+
// We need to extract just the seed (first 32 bytes)
24+
seed := privateKey[:ed25519.SeedSize]
25+
26+
fmt.Println("=== Ed25519 Key Pair ===")
27+
fmt.Printf("signingPrivateKey: %s\n", base64.StdEncoding.EncodeToString(seed))
28+
fmt.Printf("signingPublicKey: %s\n", base64.StdEncoding.EncodeToString(publicKey))
29+
30+
}

0 commit comments

Comments
 (0)