crypto

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToPubKey

func BytesToPubKey(pk_bytes []byte) (*ecdsa.PublicKey, error)

BytesToPubKey is compatible with comressed / uncompressed pubkey bytes.

func CompressedPubkeyHex

func CompressedPubkeyHex(pk *ecdsa.PublicKey) string

CompressedPubkeyHex has no "0x".

func GenerateKeypair

func GenerateKeypair() (publicKey *ecdsa.PublicKey, privateKey *ecdsa.PrivateKey)

GenerateKeypair generates a keypair. For test purpose only.

func RecoverPubkeyFromPersonalSignature

func RecoverPubkeyFromPersonalSignature(payload string, signature []byte) (pubkey *ecdsa.PublicKey, err error)

RecoverPubkeyFromPersonalSignature extract a public key from signature

func SignPersonal

func SignPersonal(payload []byte, sk *ecdsa.PrivateKey) (signature []byte, err error)

SignPersonal signs a payload using given secret key. For test purpose only.

func StringToPubkey

func StringToPubkey(pk_str string) (*ecdsa.PublicKey, error)

StringToPubkey is compatible with comressed / uncompressed pubkey hex, and with / without '0x' head.

func ValidatePersonalSignature

func ValidatePersonalSignature(payload string, signature []byte, pubkey *ecdsa.PublicKey) (err error)

ValidatePersonalSignature checks whether (eth.personal.sign) signature, payload and pubkey are matched. Pubkey and signature should be without "0x".

Types

This section is empty.

Jump to

Keyboard shortcuts

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