Standard library / crypto/ecdsa
crypto/ecdsa.PublicKey
Embeds elliptic.Curve and holds X,Y coordinates. The embedded Curve exposes Add, Double, IsOnCurve, Params, ScalarBaseMult and ScalarMult; these are low-level point operations, not signature verification. They are also promoted through PrivateKey. Use VerifyASN1 for signatures and crypto/ecdh for key agreement. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type PublicKey struct { elliptic.Curve X, Y *big.Int}Working Example
Example Snippetgo
package main
import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "fmt")
func main() { k := must(ecdsa.GenerateKey(elliptic.P256(), rand.Reader)) var v ecdsa.PublicKey = k.PublicKey fmt.Println(v.Curve.IsOnCurve(v.X, v.Y))}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) }}