crypto/ecdsa

Guided tour · Crypto · pkg.go.dev →

ECDSA signatures (P-256 etc.). More widely interoperable than Ed25519; used in TLS, JWT ES256.

Sign and verify

P-256 round-trip

priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)

hash := sha256.Sum256([]byte("hello"))
sig, _ := ecdsa.SignASN1(rand.Reader, priv, hash[:])
ok := ecdsa.VerifyASN1(&priv.PublicKey, hash[:], sig)
fmt.Println(ok)