Standard library / crypto/ecdh
crypto/ecdh.P521()
Returns the P521 curve for ECDH key agreement. Repeated calls compare equal; use a reviewed authenticated protocol and key derivation rather than raw shared secrets. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func P521() CurveReturn Value
Curve
Result as described above; check any returned error before use.
Working Example
Example Snippetgo
package main
import ( "crypto/ecdh" "crypto/rand" "fmt")
func main() { c := ecdh.P521() k := must(c.GenerateKey(rand.Reader)) fmt.Println(len(k.Bytes()) == 66)}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) }}