crypto

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keccak256

func Keccak256(data ...[]byte) ([]byte, error)

Keccak256 return sha3 of a given byte array

func PrivateKeyToHex

func PrivateKeyToHex(k crypto.PrivKey) (string, error)

PrivateKeyToHex returns the hex value of a PrivKey.

func PublicKeyFromBytes

func PublicKeyFromBytes(data []byte) (crypto.PubKey, error)

PublicKeyFromBytes returns a public key from bytes.

func PublicKeyFromHex

func PublicKeyFromHex(str string) (crypto.PubKey, error)

PublicKeyFromHex returns a public key from hex.

func PublicKeyToHex

func PublicKeyToHex(k crypto.PubKey) (string, error)

PublicKeyToHex returns the hex value of a pubkey.

func RandomEntropy

func RandomEntropy(length int) ([]byte, error)

RandomEntropy bytes from rand.Reader

func RawPublicToAddress

func RawPublicToAddress(data []byte) (string, error)

RawPublicToAddress returns the address of the public key.

func RawPublicToAddressBytes

func RawPublicToAddressBytes(data []byte) ([]byte, error)

RawPublicToAddressBytes returns the address of the public key in byte array.

func RestorePrivateKey

func RestorePrivateKey(privateKey []byte) (crypto.PrivKey, error)

RestorePrivateKey unmarshals the privateKey

func Sha1File

func Sha1File(path string) (string, error)

Sha1File performs a sha1 hash on a file

func Sha256

func Sha256(data []byte) []byte

Sha256 performs a sha256 hash of input.

func XXHashFile

func XXHashFile(path string) (string, error)

XXHashFile peforms a xxhash hash on a file.

Types

type KeyPair

type KeyPair struct {
	PrivateKey crypto.PrivKey
	PublicKey  crypto.PubKey
	Address    string
}

KeyPair represents a private, publick key and the address.

func GenerateKeyPair

func GenerateKeyPair() (KeyPair, error)

GenerateKeyPair returns a new keypair

Jump to

Keyboard shortcuts

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