Documentation ¶
Index ¶
- Constants
- func GetN() *big.Int
- func GetZBytes() []byte
- func Sm2CheckOnCurve(x, y *fiat.SM2Element) error
- func TransformPrecomputed(precomputed *[]*SM2Point, width int) [][]*[4]uint64
- type SM2Point
- func NewFromXY(xx, yy *[4]uint64) *SM2Point
- func NewSM2Generator() *SM2Point
- func NewSM2Point() *SM2Point
- func ScalarBaseMult(k []byte) (*SM2Point, error)
- func ScalarMixedMult_Unsafe(gScalar []byte, P *SM2Point, scalar []byte) (*SM2Point, error)
- func ScalarMult(P *SM2Point, scalar []byte) (*SM2Point, error)
- func (q *SM2Point) Add(p1, p2 *SM2Point) *SM2Point
- func (p *SM2Point) Bytes() []byte
- func (p *SM2Point) Bytes_Unsafe() []byte
- func (q *SM2Point) Double(p *SM2Point) *SM2Point
- func (p *SM2Point) GetAffineX() *big.Int
- func (p *SM2Point) GetAffineX_Unsafe() *big.Int
- func (q *SM2Point) MultiSelectXY(precomputed *[][]*[4]uint64, width int, bits byte) *SM2Point
- func (q *SM2Point) MultiSelectXYZ(precomputed *[][]*[4]uint64, width int, bits byte) *SM2Point
- func (q *SM2Point) Negate(p *SM2Point) *SM2Point
- func (q *SM2Point) Select(p1, p2 *SM2Point, cond int) *SM2Point
- func (p *SM2Point) Set(q *SM2Point) *SM2Point
- func (p *SM2Point) SetBytes(b []byte) (*SM2Point, error)
Constants ¶
const SM2BytesLengthUncompressed = 1 + 2*SM2ElementLength
const SM2ElementLength = 32
Variables ¶
This section is empty.
Functions ¶
func Sm2CheckOnCurve ¶
func Sm2CheckOnCurve(x, y *fiat.SM2Element) error
func TransformPrecomputed ¶
Types ¶
type SM2Point ¶
type SM2Point struct {
// contains filtered or unexported fields
}
SM2Point is a SM2 point. The zero value is NOT valid.
func NewSM2Generator ¶
func NewSM2Generator() *SM2Point
NewSM2Generator returns a new SM2Point set to the canonical generator.
func NewSM2Point ¶
func NewSM2Point() *SM2Point
NewSM2Point returns a new SM2Point representing the point at infinity point.
func ScalarBaseMult ¶
ScalarBaseMult scalar base multiplication, return [k]G when no error k is big endian and its integer value should lie in range of [1, n-1] ***secure implementation***, this could be used for sign or key generation, all sensitive operations
func ScalarMixedMult_Unsafe ¶
ScalarMixedMult_Unsafe mixed scalar multiplication, returns [gScalar]G + [scalar]P when no error gScalar and scalar are big endian and their integer values should lie in range of [1, n-1] usually used for signature verification and not sensitive This is an internal function. Do NOT use it out of this library. Use sm2.* functions instead.
func ScalarMult ¶
ScalarMult Scalar multiplication, returns [scalar]P when no error. scalar is big endian and its integer value should lie in range of [1, n-1] ***secure implementation***, this could be used for ECDH with unsigned 4-NAF
func (*SM2Point) Bytes ¶
Bytes returns the uncompressed or infinity encoding of p. Note that the encoding of the point at infinity is shorter than all other encodings. This is the SAFE version, could be used for ECDH purpose for example.
func (*SM2Point) Bytes_Unsafe ¶
Bytes_Unsafe returns the uncompressed or infinity encoding of p. Note that the encoding of the point at infinity is shorter than all other encodings. This is the unsafe version.
func (*SM2Point) GetAffineX ¶
GetAffineX return X in Affine as big integer. It saves some costs by avoiding the calculation of Y. This is a safe version for the case that the affine coordinates must be extracted safely. Returns big integer. If returned is 0, callers, if in such needs, MUST determine if this is due to a zero point, or a valid point (0, some_y). Usually if the point results from scalar multiplication with scalar in range [1, n-1], the latter will not happen.
func (*SM2Point) GetAffineX_Unsafe ¶
GetAffineX_Unsafe functions the same as GetAffineX. It uses a faster yet non-constant time algorithm to calculate the inverse of z.
func (*SM2Point) MultiSelectXY ¶
MultiSelectXY select from multiple options based on the bits. We should be able to cut roughly half of selection cost compared to if we select the point one-by-one in a loop.
func (*SM2Point) MultiSelectXYZ ¶
MultiSelectXYZ select from multiple options based on the bits. We should be able to cut roughly half of selection cost compared to if we select the point one-by-one in a loop.