smcrypto

package
v0.0.0-...-7c0078d Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ECDSAPubBytes

func ECDSAPubBytes(pub *ecdsa.PublicKey) []byte

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 GenerateKey() ([]byte, error)

func HexKeyToAddress

func HexKeyToAddress(hexKey string) common.Address

HexKeyToAddress calculate address from sm2p256v1 private key

func HexToECDSA

func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)

HexToECDSA parses a secp256k1 private key.

func HexToPem

func HexToPem(hexkey string) (string, error)

HexToPem parses a secp256k1 private key.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) common.Address

PubkeyToAddress calculate address from sm2p256v1 private key

func SM2PreProcess

func SM2PreProcess(src []byte, id string, priv *ecdsa.PrivateKey) ([]byte, error)

SM2PreProcess compute z value of id and return z||m

func SM2Sign

func SM2Sign(src []byte, priv *ecdsa.PrivateKey) (r, s *big.Int, err error)

SM2Sign return sm2 signature

func Sign

func Sign(hash []byte, hexKey string) (sig []byte, err error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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