Added Go utility to generate keys

This commit is contained in:
Nirmal N R
2025-10-31 17:08:52 +05:30
parent 7f5d46f1c9
commit 948b5251bd

View File

@@ -0,0 +1,30 @@
package main
/*
To run this code and generate a new Ed25519 key pair, use the following command:
go run install/generate-ed25519-keys.go
*/
import (
"crypto/ed25519"
"encoding/base64"
"fmt"
"log"
)
func main() {
// Generate a new Ed25519 key pair using rand.Reader as default
publicKey, privateKey, err := ed25519.GenerateKey(nil)
if err != nil {
log.Fatal("Failed to generate key pair:", err)
}
// The private key contains both seed and public key (64 bytes total)
// We need to extract just the seed (first 32 bytes)
seed := privateKey[:ed25519.SeedSize]
fmt.Println("=== Ed25519 Key Pair ===")
fmt.Printf("signingPrivateKey: %s\n", base64.StdEncoding.EncodeToString(seed))
fmt.Printf("signingPublicKey: %s\n", base64.StdEncoding.EncodeToString(publicKey))
}