curl

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: 4 Imported by: 0

Documentation

Overview

Package curl implements the Curl hashing function.

Index

Constants

View Source
const (
	// StateSize is the size of the Curl hash function.
	StateSize = HashTrinarySize * 3

	// CurlP27 is used for hashing with 27 rounds
	CurlP27 CurlRounds = 27

	// CurlP81 is used for hashing with 81 rounds
	CurlP81 CurlRounds = 81

	// NumberOfRounds is the default number of rounds in transform.
	NumberOfRounds = CurlP81
)

Variables

View Source
var (

	// TruthTable of the Curl hash function.
	TruthTable = [11]int8{1, 0, -1, 2, 1, -1, 0, 2, -1, 1, 0}
	// Indices of the Curl hash function.
	Indices [StateSize + 1]int
)

Functions

func HashTrits

func HashTrits(trits Trits, rounds ...CurlRounds) (Trits, error)

HashTrits returns the hash of the given trits.

func HashTrytes

func HashTrytes(t Trytes, rounds ...CurlRounds) (Trytes, error)

HashTrytes returns the hash of the given trytes.

func MustHashTrytes

func MustHashTrytes(t Trytes, rounds ...CurlRounds) Trytes

MustHashTrytes returns the hash of the given trytes. It panics if the given trytes are not valid.

func NewCurl

func NewCurl(rounds ...CurlRounds) SpongeFunction

NewCurl initializes a new instance with an empty State.

func NewCurlP27

func NewCurlP27() SpongeFunction

NewCurlP27 returns a new CurlP27.

func NewCurlP81

func NewCurlP81() SpongeFunction

NewCurlP81 returns a new CurlP81.

Types

type Curl

type Curl struct {
	State  Trits
	Rounds CurlRounds
}

Curl is a sponge function with an internal State of size StateSize. b = r + c, b = StateSize, r = HashSize, c = StateSize - HashSize

func (*Curl) Absorb

func (c *Curl) Absorb(in Trits) error

Absorb fills the internal State of the sponge with the given trits.

func (*Curl) AbsorbTrytes

func (c *Curl) AbsorbTrytes(inn Trytes) error

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

func (*Curl) Clone

func (c *Curl) Clone() SpongeFunction

Clone returns a deep copy of the current Curl

func (*Curl) MustAbsorbTrytes

func (c *Curl) MustAbsorbTrytes(inn Trytes)

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

func (*Curl) MustSqueeze

func (c *Curl) MustSqueeze(length int) 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 (*Curl) MustSqueezeTrytes

func (c *Curl) MustSqueezeTrytes(length int) 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 (*Curl) Reset

func (c *Curl) Reset()

Reset the internal State of the Curl sponge by filling it with all 0's.

func (*Curl) Squeeze

func (c *Curl) Squeeze(length int) (Trits, error)

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

func (*Curl) SqueezeTrytes

func (c *Curl) SqueezeTrytes(length int) (Trytes, error)

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

func (*Curl) Transform

func (c *Curl) Transform()

Transform does Transform in sponge func.

type CurlRounds

type CurlRounds int

CurlRounds is the default number of rounds used in transform.

Directories

Path Synopsis
Package curl implements the Curl hashing function.
Package curl implements the Curl hashing function.

Jump to

Keyboard shortcuts

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