argumentcomputer / argumentcomputer/sphinx

`Polynomial` should not allocate

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.