sm2

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: LGPL-3.0 Imports: 15 Imported by: 20 modules, 22 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// DEFAULT_ID is the default user id used in Sign and Verify
	DEFAULT_ID = "1234567812345678"
)
View Source
const DIGESTLEN = 32

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(priv *ecdsa.PrivateKey, encryptData []byte) ([]byte, error)

func Encrypt

func Encrypt(pub *ecdsa.PublicKey, data []byte) ([]byte, error)

func SM2P256V1

func SM2P256V1() elliptic.Curve

SM2P256V1 returns the sm2p256v1 curve.

func Sign

func Sign(rand io.Reader, priv *ecdsa.PrivateKey, id string, msg []byte, hasher hash.Hash) (r, s *big.Int, err error)

Sign generates signature for the input message using the private key and id. It returns (r, s) as the signature or error.

func Verify

func Verify(pub *ecdsa.PublicKey, id string, msg []byte, hasher hash.Hash, r, s *big.Int) bool

Verify checks whether the input (r, s) is a valid signature for the message.

Types

type SM2Curve

type SM2Curve interface {
	elliptic.Curve

	// ABytes returns the big endian byte sequence of parameter A.
	ABytes() []byte
}

SM2Curve is the curve interface used in sm2 algorithm. It extends elliptic.Curve by adding a function ABytes().

Jump to

Keyboard shortcuts

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