argumentcomputer / argumentcomputer/sphinx
`Polynomial` should not allocate
- Dominant language
- Rust
- Stars
- 80
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
The [`Polynomial`](https://github.com/wormhole-foundation/wp1/blob/b786354f4419cfd1421d3f4b8444c9ac51fda104/core/src/air/polynomial.rs#L11) struct represents its coefficients as a `Vec`. Because these are also used by various `Air::eval` implementations, this means that vectors are being allocated at every row evaluation during proving.
Ideally, the coefficients should be stored in a fixed size array, though this would conflict with the arithmetic operations that cannot return a different type.
The arithmetic operations could be replaced with methods though so that they can return the right type (e.g. multiplication of two polynomial with degree `N` would return a polynomial of degree `2N`)
Contributor guide
Research direction
Start with core/src/air/polynomial.rs and inspect how Polynomial is used by the Air::eval implementations during proving. Determine how fixed-size coefficient storage can coexist with arithmetic whose result degree changes. Done means row evaluations no longer allocate vectors while polynomial arithmetic still represents the required result degrees.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100