Documentation ¶
Index ¶
- func BytesCombine(pBytes ...[]byte) []byte
- func Compress(a *PublicKey) []byte
- func Decrypt(priv *PrivateKey, data []byte) ([]byte, error)
- func Encrypt(pub *PublicKey, data []byte) ([]byte, error)
- func KeyExchangeA(klen int, ida, idb []byte, priA *PrivateKey, pubB *PublicKey, rpri *PrivateKey, ...) (k, s1, s2 []byte, err error)
- func KeyExchangeB(klen int, ida, idb []byte, priB *PrivateKey, pubA *PublicKey, rpri *PrivateKey, ...) (k, s1, s2 []byte, err error)
- func P256Sm2() elliptic.Curve
- func Sign(priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
- func SignDataToSignDigit(sign []byte) (*big.Int, *big.Int, error)
- func SignDigitToSignData(r, s *big.Int) ([]byte, error)
- func Sm2Sign(priv *PrivateKey, msg, uid []byte) (r, s *big.Int, err error)
- func Sm2Verify(pub *PublicKey, msg, uid []byte, r, s *big.Int) bool
- func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
- func WNafReversed(wnaf []int8) []int8
- func ZA(pub *PublicKey, uid []byte) ([]byte, error)
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesCombine ¶
func KeyExchangeA ¶
func KeyExchangeA(klen int, ida, idb []byte, priA *PrivateKey, pubB *PublicKey, rpri *PrivateKey, rpubB *PublicKey) (k, s1, s2 []byte, err error)
KeyExchangeA 协商第二部,用户A调用,返回共享密钥k
func KeyExchangeB ¶
func KeyExchangeB(klen int, ida, idb []byte, priB *PrivateKey, pubA *PublicKey, rpri *PrivateKey, rpubA *PublicKey) (k, s1, s2 []byte, err error)
KeyExchangeB 协商第二部,用户B调用, 返回共享密钥k
func WNafReversed ¶
Types ¶
type PrivateKey ¶
func GenerateKey ¶
func GenerateKey() (*PrivateKey, error)
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
The SM2's private key contains the public key
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error)
sign format = 30 + len(z) + 02 + len(r) + r + 02 + len(s) + s, z being what follows its size, ie 02+len(r)+r+02+len(s)+s
Click to show internal directories.
Click to hide internal directories.