utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPrivateKey      = errors.New("err: input private key is not valid! ")
	ErrInvalidPublicKey       = errors.New("err: input nil public key is not valid! ")
	ErrInvalidVerifySigPubKey = errors.New("err: input public key is not valid for the signature! ")
)

Functions

func CalHash

func CalHash(msg []byte, hFunc func() hash.Hash) (res []byte, err error)

func DecodePrivateKey

func DecodePrivateKey(sk string) (privateKey *ecdsa.PrivateKey, err error)

func DecodePrivateKeyBigInt

func DecodePrivateKeyBigInt(skStr string) (privateKey *ecdsa.PrivateKey, err error)

func DecodePubKey

func DecodePubKey(pk string) (pubKey *ecdsa.PublicKey, err error)

func EncodePrivateKey

func EncodePrivateKey(sk *ecdsa.PrivateKey) (priKey string, err error)

func EncodePubKey

func EncodePubKey(pk *ecdsa.PublicKey) (pubKey string, err error)

func EtherToWei

func EtherToWei(value float64) *big.Int

func IsValidEthAddress

func IsValidEthAddress(address string) bool

func IsValidHashValue

func IsValidHashValue(hash string) bool

func IsValidPrivateKey

func IsValidPrivateKey(sk string) bool

func Sign

func Sign(sk string, data []byte) (sig []byte, err error)

func VerifySig

func VerifySig(pk string, sig []byte, data []byte) (res bool, err error)

func WeiToEther

func WeiToEther(_balance *big.Int) *big.Float

Types

This section is empty.

Jump to

Keyboard shortcuts

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