secp256k1

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSigningKeyPair

func GenerateSigningKeyPair() (publicKey, privateKey []byte, err error)

GenerateSigningKeyPair generates secp2562k1 based keys.

func GetAddress

func GetAddress(publicKey []byte) string

GetAddress returns the hex of first 20 bytes of the Keccak256 has of public keuy

func GetPrivateSigningKey

func GetPrivateSigningKey(fileName string) (key []byte, err error)

GetPrivateSigningKey returns the private key from the file

func GetPublicSigningKey

func GetPublicSigningKey(fileName string) (key []byte, err error)

GetPublicSigningKey returns the public key from the file

func GetSigningKeyPair

func GetSigningKeyPair(pub, priv string) (public, private []byte, err error)

GetSigningKeyPair returns the public and private keys as byte array

func Hash

func Hash(data []byte) []byte

Hash returns the hash result from Keccak256(data)

func HashWithEthPrefix

func HashWithEthPrefix(data []byte) []byte

HashWithEthPrefix returns the hash of the data. The hash is calculated as keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). for further details see https://github.com/ethereum/go-ethereum/blob/55599ee95d4151a2502465e0afc7c47bd1acba77/internal/ethapi/api.go#L404

func Sign

func Sign(message []byte, privateKey []byte) (signature []byte, err error)

Sign signs the message using private key We do hash the message since it not recommended to use the message as is.

func SignEthereum

func SignEthereum(message []byte, privateKey []byte) (signature []byte, err error)

SignEthereum converts message to ethereum specific format and signs it.

func VerifySignature

func VerifySignature(publicKey, message, signature []byte) bool

VerifySignature verifies signature using the public key provided.

func VerifySignatureWithAddress

func VerifySignatureWithAddress(address, sigHex string, msg []byte) bool

VerifySignatureWithAddress verifies the signature using address provided

Types

This section is empty.

Jump to

Keyboard shortcuts

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