Skip to content

Add multi-round absorption for inputs larger than rate #2

@jayz22

Description

@jayz22

What problem does your feature solve?

Currently (upon merging #1 ), both Poseidon and Poseidon2 only support single-round absorption, meaning the number of inputs is limited to the rate (T - 1). For example, with T=4 (rate=3), you can only hash up to 3 field elements:

  // T=4 means rate=3, so maximum 3 inputs                                                                                                                                                                                                  
  let inputs = vec![&env, a, b, c, d]; // 4 inputs - PANICS                                                                                                                                                                                 
                                                                                                                                                                                                                                            
  let mut sponge = Poseidon2Sponge::<4, BnScalar>::new(&env);                                                                                                                                                                               
  let _ = sponge.compute_hash(&inputs);     

This limits usability for hashing larger data structures or variable-length inputs.

What would you like to see?

Multi-round absorption that allows hashing arbitrary-length inputs by repeatedly absorbing and permuting inputs in chunks until all inputs are absorbed. Proper padding must be accounted for.

Current blocker: requires field addition operation for bn254 (bn254_fr_add), which isn't currently available but are planned for the next protocol version.

What alternatives are there?

  1. Use a larger state size (e.g., T=6 for Poseidon supports up to 5 inputs)
  2. Implement guest-side bn254_fr_add

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