Standard library / crypto/ed25519
crypto/ed25519.Options
Hash 0 selects ordinary Ed25519 or Ed25519ctx when Context is nonempty; SHA512 selects Ed25519ph. Context max 255 bytes. Match options during verification. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type Options struct { Hash crypto.Hash
Context string}Working Example
Example Snippetgo
package main
import ( "crypto/ed25519" "crypto/rand" "fmt")
func main() { pub, k, err := ed25519.GenerateKey(rand.Reader) check(err) o := &ed25519.Options{Context: "demo"} s := must(k.Sign(nil, []byte("Go"), o)) fmt.Println(ed25519.VerifyWithOptions(pub, []byte("Go"), s, o) == nil)}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) }}