Standard library / crypto
crypto.PrivateKey
Algorithm-independent key container; an empty interface does not guarantee signing, decryption or even that the value is a key. Prefer purpose-specific interfaces; never log private keys. Expected stdout: 'true 32\n'.
Formal Syntax & Structure
go syntaxgo
type PrivateKey anyWorking 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.PrivateKey = priv _, ok := k.(crypto.Signer) fmt.Println(ok, len(pub))}