Standard library / crypto

crypto.PublicKey

Algorithm-independent public-key container. Use type assertions or algorithm-specific parsers to establish the concrete type. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
type PublicKey any

Working Example

Example Snippetgo
package main
import (  "crypto"  "crypto/ed25519"  "crypto/rand"  "fmt")
func main() {  pub, priv, e := ed25519.GenerateKey(rand.Reader)  if e != nil {    panic(e)  }  var k crypto.PublicKey = pub  _, ok := k.(ed25519.PublicKey)  fmt.Println(ok, len(priv) > 0)}
Go Reference