crypto

package
v0.0.0-...-589da53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 13 Imported by: 0

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 fury are checksumed this expects a hex encoded string.

func EthereumIsValidAddress

func EthereumIsValidAddress(s string) bool

EthereumIsValidAddress returns whether the given string is a valid ethereum address.

func Hash

func Hash(key []byte) []byte

func HashBytesBuffer

func HashBytesBuffer(key bytes.Buffer) []byte

func HashStrToHex

func HashStrToHex(s string) string

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

func HashToHex

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 IsValidFuryID

func IsValidFuryID(id string) bool

func IsValidFuryPubKey

func IsValidFuryPubKey(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