version: 1.10

package elliptic

import "crypto/elliptic"

Overview

Package elliptic implements several standard elliptic curves over prime fields.

Index

Package files

elliptic.go p224.go p256_amd64.go

func GenerateKey

  1. func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)

GenerateKey returns a public/private key pair. The private key is generated
using the given reader, which must return random data.

func Marshal

  1. func Marshal(curve Curve, x, y *big.Int) []byte

Marshal converts a point into the uncompressed form specified in section 4.3.6
of ANSI X9.62.

func Unmarshal

  1. func Unmarshal(curve Curve, data []byte) (x, y *big.Int)

Unmarshal converts a point, serialized by Marshal, into an x, y pair. It is an
error if the point is not in uncompressed form or is not on the curve. On error,
x = nil.

type Curve

  1. type Curve interface {
  2. // Params returns the parameters for the curve.
  3. Params() *CurveParams
  4. // IsOnCurve reports whether the given (x,y) lies on the curve.
  5. IsOnCurve(x, y *big.Int) bool
  6. // Add returns the sum of (x1,y1) and (x2,y2)
  7. Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
  8. // Double returns 2*(x,y)
  9. Double(x1, y1 *big.Int) (x, y *big.Int)
  10. // ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
  11. ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)
  12. // ScalarBaseMult returns k*G, where G is the base point of the group
  13. // and k is an integer in big-endian form.
  14. ScalarBaseMult(k []byte) (x, y *big.Int)
  15. }

A Curve represents a short-form Weierstrass curve with a=-3. See
http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

func P224

  1. func P224() Curve

P224 returns a Curve which implements P-224 (see FIPS 186-3, section D.2.2).

The cryptographic operations are implemented using constant-time algorithms.

func P256

  1. func P256() Curve

P256 returns a Curve which implements P-256 (see FIPS 186-3, section D.2.3)

The cryptographic operations are implemented using constant-time algorithms.

func P384

  1. func P384() Curve

P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4)

The cryptographic operations do not use constant-time algorithms.

func P521

  1. func P521() Curve

P521 returns a Curve which implements P-521 (see FIPS 186-3, section D.2.5)

The cryptographic operations do not use constant-time algorithms.

type CurveParams

  1. type CurveParams struct {
  2. P *big.Int // the order of the underlying field
  3. N *big.Int // the order of the base point
  4. B *big.Int // the constant of the curve equation
  5. Gx, Gy *big.Int // (x,y) of the base point
  6. BitSize int // the size of the underlying field
  7. Name string // the canonical name of the curve
  8. }

CurveParams contains the parameters of an elliptic curve and also provides a
generic, non-constant time implementation of Curve.

func (*CurveParams) Add

  1. func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*CurveParams) Double

  1. func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*CurveParams) IsOnCurve

  1. func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool

func (*CurveParams) Params

  1. func (curve *CurveParams) Params() *CurveParams

func (*CurveParams) ScalarBaseMult

  1. func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*CurveParams) ScalarMult

  1. func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)