Standard library / crypto/ed25519
crypto/ed25519.PublicKey
32-byte public verification key; validate length before Verify on untrusted input. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type PublicKey []byteWorking Example
Example Snippetgo
package main
import ( "crypto/ed25519" "crypto/rand" "fmt")
func main() { pub, k, err := ed25519.GenerateKey(rand.Reader) check(err) s := ed25519.Sign(k, []byte("Go")) var v ed25519.PublicKey = pub fmt.Println(ed25519.Verify(v, []byte("Go"), s))}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}