Documentation ¶
Overview ¶
Package secp256k1 implements secp256k1-related functions and types.
- the elliptic curve secp256k1 itself (Compressed, Point and functions with prefix GE)
- scalar values (Scalar and functions with prefix SC)
- utility functions
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorInvalidPoint = errors.New("invalid point on secp256k1")
ErrorInvalidPoint is returned when an invalid point was found. The reasons why a point is invalid include:
- invalid header (neither 02 nor 03)
- could not find the y coordinate
var Order = [32]byte(nBytes) // The order of secp256k1, namely 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141.
var P = [32]byte(pBytes) // P is the order of the defining field F_p, namely 2^256 - 2^32 - 977.
Functions ¶
func CompareBytes ¶
CompareBytes compares two 32-byte arrays in constant-time.
The return value is one of {-1, 0, 1}.
- -1: a < b
- 0: a = b
- 1: a > b
Types ¶
type Compressed ¶
type Compressed [33]byte
Compressed is a compressed (33-byte, x-coordinate + y mod 2) representation of a point on secp256k1. Its zero value is invalid. It cannot represent the infinity (zero element).
func (Compressed) Uncompress ¶
func (a Compressed) Uncompress() (*Point, error)
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point retains a point in Jacobian coordinates.
Two distinct representations can represent the same point, so you cannot simply compare two Points with == to check if they are equal. You need to first compress them into Compressed and then compare.
Its zero value is invalid.
func GEVartimePoint ¶
GEVartimePoint computes n G where G is the base point. It does not have a constant-time guarantee, but it is faster than GEPoint.
func (*Point) Compress ¶
func (p *Point) Compress() Compressed
Compress returns the value in the compressed format. It runs in constant-time.