Standard library / crypto/ed25519
crypto/ed25519.Verify()
Verifies ordinary Ed25519 signature; malformed signatures return false, wrong public key length panics. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Verify(publicKey PublicKey, message, sig []byte) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| publicKey | PublicKey | Public verification key. |
| message | []byte | Message bytes or prehash as specified. |
| sig | []byte | Signature bytes to verify. |
Return Value
bool
Result as described above; check any returned error before use.
Working 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")) fmt.Println(ed25519.Verify(pub, []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) }}