Overview

Package elliptic implements several standard elliptic curves over prime fields.

p224.go

func GenerateKey

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

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

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 []) (x, y *big.)

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.

  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 *.Int)
  6. // Add returns the sum of (x1,y1) and (x2,y2)
  7. Add(x1, y1, x2, y2 *big.) (x, y *big.)
  8. // Double returns 2*(x,y)
  9. Double(x1, y1 *big.) (x, y *big.)
  10. // ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
  11. ScalarMult(x1, y1 *big., k []byte) (x, y *.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. }

func

  1. func P224()

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

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.

  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

  1. func P521()

The cryptographic operations do not use constant-time algorithms.

type CurveParams

  1. type CurveParams struct {
  2. P *big. // the order of the underlying field
  3. N *big. // the order of the base point
  4. B *big. // the constant of the curve equation
  5. Gx, Gy *big. // (x,y) of the base point
  6. BitSize int // the size of the underlying field
  7. Name // 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 *.Int) (*.Int, *.Int)

func (*CurveParams)

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

func (*CurveParams)

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

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

func (*CurveParams)