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 ¶
- Variables
- func NewLegacyHash() hash.Hash
- type Parameters
- type Poseidon
- func (*Poseidon) BlockSize() int
- func (p *Poseidon) Digest() *pasta.PallasBaseFieldElement
- func (p *Poseidon) Hash(xs ...*pasta.PallasBaseFieldElement) *pasta.PallasBaseFieldElement
- func (p *Poseidon) Rate() int
- func (p *Poseidon) Reset()
- func (*Poseidon) Size() int
- func (p *Poseidon) Sum(data []byte) []byte
- func (p *Poseidon) Update(xs ...*pasta.PallasBaseFieldElement)
- func (p *Poseidon) Write(data []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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) Digest ¶
func (p *Poseidon) Digest() *pasta.PallasBaseFieldElement
Digest returns the current hash output as the first element of the state.
func (*Poseidon) Hash ¶
func (p *Poseidon) Hash(xs ...*pasta.PallasBaseFieldElement) *pasta.PallasBaseFieldElement
Hash resets the state, absorbs the input field elements, and returns the digest.
func (*Poseidon) Rate ¶
Rate returns the rate of the sponge construction (number of field elements absorbed per permutation).
func (*Poseidon) Size ¶
Size returns the number of bytes in the hash output (32 bytes for a field element).
func (*Poseidon) Sum ¶
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.