Documentation ¶
Index ¶
- func ECDSAPubBytes(pub *ecdsa.PublicKey) []byte
- func ECDSAToPem(key *ecdsa.PrivateKey) (string, error)
- func GenerateKey() ([]byte, error)
- func HexKeyToAddress(hexKey string) common.Address
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func HexToPem(hexkey string) (string, error)
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func SM2PreProcess(src []byte, id string, priv *ecdsa.PrivateKey) ([]byte, error)
- func SM2Sign(src []byte, priv *ecdsa.PrivateKey) (r, s *big.Int, err error)
- func Sign(hash []byte, hexKey string) (sig []byte, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ECDSAPubBytes ¶
ECDSAPubBytes return esdsa public key as slice
func ECDSAToPem ¶
func ECDSAToPem(key *ecdsa.PrivateKey) (string, error)
ECDSAToPem parses a secp256k1 private key.
func GenerateKey ¶
func HexKeyToAddress ¶
HexKeyToAddress calculate address from sm2p256v1 private key
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func PubkeyToAddress ¶
PubkeyToAddress calculate address from sm2p256v1 private key
func SM2PreProcess ¶
SM2PreProcess compute z value of id and return z||m
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.