merkle

package
v0.15.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: ISC Imports: 4 Imported by: 1

Documentation

Overview

Package merkle - merkle tree manipulation routines

Index

Constants

View Source
const DigestLength = 32

DigestLength - number of bytes in the digest

Variables

This section is empty.

Functions

func DigestFromBytes

func DigestFromBytes(digest *Digest, buffer []byte) error

DigestFromBytes - convert and validate Little Endian binary byte slice to a digest the input bytes are Little Endian

Types

type Digest

type Digest [DigestLength]byte

Digest - type for a digest

* stored as Little Endian byte array * represented as Big Endian hex value for printf and scanf * represented as Little Endian hex text for JSON encoding * to convert to bytes just use d[:]

func FullMerkleTree

func FullMerkleTree(txIds []Digest) []Digest

FullMerkleTree - compute merkle root from a set of transaction ids

structure is:

  1. N * transaction digests
  2. level 1..m digests
  3. merkle root digest

func MinimumMerkleTree

func MinimumMerkleTree(ids []Digest) []Digest

MinimumMerkleTree - merkle hashing

build a minimised tree

func NewDigest

func NewDigest(record []byte) Digest

NewDigest - create a digest from a byte slice

func (Digest) Bytes added in v0.6.7

func (digest Digest) Bytes() []byte

Bytes - convert to slice

func (Digest) GoString

func (digest Digest) GoString() string

GoString - convert a binary digest to Big Endian hex string for use by the fmt package (for %#v)

func (Digest) MarshalText

func (digest Digest) MarshalText() ([]byte, error)

MarshalText - convert digest to Little Endian hex text

func (*Digest) Scan

func (digest *Digest) Scan(state fmt.ScanState, verb rune) error

Scan - convert a Big Endian hex representation to a digest for use by the format package scan routines

func (Digest) String

func (digest Digest) String() string

String - convert a binary digest to Big Endian hex string for use by the fmt package (for %s)

func (*Digest) UnmarshalText

func (digest *Digest) UnmarshalText(s []byte) error

UnmarshalText - convert Little Endian hex text into a digest

Jump to

Keyboard shortcuts

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