Documentation
¶
Overview ¶
Poseidon hash function, written in the layered circuit.
Index ¶
- Constants
- func Mul(field *big.Int, inputs []*big.Int, outputs []*big.Int) error
- func PoseidonCircuit(api frontend.API, engine m31.Field, param *PoseidonParams, ...) frontend.Variable
- func PoseidonM31(param *PoseidonParams, input []constraint.Element) constraint.Element
- func Power5(field *big.Int, inputs []*big.Int, outputs []*big.Int) error
- type PoseidonInternalState
- type PoseidonInternalStateVar
- type PoseidonParams
Constants ¶
View Source
const GATE_4TH_POWER_COST = 20
View Source
const GATE_5TH_POWER_TYPE = 12345
Suppose we have a x^4 gate, which has id 12345 in the prover
View Source
const GATE_MUL_COST = 20
View Source
const GATE_MUL_TYPE = 12346
Variables ¶
This section is empty.
Functions ¶
func PoseidonCircuit ¶
func PoseidonCircuit( api frontend.API, engine m31.Field, param *PoseidonParams, input []frontend.Variable, useRandomness bool) frontend.Variable
Main function of proving poseidon in circuit.
To obtain a more efficient layered circuit representation, we also feed the internal state of the hash to this function.
func PoseidonM31 ¶
func PoseidonM31(param *PoseidonParams, input []constraint.Element) constraint.Element
Types ¶
type PoseidonInternalState ¶
type PoseidonInternalState struct {
AfterHalfFullRound [16]constraint.Element
AfterHalfPartialRound [16]constraint.Element
AfterPartialRound [16]constraint.Element
}
func PoseidonM31WithInternalStates ¶
func PoseidonM31WithInternalStates(param *PoseidonParams, input []constraint.Element, withState bool) (PoseidonInternalState, constraint.Element)
Poseidon hash function over M31 field. For convenience, function also outputs an internal state when the hash function is half complete.
type PoseidonParams ¶
type PoseidonParams struct {
// number of full rounds
NumFullRounds int
// number of half full rounds
NumHalfFullRounds int
// number of partial rounds
NumPartRounds int
// number of half full rounds
NumHalfPartialRounds int
// number of states
NumStates int
// mds matrix
MdsMatrix [][]uint32
// external round constants
ExternalRoundConstant [][]uint32
// internal round constants
InternalRoundConstant []uint32
}
func NewPoseidonParams ¶
func NewPoseidonParams() *PoseidonParams
TODOs: the parameters are not secure. use a better way to generate the constants
Click to show internal directories.
Click to hide internal directories.