poseidon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

poseidon

Poseidon hash function over the Pallas base field, designed for efficient use in zero-knowledge proof systems.

Implements the sponge-based construction from Poseidon: A New Hash Function for Zero-Knowledge Proof Systems.

Documentation

Overview

Package poseidon provides poseidon hash function over the Pallas base field, designed for efficient use in zero-knowledge proof systems.

See README.md for details.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDataLength = errs.New("invalid data length")

ErrInvalidDataLength is returned when the input data length is not a multiple of 32 bytes.

Functions

func NewLegacyHash

func NewLegacyHash() hash.Hash

NewLegacyHash creates a new Poseidon hasher with legacy parameters that implements hash.Hash.

Types

type Parameters

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

Parameters contains the configuration for a Poseidon hash instance including round constants, MDS matrix, and other permutation parameters.

type Poseidon

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

Poseidon implements the Poseidon hash function over the Pallas base field. It provides a sponge-based construction suitable for zero-knowledge proof systems.

func NewKimchi

func NewKimchi() *Poseidon

NewKimchi creates a new Poseidon hasher with Kimchi parameters used by Mina Protocol.

func NewLegacy

func NewLegacy() *Poseidon

NewLegacy creates a new Poseidon hasher with legacy parameters.

func (*Poseidon) BlockSize

func (*Poseidon) BlockSize() int

BlockSize returns the hash's underlying block size in bytes.

func (*Poseidon) Digest

func (p *Poseidon) Digest() *pasta.PallasBaseFieldElement

Digest returns the current hash output as the first element of the state.

func (*Poseidon) Hash

Hash resets the state, absorbs the input field elements, and returns the digest.

func (*Poseidon) Rate

func (p *Poseidon) Rate() int

Rate returns the rate of the sponge construction (number of field elements absorbed per permutation).

func (*Poseidon) Reset

func (p *Poseidon) Reset()

Reset resets the hasher to its initial state.

func (*Poseidon) Size

func (*Poseidon) Size() int

Size returns the number of bytes in the hash output (32 bytes for a field element).

func (*Poseidon) Sum

func (p *Poseidon) Sum(data []byte) []byte

Sum appends the current hash to b and returns the resulting slice. It implements hash.Hash.

func (*Poseidon) Update

func (p *Poseidon) Update(xs ...*pasta.PallasBaseFieldElement)

Update absorbs field elements into the sponge state and applies the permutation.

func (*Poseidon) Write

func (p *Poseidon) Write(data []byte) (n int, err error)

Write implements io.Writer by converting bytes to field elements and hashing them. The data length must be a multiple of 32 bytes.

Jump to

Keyboard shortcuts

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