elliptic

package
v0.0.0-...-f8c0f81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2011 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package elliptic implements several standard elliptic curves over prime fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

type Curve struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the curve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
}

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

func P224

func P224() *Curve

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

func P256

func P256() *Curve

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

func P384

func P384() *Curve

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

func P521

func P521() *Curve

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

func (*Curve) Add

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

Add returns the sum of (x1,y1) and (x2,y2)

func (*Curve) Double

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

Double returns 2*(x,y)

func (*Curve) GenerateKey

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

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

func (*Curve) IsOnCurve

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

IsOnCurve returns true if the given (x,y) lies on the curve.

func (*Curve) Marshal

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

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

func (*Curve) ScalarBaseMult

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

ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.

func (*Curve) ScalarMult

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

ScalarMult returns k*(Bx,By) where k is a number in big-endian form.

func (*Curve) Unmarshal

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

Unmarshal converts a point, serialized by Marshal, into an x, y pair. On error, x = nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL