Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidSizebuffer = errors.New("the size of the input should match the size of the hash buffer")
)
Functions ¶
This section is empty.
Types ¶
type Parameters ¶ added in v0.15.0
type Parameters struct {
// len(preimage)+len(digest)=len(preimage)+ceil(log(2*<security_level>/r))
Width int
// sbox degree
DegreeSBox int
// number of full rounds (even number)
NbFullRounds int
// number of partial rounds
NbPartialRounds int
// round keys: ordered by round then variable
RoundKeys [][]big.Int
// DiagM1 holds the diagonal entries of the internal matrix for width >= 4.
// For width 2 and 3 the internal matrix is hardcoded and this field is unused.
// See https://eprint.iacr.org/2023/323.pdf page 15.
DiagM1 []big.Int
}
Parameters describing the poseidon2 implementation
func GetDefaultParameters ¶ added in v0.15.0
func GetDefaultParameters(curve ecc.ID) (Parameters, error)
type Permutation ¶ added in v0.13.0
type Permutation struct {
// contains filtered or unexported fields
}
func NewPoseidon2 ¶ added in v0.13.0
func NewPoseidon2(api frontend.API) (*Permutation, error)
NewPoseidon2 returns a new Poseidon2 hasher with default parameters as defined in the gnark-crypto library.
func NewPoseidon2FromParameters ¶ added in v0.13.0
func NewPoseidon2FromParameters(api frontend.API, width, nbFullRounds, nbPartialRounds int) (*Permutation, error)
NewPoseidon2FromParameters returns a new Poseidon2 hasher with the given parameters. The parameters are used to precompute the round keys. The round key computation is deterministic and depends on the curve ID. See the corresponding NewParameters function in the gnark-crypto library poseidon2 packages for more details.
func (*Permutation) Compress ¶ added in v0.13.0
func (h *Permutation) Compress(left, right frontend.Variable) frontend.Variable
Compress applies the permutation on left and right and returns the right lane of the result. Panics if the permutation instance is not initialized with a width of 2.
Implements the hash.Compressor interface for building a Merkle-Damgard hash construction.
func (*Permutation) Permutation ¶ added in v0.13.0
func (h *Permutation) Permutation(input []frontend.Variable) error
Permutation applies the permutation on input, and stores the result in input.