Documentation
¶
Index ¶
- Constants
- Variables
- func AddArkAndKeysInplace(state []fr.Element, keys []fr.Element, ark fr.Element)
- func FullRoundInPlace(state []fr.Element)
- func GenerateMDSMatrix(t int) [][]fr.Element
- func InPlaceCircularPermutation(state []fr.Element)
- func MatrixMultiplication(mat [][]fr.Element, vec []fr.Element) []fr.Element
- func MimcBlockCipher(msg fr.Element, key fr.Element) fr.Element
- func MimcHash(input []fr.Element) fr.Element
- func MimcKeyedPermutation(x fr.Element, key fr.Element) fr.Element
- func MimcUpdateInplace(state *fr.Element, block fr.Element)
- func PartialRoundInplace(state []fr.Element)
- func SBoxInplace(x *fr.Element)
- type GMimcHasher
- type PoseidonHasher
Constants ¶
const MimcRounds int = 91
MimcRounds is the number of rounds for the Mimc function
Variables ¶
var Arks []fr.Element
Arks contains the round constants used by gMimc
Functions ¶
func AddArkAndKeysInplace ¶
AddArkAndKeysInplace adds the
func FullRoundInPlace ¶
FullRoundInPlace applies the SBox on all entries of the state
func GenerateMDSMatrix ¶
GenerateMDSMatrix returns the MDS matrix for a given size
func InPlaceCircularPermutation ¶
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 ¶
MatrixMultiplication by a vector The dimensions are mat[k][n] * vec[n] = res[k]
func MimcBlockCipher ¶
MimcBlockCipherInPlace applies the mimc permutation in place In the papier; E_k(x) = Perm_k(x) + k
func MimcKeyedPermutation ¶
Iterates the Mimc rounds functions over x with key k
func MimcUpdateInplace ¶
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 ¶
PartialRoundInplace applies the SBox on the first entry
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