mimc

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mimc implements the MiMC hash function as a gnark circuit

This is an internal package as the implementation is used for some internal components and proof recursion where importing the github.com/consensys/gnark/std/hash package would create an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MiMC

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

MiMC contains the params of the MiMC hash func and the curves on which it is implemented.

NB! See the package documentation for length extension attack consideration.

func NewMiMC

func NewMiMC(api frontend.API) (MiMC, error)

NewMiMC returns a MiMC instance that can be used in a gnark circuit. The out-circuit counterpart of this function is provided in gnark-crypto.

NB! See the package documentation for length extension attack consideration.

func (*MiMC) Reset

func (h *MiMC) Reset()

Reset resets the Hash to its initial state.

func (*MiMC) SetState

func (h *MiMC) SetState(newState []frontend.Variable) error

SetState manually sets the state of the hasher to the provided value. In the case of MiMC only a single frontend variable is expected to represent the state.

func (*MiMC) State

func (h *MiMC) State() []frontend.Variable

State returns the inner-state of the hasher. In the context of MiMC only a single field element is returned.

func (*MiMC) Sum

func (h *MiMC) Sum() frontend.Variable

Sum hash using Miyaguchi–Preneel where the XOR operation is replaced by field addition.

func (*MiMC) Write

func (h *MiMC) Write(data ...frontend.Variable)

Write adds more data to the running hash.

Jump to

Keyboard shortcuts

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