poseidon

package
v0.0.0-...-ba6c393 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const NROUNDSF = 8

NROUNDSF constant from Poseidon paper

Variables

View Source
var NROUNDSP = []int{56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68}

NROUNDSP constant from Poseidon paper

Functions

func BigInts2DtoElements2D

func BigInts2DtoElements2D[E Element[E]](bi [][]*big.Int) [][]E

func BigIntsToElements

func BigIntsToElements[E Element[E]](bi []*big.Int) []E

func Exp

func Exp[E Element[E]](z, x E, k *big.Int)

Exp is a copy of gnark-crypto's implementation, but takes a pointer argument

func Hash

func Hash[E Element[E]](inpBI []*big.Int) (*big.Int, error)

Hash computes the Poseidon hash for the given inputs

func HashBytes

func HashBytes[E Element[E]](msg []byte) (*big.Int, error)

HashBytes returns a sponge hash of a msg byte slice split into blocks of 31 bytes

func HashBytesX

func HashBytesX[E Element[E]](msg []byte, frameSize int) (*big.Int, error)

HashBytesX returns a sponge hash of a msg byte slice split into blocks of 31 bytes

func HashEx

func HashEx[E Element[E]](inpBI []*big.Int, initialState *big.Int) (*big.Int, error)

func HashMulti

func HashMulti[E Element[E]](inpBI []*big.Int) (*big.Int, error)

func Modulus

func Modulus[E Element[E]]() *big.Int

func NewElement

func NewElement[E Element[E]]() E

func SpongeHash

func SpongeHash[E Element[E]](inputs []*big.Int) (*big.Int, error)

SpongeHash returns a sponge hash of inputs (using Poseidon with frame size of 16 inputs)

func SpongeHashX

func SpongeHashX[E Element[E]](inputs []*big.Int, frameSize int) (*big.Int, error)

SpongeHashX returns a sponge hash of inputs using Poseidon with configurable frame size

Types

type Element

type Element[E any] interface {
	SetUint64(uint64) E
	SetBigInt(*big.Int) E
	BigInt(*big.Int) *big.Int
	SetOne() E
	SetZero() E
	Inverse(E) E
	Set(E) E
	Square(E) E
	Mul(E, E) E
	Add(E, E) E
	Sub(E, E) E
	Marshal() []byte
}

Jump to

Keyboard shortcuts

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