hash

package
v0.0.0-...-81eada0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const MimcRounds int = 91

MimcRounds is the number of rounds for the Mimc function

Variables

View Source
var Arks []fr.Element

Arks contains the round constants used by gMimc

Functions

func AddArkAndKeysInplace

func AddArkAndKeysInplace(state []fr.Element, keys []fr.Element, ark fr.Element)

AddArkAndKeysInplace adds the

func FullRoundInPlace

func FullRoundInPlace(state []fr.Element)

FullRoundInPlace applies the SBox on all entries of the state

func GenerateMDSMatrix

func GenerateMDSMatrix(t int) [][]fr.Element

GenerateMDSMatrix returns the MDS matrix for a given size

func InPlaceCircularPermutation

func InPlaceCircularPermutation(state []fr.Element)

InPlaceCircularPermutation moves all the element to the left and place the first element at the end of the state ie: [a, b, c, d] -> [b, c, d, a]

func MatrixMultiplication

func MatrixMultiplication(mat [][]fr.Element, vec []fr.Element) []fr.Element

MatrixMultiplication by a vector The dimensions are mat[k][n] * vec[n] = res[k]

func MimcBlockCipher

func MimcBlockCipher(msg fr.Element, key fr.Element) fr.Element

MimcBlockCipherInPlace applies the mimc permutation in place In the papier; E_k(x) = Perm_k(x) + k

func MimcHash

func MimcHash(input []fr.Element) fr.Element

MimcHash returns the hash of a slice of field element

func MimcKeyedPermutation

func MimcKeyedPermutation(x fr.Element, key fr.Element) fr.Element

Iterates the Mimc rounds functions over x with key k

func MimcUpdateInplace

func MimcUpdateInplace(state *fr.Element, block fr.Element)

MimcUpdateInplace performs a state update using the Mimc permutation Using Miyaguchi-Preenel In the Miyaguchi-Preenel construct, the state is used as the key of a cipher function and the message to hash is set as the plaintext of the cipher

func PartialRoundInplace

func PartialRoundInplace(state []fr.Element)

PartialRoundInplace applies the SBox on the first entry

func SBoxInplace

func SBoxInplace(x *fr.Element)

SBoxInplace computes x^7 in-place

Types

type GMimcHasher

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

GMimcHasher contains all the parameters to describe a GMimc function

var GMimcT2 GMimcHasher

GMimcT2 is a hasher for t = 2

var GMimcT4 GMimcHasher

GMimcT4 is a hasher for t = 4

var GMimcT8 GMimcHasher

GMimcT8 is a hasher for t = 8

func (*GMimcHasher) Hash

func (g *GMimcHasher) Hash(msg []fr.Element) fr.Element

Hash hashes a full message

func (*GMimcHasher) UpdateInplace

func (g *GMimcHasher) UpdateInplace(state []fr.Element, block []fr.Element)

UpdateInplace updates the state with the provided block of data

type PoseidonHasher

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

PoseidonHasher contains all the parameters to specify a poseidon hash function

var PoseidonT2 PoseidonHasher

PoseidonT2 is a hasher with T = 2

var PoseidonT4 PoseidonHasher

PoseidonT4 is a hasher with T = 4

var PoseidonT8 PoseidonHasher

PoseidonT8 is a hasher with T = 8

func (*PoseidonHasher) Hash

func (p *PoseidonHasher) Hash(msg []fr.Element) fr.Element

Hash hashes a full message

func (*PoseidonHasher) Update

func (p *PoseidonHasher) Update(state, block []fr.Element)

Update uses the poseidon permutation in a Miyaguchi-Preenel construction to create the hash function. https://en.wikipedia.org/wiki/One-way_compression_function#Miyaguchi.E2.80.93Preneel

Jump to

Keyboard shortcuts

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