utils

package
v0.0.0-...-e49ae39 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddresToPubKeyHash

func AddresToPubKeyHash(address string) ([]byte, error)

Converts address string to hash of pubkey

func Base58Decode

func Base58Decode(input []byte) []byte

Base58Decode decodes Base58-encoded data

func Base58Encode

func Base58Encode(input []byte) []byte

Base58Encode encodes a byte array to Base58

func Checksum

func Checksum(payload []byte) []byte

Checksum generates a checksum for a public key

func CopyBytes

func CopyBytes(source []byte) []byte

func HashPubKey

func HashPubKey(pubKey []byte) ([]byte, error)

HashPubKey hashes public key

func IntToHex

func IntToHex(num int64) []byte

IntToHex converts an int64 to a byte array

func PubKeyHashToAddres

func PubKeyHashToAddres(pubKeyHash []byte) (string, error)

Converts hash of pubkey to address as a string

func PubKeyToAddres

func PubKeyToAddres(pubKey []byte) (string, error)

Makes string adres from pub key

func RandString

func RandString(n int) string

func ReverseBytes

func ReverseBytes(data []byte)

ReverseBytes reverses a byte array

func SignData

func SignData(privKey ecdsa.PrivateKey, dataToSign []byte) ([]byte, error)

func SignDataSet

func SignDataSet(PubKey []byte, privKey ecdsa.PrivateKey, dataSetsToSign [][]byte) ([][]byte, error)

func VerifySignature

func VerifySignature(signature []byte, message []byte, PubKey []byte) (bool, error)

Types

type LoggerMan

type LoggerMan struct {
	State map[string]bool

	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Error   *log.Logger
	// contains filtered or unexported fields
}

Structure to manage logs

func CreateLogger

func CreateLogger() *LoggerMan

Creates logger object. sets all logging to STDOUT

func (*LoggerMan) DisableLogging

func (logger *LoggerMan) DisableLogging()

disable all logging

func (*LoggerMan) EnableLogs

func (logger *LoggerMan) EnableLogs(logs string)

change enabled logs state

func (*LoggerMan) GetState

func (logger *LoggerMan) GetState() string

return logs state as command separated list

func (*LoggerMan) LogToFiles

func (logger *LoggerMan) LogToFiles(datadir, trace, info, warning, errorname string) error

Changes logging to files

func (*LoggerMan) LogToStdout

func (logger *LoggerMan) LogToStdout() error

Sets ogging to STDOUT

type MerkleNode

type MerkleNode struct {
	Left  *MerkleNode
	Right *MerkleNode
	Data  []byte
}

MerkleNode represent a Merkle tree node

func NewMerkleNode

func NewMerkleNode(left, right *MerkleNode, data []byte) *MerkleNode

NewMerkleNode creates a new Merkle tree node

type MerkleTree

type MerkleTree struct {
	RootNode *MerkleNode
}

MerkleTree represent a Merkle tree

func NewMerkleTree

func NewMerkleTree(data [][]byte) *MerkleTree

NewMerkleTree creates a new Merkle tree from a sequence of data

Jump to

Keyboard shortcuts

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