merkle

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: ISC Imports: 4 Imported by: 0

Documentation

Overview

merkle tree manipulation routines

Index

Constants

View Source
const DigestLength = 32

number of bytes in the digest

Variables

This section is empty.

Functions

func DigestFromBytes

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

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

Types

type Digest

type Digest [DigestLength]byte

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

compute minimum 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

merkle hashing

build a minimised tree

func NewDigest

func NewDigest(record []byte) Digest

create a digest from a byte slice

func (Digest) Bytes added in v0.6.7

func (digest Digest) Bytes() []byte

convert to slice

func (Digest) GoString

func (digest Digest) GoString() string

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)

convert digest to Little Endian hex text

func (*Digest) Scan

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

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

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

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