Documentation ¶
Overview ¶
Package bitelliptic implements several Koblitz elliptic curves over prime fields.
This package operates, internally, on Jacobian coordinates. For a given (x, y) position on the curve, the Jacobian coordinates are (x1, y1, z1) where x = x1/z1² and y = y1/z1³. The greatest speedups come when the whole calculation can be performed within the transform (as in ScalarMult and ScalarBaseMult). But even for Add and Double, it's faster to apply and reverse the transform than to operate in affine coordinates.
Index ¶
- func CompressPoint(curve *Curve, X, Y *big.Int) (cp []byte)
- func LegendreSymbol(a, p *big.Int) int
- type Curve
- func (curve *Curve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
- func (curve *Curve) CompressPoint(X, Y *big.Int) (cp []byte)
- func (curve *Curve) DecompressPoint(cp []byte) (X, Y *big.Int, err error)
- func (curve *Curve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (curve *Curve) IsOnCurve(x, y *big.Int) bool
- func (curve *Curve) Params() *elliptic.CurveParams
- func (curve *Curve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- func (curve *Curve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)
- func (curve *Curve) Sqrt(a *big.Int) *big.Int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LegendreSymbol ¶
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 Koblitz Curve with a=0. See http://www.hyperellipticurve.org/EFD/g1p/auto-shortw.html
func S160 ¶
func S160() *Curve
S160 returns a Curve which implements secp160k1 (see SEC 2 section 2.4.1)
func S192 ¶
func S192() *Curve
S192 returns a Curve which implements secp192k1 (see SEC 2 section 2.5.1)
func S224 ¶
func S224() *Curve
S224 returns a Curve which implements secp224k1 (see SEC 2 section 2.6.1)
func S256 ¶
func S256() *Curve
S256 returns a Curve which implements secp256k1 (see SEC 2 section 2.7.1)
func (*Curve) CompressPoint ¶
Point Compression Routines. These could use a lot of testing.
func (*Curve) DecompressPoint ¶
func (*Curve) Params ¶
func (curve *Curve) Params() *elliptic.CurveParams
func (*Curve) ScalarBaseMult ¶
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 ¶
ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
TODO(x): double check if it is okay
func (*Curve) Sqrt ¶
Sqrt returns the module square root.
Modulus must be prime. Some non-prime values will loop indefinately. Modulo Square root involves deep magic. You have been warned! Uses the Shanks-Tonelli algorithem:
http://en.wikipedia.org/wiki/Shanks-Tonelli_algorithm
Translated from a python implementation found here:
http://eli.thegreenplace.net/2009/03/07/computing-modular-square-roots-in-python/