gm

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: Apache-2.0

README

Generate public key and private key,the public key is point compress

// BHGeneratePointCompressKey used to product publicKey and privateKey.
// The publicKey is ponit compressed
func BHGeneratePointCompressKey() (pubKey string, priKey string, err error)

Generate public key and private key

// BHGenerateKey used to product publicKey and privateKey
func BHGenerateKey() (pubKey string, priKey string, err error)

sm2 sign

// BHSign used to sign src,priKey is hex string.return r/s bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHSign(priKey string, userID []byte, src []byte) ([]byte, error)

sm2 sign with asn1

// BHSignX used to sign src,priKey is hex string.return asn.1 format bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHSignX(priKey string, userID []byte, src []byte) ([]byte, error)

sm2 verify use point compress pubkey

// BHVerifyWithPointCompress used to verify src and sign,the pubKey is point compress,the sign is r/s bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHVerifyWithPointCompress(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)

sm2 verify use point compress pubkey,the sign is asn1 format

// BHVerifyWithPointCompressX used to verify src and sign,the pubKey is point compress,the sign is asn.1 format bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHVerifyWithPointCompressX(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)

sm2 verify

// BHVerify function is similar with VerifyWithPointCompress,the pubKey is unCompress,the sign is r/s bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHVerify(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error))

sm2 verify,the sign is asn1 format

// BHVerifyX function is similar with VerifyWithPointCompress,the pubKey is unCompress,the sign is asn.1 format bytes
// If userID be assigned nil,which will use default value,default value is 1234567812345678 bytes
func BHVerifyX(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)

Directories

Path Synopsis
Package cryptobyte contains types that help with parsing and constructing length-prefixed, binary messages, including ASN.1 DER.
Package cryptobyte contains types that help with parsing and constructing length-prefixed, binary messages, including ASN.1 DER.
asn1
Package asn1 contains supporting types for parsing and building ASN.1 messages with the cryptobyte package.
Package asn1 contains supporting types for parsing and building ASN.1 messages with the cryptobyte package.
sm2

Jump to

Keyboard shortcuts

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