Skip to content

Feat: Add Canonical Round Constants for Poseidon2 KoalaBear Spec #4

@tcoratger

Description

@tcoratger

Context

In #3, a discussion was raised regarding the generation of round constants (#3 (comment)). The current spec uses a simplified, non-compliant function (_generate_spec_test_round_constants) that generates sequential integers ([0, 1, 2, ...]).

This approach was intentionally chosen as a temporary measure to simplify initial implementation and allow for direct comparison with a reference Rust implementation without needing to hardcode a large, arbitrary array of values.

The Problem

While useful for testing the algebraic structure, using simple sequential integers is not representative of a production-grade cryptographic primitive.

The current function is explicitly named to reflect its non-compliant, test-only nature, but the long-term goal for a canonical specification should be to use fixed, pseudo-random constants.

Proposed Solution

To align the KoalaBear Poseidon2 spec with best practices and other reference implementations, we should replace the test generation function with a pre-computed, hardcoded array of canonical round constants.

This would follow the precedent set by other fields, such as BabyBear, which uses a set of hardcoded constants for performance and security reasons.
Reference: Plonky3 BabyBear Poseidon2 Constants

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions