Use the crypto/ed25519 package to generate a key pair with ed25519.GenerateKey() and sign or verify data using the public key and signature bytes.
package main
import (
"crypto/ed25519"
"fmt"
)
func main() {
// Generate key pair
public, private, err := ed25519.GenerateKey(nil)
if err != nil {
panic(err)
}
// Sign a message
message := []byte("Hello, World!")
signature := ed25519.Sign(private, message)
// Verify the signature
if ed25519.Verify(public, message, signature) {
fmt.Println("Signature is valid")
} else {
fmt.Println("Signature is invalid")
}
}