Documentation ¶
Overview ¶
Package curl implements the Curl hashing function.
Index ¶
- Constants
- Variables
- func HashTrits(trits Trits, rounds ...CurlRounds) (Trits, error)
- func HashTrytes(t Trytes, rounds ...CurlRounds) (Trytes, error)
- func MustHashTrytes(t Trytes, rounds ...CurlRounds) Trytes
- func NewCurl(rounds ...CurlRounds) SpongeFunction
- func NewCurlP27() SpongeFunction
- func NewCurlP81() SpongeFunction
- type Curl
- func (c *Curl) Absorb(in Trits) error
- func (c *Curl) AbsorbTrytes(in Trytes) error
- func (c *Curl) Clone() SpongeFunction
- func (c *Curl) CopyState(s Trits)
- func (c *Curl) MustAbsorbTrytes(in Trytes)
- func (c *Curl) MustSqueeze(tritsCount int) Trits
- func (c *Curl) MustSqueezeTrytes(tritsCount int) Trytes
- func (c *Curl) NumRounds() int
- func (c *Curl) Reset()
- func (c *Curl) Squeeze(tritsCount int) (Trits, error)
- func (c *Curl) SqueezeTrytes(tritsCount int) (Trytes, error)
- type CurlRounds
- type SpongeDirection
Constants ¶
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 ¶
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 Curl instance.
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) AbsorbTrytes ¶
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 ¶
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 ¶
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) Squeeze ¶
Squeeze squeezes out trits of the given length. The value tritsCount has to be a multiple of HashTrinarySize.
func (*Curl) SqueezeTrytes ¶
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 )