mimc

package
v0.0.0-...-35a8ded Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

mimc wraps the github.com/consensys/gnark-crypto/ecc/bls12-377/fr/mimc and provides low-level utility methods to use the block compression of MiMC directly. This is used in several occasions in the wizard package to implement and test the arithmetization of the MiMC block compression function and to have interfaces that are friendly to field elements.

Index

Constants

This section is empty.

Variables

View Source
var Constants []field.Element = func() []field.Element {
	bigConsts := mimc.GetConstants()
	res := make([]field.Element, len(bigConsts))
	for i := range res {
		res[i].SetBigInt(&bigConsts[i])
	}
	return res
}()

Constants collects the MiMC constants parsed as field elements

Functions

func BlockCompression

func BlockCompression(oldState, block field.Element) (newState field.Element)

BlockCompression applies the MiMC block compression function to a given block over a given state. This what is run under the hood by the MiMC hash function in Miyaguchi-Preneel mode.

func GnarkBlockCompression

func GnarkBlockCompression(api frontend.API, oldState, block frontend.Variable) (newState frontend.Variable)

GnarkBlockCompression applies the MiMC permutation to a given block within a gnark circuit and mirrors exactly BlockCompression.

func HashVec

func HashVec(v []field.Element) (h field.Element)

HashVec hashes a vector of field elements

func NewMiMC

func NewMiMC() hash.Hash

NewMiMC wraps mimc.NewMiMC, this is used to limit the number of gnark-crypto imports.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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