kerl

package
v1.0.0-beta.15....-0de5f12 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package kerl implements the Kerl hashing function.

Package kerl implements the Kerl hashing function.

Package kerl implements the Kerl hash function.

Index

Constants

This section is empty.

Variables

View Source
var ErrAbsorbAfterSqueeze = errors.New("absorb after squeeze")

ErrAbsorbAfterSqueeze is returned when absorb is called on the same hash after a squeeze.

Functions

func KerlBytesToTrits

func KerlBytesToTrits(b []byte) (Trits, error)

KerlBytesToTrits is only defined for hashes, i.e. chunks of 48 bytes. It returns 243 trits.

func KerlBytesToTrytes

func KerlBytesToTrytes(b []byte) (Trytes, error)

KerlBytesToTrytes is only defined for hashes, i.e. chunks of 48 bytes. It returns 81 trytes.

func KerlBytesZeroLastTrit

func KerlBytesZeroLastTrit(bytes []byte)

KerlBytesZeroLastTrit changes a chunk of 48 bytes so that the corresponding ternary number has 242th trit set to 0.

func KerlTritsToBytes

func KerlTritsToBytes(trits Trits) ([]byte, error)

KerlTritsToBytes is only defined for hashes, i.e. chunks of trits of length 243. It returns 48 bytes.

func KerlTrytesToBytes

func KerlTrytesToBytes(trytes Trytes) ([]byte, error)

KerlTrytesToBytes is only defined for hashes, i.e. chunks of trytes of length 81. It returns 48 bytes.

Types

type Kerl

type Kerl struct {
	hash.Hash // underlying binary hashing function
	// contains filtered or unexported fields
}

Kerl is a to trinary aligned version of keccak

func NewKerl

func NewKerl() *Kerl

NewKerl returns a new Kerl

func (*Kerl) Absorb

func (k *Kerl) Absorb(in trinary.Trits) error

Absorb fills the internal state of the sponge with the given trits. This is only defined for Trit slices that are a multiple of HashTrinarySize long.

func (*Kerl) AbsorbTrytes

func (k *Kerl) AbsorbTrytes(in trinary.Trytes) error

AbsorbTrytes fills the internal State of the sponge with the given trytes.

func (*Kerl) Clone

func (k *Kerl) Clone() SpongeFunction

Clone returns a deep copy of the current Kerl

func (*Kerl) MustAbsorbTrytes

func (k *Kerl) MustAbsorbTrytes(in trinary.Trytes)

MustAbsorbTrytes fills the internal State of the sponge with the given trytes. It panics if the given trytes are not valid.

func (*Kerl) MustSqueeze

func (k *Kerl) MustSqueeze(length int) trinary.Trits

MustSqueeze squeezes out trits of the given length. Length has to be a multiple of HashTrinarySize. It panics if the length is not valid.

func (*Kerl) MustSqueezeTrytes

func (k *Kerl) MustSqueezeTrytes(length int) trinary.Trytes

MustSqueezeTrytes squeezes out trytes of the given trit length. Length has to be a multiple of HashTrinarySize. It panics if the trytes or the length are not valid.

func (*Kerl) Read

func (k *Kerl) Read(b []byte) (n int, err error)

Read squeezes an arbitrary number of bytes. The buffer will be filled in multiples of HashByteSize.

func (*Kerl) Reset

func (k *Kerl) Reset()

Reset resets the Hash to its initial state.

func (*Kerl) Size

func (k *Kerl) Size() int

Size returns the number of bytes Sum will return.

func (*Kerl) Squeeze

func (k *Kerl) Squeeze(length int) (trinary.Trits, error)

Squeeze out length trits. Length has to be a multiple of HashTrinarySize.

func (*Kerl) SqueezeTrytes

func (k *Kerl) SqueezeTrytes(length int) (trinary.Trytes, error)

SqueezeTrytes squeezes out trytes of the given trit length. Length has to be a multiple of HashTrinarySize.

func (*Kerl) Sum

func (k *Kerl) Sum(b []byte) []byte

Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.

func (*Kerl) Write

func (k *Kerl) Write(in []byte) (int, error)

Write absorbs more data into the hash's state. In oder to have consistent behavior with Absorb and AbsorbTrytes, it must be assured that the bytes written are multiples of HashByteSize and do not represent ternary numbers with a non-zero 243rd trit, e.g. by calling KerlBytesZeroLastTrit or by only using output from the Kerl hash function.

Directories

Path Synopsis
Package bigint contains a very lightweight and high-performance implementation of unsigned multi-precision integers.
Package bigint contains a very lightweight and high-performance implementation of unsigned multi-precision integers.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.

Jump to

Keyboard shortcuts

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