elliptic

package
v0.0.0-...-219d96f Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 3 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

func GenerateKey

func GenerateKey(curve elliptic.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

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

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

func MarshalCompressed

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

MarshalCompressed converts a point on the curve into the compressed form specified in section 4.3.6 of ANSI X9.62.

func Unmarshal

func Unmarshal(curve elliptic.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.

func UnmarshalCompressed

func UnmarshalCompressed(curve EnhancedCurve, data []byte) (x, y *big.Int)

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

Types

type EnhancedCurve

type EnhancedCurve interface {
	elliptic.Curve
	CustomParams() *EnhancedCurveParams
}

A EnhancedCurve represents a short-form Weierstrass curve with variable 'a' and 'b' polynomial parameters.

Note that the point at infinity (0, 0) is not considered on the curve, and although it can be returned by Add, Double, ScalarMult, or ScalarBaseMult, it can't be marshaled or unmarshaled, and IsOnCurve will return false for it.

type EnhancedCurveParams

type EnhancedCurveParams struct {
	elliptic.CurveParams
	A *big.Int // the constant of the curve equation: x³ + ax + b.
}

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

func (*EnhancedCurveParams) Add

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

func (*EnhancedCurveParams) CustomParams

func (curve *EnhancedCurveParams) CustomParams() *EnhancedCurveParams

func (*EnhancedCurveParams) Double

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

func (*EnhancedCurveParams) IsOnCurve

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

func (*EnhancedCurveParams) Params

func (curve *EnhancedCurveParams) Params() *elliptic.CurveParams

func (*EnhancedCurveParams) ScalarBaseMult

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

func (*EnhancedCurveParams) ScalarMult

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

Jump to

Keyboard shortcuts

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