smcrypto

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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

func HexKeyToAddress(hexKey string) common.Address

HexKeyToAddress calculate address from sm2p256v1 private key

func HexToPEM

func HexToPEM(hexkey string) (string, error)

HexToPEM parses a secp256k1 private key.

func HexToSM2

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

HexToSM2 parses a secp256k1 private key.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) common.Address

PubkeyToAddress calculate address from sm2p256v1 private key

func SM2KeyToAddress

func SM2KeyToAddress(privateKey []byte) common.Address

SM2KeyToAddress 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 SM2PubBytes

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

SM2PubBytes return esdsa public key as slice

func SM2Sign

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

SM2Sign return sm2 signature

func SM2ToPEM

func SM2ToPEM(key *ecdsa.PrivateKey) (string, error)

SM2ToPEM parses a secp256k1 private key.

func Sign

func Sign(hash, privateKey []byte) (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.

func ToSM2

func ToSM2(d []byte) (*ecdsa.PrivateKey, error)

ToSM2 creates a private key with the given D value.

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