Documentation ¶
Index ¶
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func HexKeyToAddress(hexKey string) common.Address
- func HexToPEM(hexkey string) (string, error)
- func HexToSM2(hexkey string) (*ecdsa.PrivateKey, error)
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func SM2KeyToAddress(privateKey []byte) common.Address
- func SM2PreProcess(src []byte, id string, priv *ecdsa.PrivateKey) ([]byte, error)
- func SM2PubBytes(pub *ecdsa.PublicKey) []byte
- func SM2Sign(src []byte, priv *ecdsa.PrivateKey) (r, s *big.Int, err error)
- func SM2ToPEM(key *ecdsa.PrivateKey) (string, error)
- func Sign(hash, privateKey []byte) (sig []byte, err error)
- func ToSM2(d []byte) (*ecdsa.PrivateKey, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶ added in v1.1.0
func GenerateKey() (*ecdsa.PrivateKey, error)
GenerateKey generates a new private key.
func HexKeyToAddress ¶
HexKeyToAddress calculate address from sm2p256v1 private key
func HexToSM2 ¶ added in v0.10.0
func HexToSM2(hexkey string) (*ecdsa.PrivateKey, error)
HexToSM2 parses a secp256k1 private key.
func PubkeyToAddress ¶
PubkeyToAddress calculate address from sm2p256v1 private key
func SM2KeyToAddress ¶ added in v0.10.0
SM2KeyToAddress calculate address from sm2p256v1 private key
func SM2PreProcess ¶
SM2PreProcess compute z value of id and return z||m
func SM2PubBytes ¶ added in v0.10.0
SM2PubBytes return esdsa public key as slice
func SM2ToPEM ¶ added in v0.10.0
func SM2ToPEM(key *ecdsa.PrivateKey) (string, error)
SM2ToPEM parses a secp256k1 private key.
func Sign ¶
Sign calculates an sm2 signature.
This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.
The produced signature is in the [R || S || V] format where V is public key.
Types ¶
This section is empty.