Skip to content

Perform final reduction of Horner poly evaluation - #593

Closed
sug0 wants to merge 1 commit into
cloudflare:mainfrom
sug0:tiago/horner-final-reduction
Closed

Perform final reduction of Horner poly evaluation#593
sug0 wants to merge 1 commit into
cloudflare:mainfrom
sug0:tiago/horner-final-reduction

Conversation

@sug0

@sug0 sug0 commented Mar 30, 2026

Copy link
Copy Markdown

Amendment to #590

Gets rid of modular arithmetic in additions, which stays within the bounds of the ring modulus, saving a few CPU cycles. The operations are const time on a best-effort basis... Switching from math/big to a library with Montgomery reductions is actually the better approach here.

Gets rid of modular arithmetic in additions, which stays within the bounds of the field modulus.
@armfazh armfazh added the enhancement Improvement over something already in the project label Mar 31, 2026
@armfazh
armfazh self-requested a review March 31, 2026 20:51
@armfazh

armfazh commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

I measured and the time difference is a small percentage on my machine. Also note that adding without performing modular reduction (i.e., lazy reduction) may reveal some information about the coefficients in the case the number of words of sum grows, making that the subsequent multiplication takes more time. Of course, the entire arithmetic still uses big.Int and some replacement is needed too. Let's do modular reduction to cover that edge case.

@sug0 thanks for the proposed change.

@armfazh armfazh closed this Mar 31, 2026
@armfazh armfazh added the fix-A-bug code that fix a bug label Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement over something already in the project fix-A-bug code that fix a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants