Documentation ¶
Overview ¶
Package elliptic implements several standard elliptic curves over prime finite fields of the form: y^2 = x^3 + a*x + b (mod p)
Index ¶
- Variables
- func Marshal(curve Curve, x, y *big.Int) []byte
- func MarshalCompressed(curve Curve, x, y *big.Int) []byte
- func Unmarshal(curve Curve, buf []byte) (x, y *big.Int, err error)
- type Curve
- type CurveParams
- func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
- func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool
- func (curve *CurveParams) Params() *CurveParams
- func (curve *CurveParams) ScalarBaseMult(k *big.Int) (x, y *big.Int)
- func (curve *CurveParams) ScalarMult(x1, y1, k *big.Int) (x, y *big.Int)
Constants ¶
This section is empty.
Variables ¶
View Source
var Secp256k1 = new(CurveParams)
Bitcoin's secp256k1 elliptic curve Reference: https://en.bitcoin.it/wiki/Secp256k1
Functions ¶
func MarshalCompressed ¶
MarshalCompressed serializes a point (x,y) in a compressed SEC format.
Types ¶
type Curve ¶
type Curve interface { // Params returns the parameters for the curve. Params() *CurveParams // IsOnCurve reports whether the given (x,y) lies on the curve. IsOnCurve(x, y *big.Int) bool // Add returns the sum of (x1,y1) and (x2,y2) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int) // ScalarMult returns k*(x1, y1) ScalarMult(x1, y1, k *big.Int) (x, y *big.Int) // ScalarBaseMult returns k*G, where G is the base point of the group ScalarBaseMult(k *big.Int) (x, y *big.Int) }
type CurveParams ¶
type CurveParams struct { P *big.Int // the order of the underlying finite field N *big.Int // the order of the base (generator) point A *big.Int // the constant of the curve equation 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 Name string // the canonical name of the curve }
CurveParams contains the parameters of an elliptic curve and also provides a generic implementation of Curve.
func (*CurveParams) Params ¶
func (curve *CurveParams) Params() *CurveParams
func (*CurveParams) ScalarBaseMult ¶
func (curve *CurveParams) ScalarBaseMult(k *big.Int) (x, y *big.Int)
func (*CurveParams) ScalarMult ¶
func (curve *CurveParams) ScalarMult(x1, y1, k *big.Int) (x, y *big.Int)
Click to show internal directories.
Click to hide internal directories.