crypto

package
v0.68.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Sha3 = "sha3_24_rounds"
)

Variables

This section is empty.

Functions

func CountZeros

func CountZeros(d []byte) byte

func Decrypt

func Decrypt(data []byte, passphrase string) ([]byte, error)

func Encrypt

func Encrypt(data []byte, passphrase string) ([]byte, error)

func EthereumChecksumAddress

func EthereumChecksumAddress(s string) string

EthereumChecksumAddress is a simple utility function to ensure all ethereum addresses used in vega are checksumed this expects a hex encoded string.

func Hash

func Hash(key []byte) []byte

func HashBytesBuffer added in v0.66.0

func HashBytesBuffer(key bytes.Buffer) []byte

func HashStrToHex added in v0.62.0

func HashStrToHex(s string) string

HashStrToHex hash a string returns a hex encoded string of the result.

func HashToHex added in v0.62.0

func HashToHex(data []byte) string

HashToHex hash the input bytes and returns a hex encoded string of the result.

func IntToHex

func IntToHex(num uint64) []byte

func IsValidVegaPubKey

func IsValidVegaPubKey(pkey string) bool

func NewNonce

func NewNonce() uint64

func PoW

func PoW(blockHash string, txID string, difficulty uint, hashFunction string) (uint64, []byte, error)

PoW calculates proof of work given block hash, transaction hash, target difficulty and a hash function. returns the nonce, the hash and the error if any.

func RandomHash

func RandomHash() string

func Verify

func Verify(blockHash string, tid string, nonce uint64, hashFuncion string, difficulty uint) (bool, byte)

Verify checks that the hash with the given nonce results in the target difficulty.

Types

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func NewPublicKey

func NewPublicKey(hex string, bytes []byte) PublicKey

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

func (PublicKey) Hex

func (p PublicKey) Hex() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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