Skip to content

Conversation

@tarcieri
Copy link
Member

Loops over the input blocks performing karatsuba using powers-of-H and accumulating a wide product (in normal and bit-reversed form), then performing a final mont_reduce.

This avoids performing a mont_reduce on each block (although to be fair, it just performs shifts/XORs and is not nearly as expensive as the multiplications in karatsuba). It could perhaps be improved by splitting karatsuba into karatsuba1/karatsuba2 like the other backends and skipping the recombination/product assembly steps.

This uses 1 as FieldElement::DEFAULT_PARALLELISM (which it seems was mistakenly set to 8 before) so this functionality is not on-by-default. It seems like it will probably not be much of a win without additional work.

Even if it's not though, all backends now have the same structure and soft is not a weird special case when used with N > 1.

Also adds a proptest that whatever parallel backend is in use produces equivalent results to a pure Rust serial implementation, using the FieldElement type's public API (namely Add and Mul) via the newly added hazmat feature.

@tarcieri tarcieri force-pushed the polyval/powers-of-h-for-soft-backend branch from bb3ed65 to 853866a Compare January 28, 2026 01:07
Loops over the input blocks performing `karatsuba` using powers-of-H
and accumulating a wide product (in normal and bit-reversed form),
then performing a final `mont_reduce`.

This avoids performing a `mont_reduce` on each block (although to be
fair, it just performs shifts/XORs and is not nearly as expensive as the
multiplications in `karatsuba`). It could perhaps be improved by
splitting `karatsuba` into `karatsuba1`/`karatsuba2` like the other
backends and skipping the recombination/product assembly steps.

This uses `1` as `FieldElement::DEFAULT_PARALLELISM` (which it seems was
mistakenly set to `8` before) so this functionality is not
on-by-default. It seems like it will probably not be much of a win
without additional work.

Even if it's not though, all backends now have the same structure and
`soft` is not a weird special case when used with `N > 1`.

Also adds a proptest that whatever parallel backend is in use produces
equivalent results to a pure Rust serial implementation, using the
`FieldElement` type's public API (namely `Add` and `Mul`) via the newly
added `hazmat` feature.
@tarcieri tarcieri force-pushed the polyval/powers-of-h-for-soft-backend branch from 853866a to 3fca7ce Compare January 28, 2026 01:14
@tarcieri tarcieri merged commit d4ad8b0 into master Jan 28, 2026
51 checks passed
@tarcieri tarcieri deleted the polyval/powers-of-h-for-soft-backend branch January 28, 2026 01:21
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