hash

package
v0.9.15-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package hash defines functions around keccak256 and useful helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashStringGetBytes

func HashStringGetBytes(hexString string) []byte

HashStringGetBytes takes a hex string (which represents a hash) and return the bytes of a hash.Hash object that would return the input string if you called .GetString() on it. This function exists because you can NOT just []byte(hexString) as it would give a different result.

Types

type Hash

type Hash struct {
	Bytes []byte
}

Hash has only one field which is the hash as slice of byte.

func Concatenate

func Concatenate(h1 Hash, h2 Hash) Hash

Concatenate concatenates two Hashes, hashes it and then returns the resulting Hash. It is used for Merkle Tree construction.

func GetHashObjectWithoutHashing

func GetHashObjectWithoutHashing(hexString string) Hash

GetHashObjectWithoutHashing takes a hex string (which represent a hash) and returns a hash.Hash that returns this when called with .GetString() sometimes you already know the hash you want as hex string but you need it as hash.Hash. This function takes care of this situation and is very useful for e.g. GenerateTransaction() which is used for testing.

func NewHash

func NewHash(input string) Hash

NewHash is the constructor of Hash which makes sure that the hash function is used correctly.

func (Hash) GetString

func (h Hash) GetString() string

GetString returns the hash as string.

func (Hash) PrintString

func (h Hash) PrintString()

PrintString prints the hash value as hex string.

type LRHash

type LRHash struct {
	Value  Hash
	IsLeft bool
}

LRHash is a Hash that is aware of whether it is the hash of a left node or a right node in a tree. This is used in the context of Merkle Trees and Merkle Proofs.

Jump to

Keyboard shortcuts

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