Standard library / crypto/ed25519
crypto/ed25519.NewKeyFromSeed()
Derives private key from exactly 32 secret bytes; wrong length panics. Use only for seed-based interoperability or restoration. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func NewKeyFromSeed(seed []byte) PrivateKeyParameters & Attributes
| Name | Type | Description |
|---|---|---|
| seed | []byte | Secret seed bytes of required size. |
Return Value
PrivateKey
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) v := ed25519.NewKeyFromSeed(k.Seed()) fmt.Println(v.Public().(ed25519.PublicKey).Equal(pub))}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) }}