Standard library / crypto/ed25519
crypto/ed25519.PublicKey.Equal()
Checks equality with another Ed25519 public key. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (pub PublicKey) Equal(x crypto.PublicKey) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | crypto.PublicKey | Other key to compare. |
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) fmt.Println(pub.Equal(k.Public()))}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) }}