xof

package
v0.0.0-...-cb92b4e Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveKey256

func DeriveKey256[S any](sch Scheme[S], dst []byte, base *[32]byte, info []byte)

DeriveKey256 deterministically derives a key from base and info. - `dst` is filled with the output. - `base` must have 256 bits of entropy, and should be kept secret. If base is weak, derived keys will be also be weak. - `info` can be anything, but should be distinct from other infos used with this base key. info is not secret.

func Sum

func Sum[S any](sch Scheme[S], dst []byte, in []byte)

Sum creates a new XOF state from sch, absorbs the input and expands output into dst.

func Sum256

func Sum256[S any](sch Scheme[S], in []byte) (ret [32]byte)

Sum256 is a convenience function for reading 256 bits of output from an XOF.

func Sum512

func Sum512[S any](sch Scheme[S], in []byte) (ret [64]byte)

Sum512 is a convenience function for reading 512 bits of output from an XOF.

func SumMany

func SumMany[S any](sch Scheme[S], dst []byte, ins ...[]byte)

SumMany creats a new XOF state from sch, absorbs the input from all of ins, in order and expands the output filling dst.

func TestScheme

func TestScheme[S any](t *testing.T, s Scheme[S])

func XOROut

func XOROut[T any](sch Scheme[T], x *T, dst, src []byte)

Types

type Reader

type Reader[S any] struct {
	Scheme Scheme[S]
	State  *S
}

func NewRand256

func NewRand256[S any](sch Scheme[S], seed *[32]byte) Reader[S]

NewRand256 seeds a random number generator using seed and returns it.

func (*Reader[S]) Read

func (r *Reader[S]) Read(p []byte) (int, error)

type Scheme

type Scheme[State any] interface {
	// New creates a new instance of the XOF
	New() State
	// Absorb appends data to the input of the XOF by modifying s
	Absorb(s *State, data []byte)
	// Expand reads out data from the XOF, and evolves s as needed to account for the read bytes.
	Expand(s *State, data []byte)
	// Reset sets s to it's initial state.
	Reset(s *State)
}

type Writer

type Writer[S any] struct {
	Scheme Scheme[S]
	State  *S
}

func (*Writer[S]) Write

func (w *Writer[S]) Write(p []byte) (int, error)

type XORExpander

type XORExpander[T any] interface {
	XOROut(x *T, dst, src []byte)
}

Directories

Path Synopsis
internal/sha3
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