sm2curve

package
v1.0.2048 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImplicitSig

func ImplicitSig(sPriv, ePriv, t []byte) ([]byte, error)

func Marshal

func Marshal(curve elliptic.Curve, x, y *big.Int) []byte

Marshal converts a point on the curve into the uncompressed

func MarshalCompressed

func MarshalCompressed(curve elliptic.Curve, x, y *big.Int) []byte

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 P256

func P256() elliptic.Curve

func P256OrdInverse

func P256OrdInverse(k []byte) ([]byte, error)

P256OrdInverse, sets out to in⁻¹ mod org(G). If in is zero, out will be zero. n-2 = 1111111111111111111111111111111011111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111 0111001000000011110111110110101100100001110001100000010100101011 0101001110111011111101000000100100111001110101010100000100100001

func P256OrdMul

func P256OrdMul(in1, in2 []byte) ([]byte, error)

P256OrdMul multiplication modulo org(G).

func Unmarshal

func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)

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

func UnmarshalCompressed(curve elliptic.Curve, 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, 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
}

Point is a SM2P256 point. The zero value is NOT valid.

func NewPoint

func NewPoint() *Point

NewPoint returns a new Point representing the point at infinity point.

func (*Point) Add

func (q *Point) Add(p1, p2 *Point) *Point

Add sets q = p1 + p2, and returns q. The points may overlap.

func (*Point) Bytes

func (p *Point) Bytes() []byte

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

func (p *Point) BytesCompressed() []byte

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

func (p *Point) BytesX() ([]byte, error)

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) Double

func (q *Point) Double(p *Point) *Point

Double sets q = p + p, and returns q. The points may overlap.

func (*Point) ScalarBaseMult

func (p *Point) ScalarBaseMult(scalar []byte) (*Point, error)

ScalarBaseMult sets p = scalar * B, where B is the canonical generator, and returns p.

func (*Point) ScalarMult

func (p *Point) ScalarMult(q *Point, scalar []byte) (*Point, error)

ScalarMult sets p = scalar * q, and returns p.

func (*Point) Select

func (q *Point) Select(p1, p2 *Point, cond int) *Point

Select sets q to p1 if cond == 1, and to p2 if cond == 0.

func (*Point) Set

func (p *Point) Set(q *Point) *Point

Set sets p = q and returns p.

func (*Point) SetBytes

func (p *Point) SetBytes(b []byte) (*Point, error)

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

func (p *Point) SetGenerator() *Point

SetGenerator sets p to the canonical generator and returns p.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL