Skip to content

Conversation

@chetanyb
Copy link
Contributor

Summary

Adds a WIDTH constant to Poseidon2 type definitions to enable compile-time width validation.

Motivation

Poseidon2 has multiple width variants, but there was no programmatic way to verify which variant a type represents at compile time. This can lead to subtle bugs where code expects one width but receives another.

Benefits

  1. Compile-time safety: Downstream code can verify the width with:
    comptime {
        if (Poseidon2Type.WIDTH != 24) {
            @compileError("Expected width-24");
        }
    }
    
  2. Better type documentation: The width is now part of the type's public interface
  3. Prevents runtime errors: Catches width mismatches before code runs

@chetanyb chetanyb requested a review from ch4r10t33r December 18, 2025 21:31
Copy link
Collaborator

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ch4r10t33r ch4r10t33r merged commit 2bca654 into blockblaz:master Dec 18, 2025
5 checks passed
@chetanyb chetanyb deleted the add-width-const branch December 19, 2025 06:07
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.

2 participants