curl

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 5 Imported by: 13

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

	// NumRounds is the number of rounds in a Curl transform.
	NumRounds = 81
)

Variables

View Source
var (
	// Indices stores the rotation indices for a Curl round.
	Indices [StateSize + 1]int
)

Functions

func HashTrits

func HashTrits(trits Trits) (Trits, error)

HashTrits returns the hash of the given trits.

func HashTrytes

func HashTrytes(t Trytes) (Trytes, error)

HashTrytes returns the hash of the given trytes.

func MustHashTrytes

func MustHashTrytes(t Trytes) Trytes

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

func NewCurlP81

func NewCurlP81() SpongeFunction

NewCurlP81 returns a new Curl-P-81.

Types

type Curl

type Curl struct {
	// contains filtered or unexported fields
}

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(in 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) CopyState

func (c *Curl) CopyState(s Trits)

CopyState copy the content of the Curl state buffer into s.

func (*Curl) MustAbsorbTrytes

func (c *Curl) MustAbsorbTrytes(in 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(tritsCount int) Trits

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

func (*Curl) MustSqueezeTrytes

func (c *Curl) MustSqueezeTrytes(tritsCount int) Trytes

MustSqueezeTrytes squeezes out trytes of the given trit length. The value tritsCount has to be a multiple of HashTrinarySize. It panics if the length is not valid.

func (*Curl) Reset

func (c *Curl) Reset()

Reset the internal state of the Curl sponge.

func (*Curl) Squeeze

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

Squeeze squeezes out trits of the given length. The value tritsCount has to be a multiple of HashTrinarySize.

func (*Curl) SqueezeTrytes

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

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

type SpongeDirection

type SpongeDirection int

SpongeDirection indicates the direction trits are flowing through the sponge.

const (
	// SpongeAbsorbing indicates that the sponge is absorbing input.
	SpongeAbsorbing SpongeDirection = iota
	// SpongeSqueezing indicates that the sponge is being squeezed.
	SpongeSqueezing
)

Directories

Path Synopsis
Package bct implements the BCT Curl hashing function computing multiple Curl hashes in parallel.
Package bct implements the BCT Curl hashing function computing multiple Curl hashes in parallel.

Jump to

Keyboard shortcuts

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