Documentation ¶
Index ¶
- Variables
- func ImplicitSig(sPriv, ePriv, t []byte) ([]byte, error)
- func Marshal(curve elliptic.Curve, x, y *big.Int) []byte
- func MarshalCompressed(curve elliptic.Curve, x, y *big.Int) []byte
- func P256() elliptic.Curve
- func P256OrdInverse(k []byte) ([]byte, error)
- func P256OrdMul(in1, in2 []byte) ([]byte, error)
- func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)
- func UnmarshalCompressed(curve elliptic.Curve, data []byte) (x, y *big.Int)
- type Point
- func (q *Point) Add(r1, r2 *Point) *Point
- func (p *Point) Bytes() []byte
- func (p *Point) BytesCompressed() []byte
- func (p *Point) BytesX() ([]byte, error)
- func (q *Point) Double(p *Point) *Point
- func (r *Point) ScalarBaseMult(scalar []byte) (*Point, error)
- func (r *Point) ScalarMult(q *Point, scalar []byte) (*Point, error)
- func (q *Point) Select(p1, p2 *Point, cond int) *Point
- func (p *Point) Set(q *Point) *Point
- func (p *Point) SetBytes(b []byte) (*Point, error)
- func (p *Point) SetGenerator() *Point
Constants ¶
This section is empty.
Variables ¶
var RR = &p256OrdElement{0x901192af7c114f20, 0x3464504ade6fa2fa, 0x620fc84c3affe0d4, 0x1eb5e412a22b3d3b}
This code operates in the Montgomery domain where R = 2²⁵⁶ mod n and n is the order of the scalar field. Elements in the Montgomery domain take the form a×R and p256OrdMul calculates (a × b × R⁻¹) mod n. RR is R in the domain, or R×R mod n, thus p256OrdMul(x, RR) gives x×R, i.e. converts x into the Montgomery domain.
Functions ¶
func ImplicitSig ¶
func MarshalCompressed ¶
MarshalCompressed converts a point on the curve into the compressed form specified in SEC 1, Version 2.0, Section 2.3.3. If the point is not on the curve (or is the conventional point at infinity), the behavior is undefined.
func P256OrdInverse ¶
P256OrdInverse, sets out to in⁻¹ mod org(G). If in is zero, out will be zero. n-2 = 1111111111111111111111111111111011111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111 0111001000000011110111110110101100100001110001100000010100101011 0101001110111011111101000000100100111001110101010100000100100001
func P256OrdMul ¶
P256OrdMul multiplication modulo org(G).
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, is not on the curve, or is the point at infinity. On error, x = nil.
func UnmarshalCompressed ¶
UnmarshalCompressed converts a point, serialized by MarshalCompressed, into an x, y pair. It is an error if the point is not in compressed form, is not on the curve, or is the point at infinity. On error, x = nil.
Types ¶
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
P256Point is a P-256 point. The zero value should not be assumed to be valid (although it is in this implementation).
func NewPoint ¶
func NewPoint() *Point
NewPoint returns a new Point representing the point at infinity.
func (*Point) Bytes ¶
Bytes returns the uncompressed or infinity encoding of p, as specified in SEC 1, Version 2.0, Section 2.3.3. Note that the encoding of the point at infinity is shorter than all other encodings.
func (*Point) BytesCompressed ¶
BytesCompressed returns the compressed or infinity encoding of p, as specified in SEC 1, Version 2.0, Section 2.3.3. Note that the encoding of the point at infinity is shorter than all other encodings.
func (*Point) BytesX ¶
BytesX returns the encoding of the x-coordinate of p, as specified in SEC 1, Version 2.0, Section 2.3.5, or an error if p is the point at infinity.
func (*Point) ScalarBaseMult ¶
ScalarBaseMult sets r = scalar * generator, where scalar is a 32-byte big endian value, and returns r. If scalar is not 32 bytes long, ScalarBaseMult returns an error and the receiver is unchanged.
func (*Point) ScalarMult ¶
ScalarMult sets r = scalar * q, where scalar is a 32-byte big endian value, and returns r. If scalar is not 32 bytes long, ScalarBaseMult returns an error and the receiver is unchanged.
func (*Point) SetBytes ¶
SetBytes sets p to the compressed, uncompressed, or infinity value encoded in b, as specified in SEC 1, Version 2.0, Section 2.3.4. If the point is not on the curve, it returns nil and an error, and the receiver is unchanged. Otherwise, it returns p.
func (*Point) SetGenerator ¶
SetGenerator sets p to the canonical generator and returns p.