Skip to content

Refactor Poseidon sponge types to use const generic arrays instead of vectors #2056

@dannywillems

Description

@dannywillems

Summary

Replace dynamic vector allocations in Poseidon sponge types with fixed-size arrays using const generics, improving memory layout and reducing allocations.

Motivation

The current ArithmeticSpongeParams uses Vec<Vec<F>> for round constants, which:

  • Scatters data across the heap
  • Requires dynamic allocations during initialization
  • Prevents compile-time size verification

Using const generic arrays allows:

  • Stack allocation when possible
  • Contiguous memory layout
  • Compile-time verification of round counts
  • Small but consistent performance improvement

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions