Skip to content

fix: correct Poseidon2 KoalaBear partial rounds to 20 (security parameter) - #525

Open
mhmdrizzzki wants to merge 1 commit into
ProjectZKM:mainfrom
mhmdrizzzki:fix/poseidon2-rounds
Open

fix: correct Poseidon2 KoalaBear partial rounds to 20 (security parameter)#525
mhmdrizzzki wants to merge 1 commit into
ProjectZKM:mainfrom
mhmdrizzzki:fix/poseidon2-rounds

Conversation

@mhmdrizzzki

Copy link
Copy Markdown

Summary

Changes ROUNDS_P/NUM_INTERNAL_ROUNDS from 13 → 20 across all 4 Poseidon2 layers.

Why

Per both upstream Plonky3 and the project's own fork (ProjectZKM/Plonky3), the correct partial rounds for KoalaBear (31-bit, width 16, alpha=3) is 20, not 13.

Reference: poseidon2/src/round_numbers.rs:40:

31 => match (width, d) {
    (16, 3) => (8, 20),

The project already provides 30 round constants (RC_16_30) which implies the config was always intended for 8+20=28 rounds (plus 2 buffer).

Files changed

  • crates/primitives/src/lib.rsROUNDS_P in poseidon2_init()
  • crates/core/machine/src/operations/poseidon2/mod.rs — kernel prover
  • crates/recursion/core/src/chips/poseidon2_skinny/mod.rs — recursion skinny
  • crates/recursion/core/src/chips/poseidon2_wide/mod.rs — recursion wide
  • crates/stark/src/kb31_poseidon2.rs — test reference (was self-referentially wrong)

Fixes #524

…eter)

Changes ROUNDS_P/NUM_INTERNAL_ROUNDS from 13 to 20 across all 4 layers:

- crates/primitives/src/lib.rs: poseidon2_init() — ROUNDS_P 13->20
- crates/core/machine/.../poseidon2/mod.rs: kernel prover — 13->20
- crates/recursion/.../poseidon2_skinny/mod.rs: recursion skinny — 13->20
- crates/recursion/.../poseidon2_wide/mod.rs: recursion wide — 13->20
- crates/stark/src/kb31_poseidon2.rs: test reference ROUNDS_P — 13->20

Fixes ProjectZKM#524

Reference: Plonky3 poseidon2/src/round_numbers.rs line 40:
(16, 3) => (8, 20)  # KoalaBear 31-bit, width=16, alpha=3
@eigmax

eigmax commented Aug 27, 2026

Copy link
Copy Markdown
Member

Thanks, we have this discussed internally for a while, we have the plan to do this upgrade in some branch. previously documented in 43185de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poseidon2 KoalaBear (width 16, alpha=3) uses only 13 partial rounds instead of required 20 — undermines Fiat-Shamir & Merkle commitments

2 participants