Documentation ¶
Overview ¶
Package elliptic implements several standard elliptic curves over prime fields.
Index ¶
- func GenerateKey(curve elliptic.Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)
- func Marshal(curve elliptic.Curve, x, y *big.Int) []byte
- func MarshalCompressed(curve elliptic.Curve, x, y *big.Int) []byte
- func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)
- func UnmarshalCompressed(curve EnhancedCurve, data []byte) (x, y *big.Int)
- type EnhancedCurve
- type EnhancedCurveParams
- func (curve *EnhancedCurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
- func (curve *EnhancedCurveParams) CustomParams() *EnhancedCurveParams
- func (curve *EnhancedCurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (curve *EnhancedCurveParams) IsOnCurve(x, y *big.Int) bool
- func (curve *EnhancedCurveParams) Params() *elliptic.CurveParams
- func (curve *EnhancedCurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- func (curve *EnhancedCurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey returns a public/private key pair. The private key is generated using the given reader, which must return random data.
func Marshal ¶
Marshal converts a point on the curve into the uncompressed form specified in section 4.3.6 of ANSI X9.62.
func MarshalCompressed ¶
MarshalCompressed converts a point on the curve into the compressed form specified in section 4.3.6 of ANSI X9.62.
func Unmarshal ¶
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) CustomParams ¶
func (curve *EnhancedCurveParams) CustomParams() *EnhancedCurveParams
func (*EnhancedCurveParams) IsOnCurve ¶
func (curve *EnhancedCurveParams) IsOnCurve(x, y *big.Int) bool
func (*EnhancedCurveParams) Params ¶
func (curve *EnhancedCurveParams) Params() *elliptic.CurveParams