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 ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
GenerateKey generates a new private key.
func HexKeyToAddress ¶
HexKeyToAddress calculate address from sm2p256v1 private key
func HexToSM2 ¶
func HexToSM2(hexkey string) (*ecdsa.PrivateKey, error)
HexToSM2 parses a secp256k1 private key.
func PubkeyToAddress ¶
PubkeyToAddress calculate address from sm2p256v1 private key
func SM2KeyToAddress ¶
SM2KeyToAddress calculate address from sm2p256v1 private key
func SM2PreProcess ¶
SM2PreProcess compute z value of id and return z||m
func SM2PubBytes ¶
SM2PubBytes return esdsa public key as slice
func SM2ToPEM ¶
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.