Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binius counts #353

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Binius counts #353

wants to merge 3 commits into from

Conversation

sragss
Copy link
Collaborator

@sragss sragss commented May 9, 2024

Implements the conversion to multiplicities for Binius counts as described in Section 4.4 of the Binius paper. Does not wire it into the offline memory checking system yet.

Runs a similar strategy to halo2curves::PrimeField and our fork of Arkworks to precompute some tables to reduce the cost of calls to from_count_index. Unfortunately does not move all the pre-computation work to compile time as the Binius library does not currently have a const fn impl. If this does get implemented we can revert back to 1241739007964a4e2c2ba71fc07e76082a0ca925 which is substantially simpler.

Thaler's optimization strategy:

  • Split the count $x$ such that $x = a \cdot 2^{16} + b$ with $a$ and $b$ each ranging from $0$ to $2^{16}$.
  • Maintain two lookup tables:
    • One for $2^{16}$ powers of $g^{2^{16}}$.
    • Another for $2^{16}$ powers of $g$.
  • Any count up to $2^{32}$ can be computed using two lookups and one multiplication:
    $$g^x = (g^{2^{16}})^a \cdot g^b$$

2^32 may be overkill and we would get significant speedups on the initialization time of tables by reducing size.

@sragss sragss changed the title feat: Binius counts Binius counts May 9, 2024
@sragss sragss marked this pull request as ready for review May 9, 2024 23:31
@sragss sragss requested a review from moodlezoup May 9, 2024 23:31
Base automatically changed from sragss/binius to main June 5, 2024 22:20
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.

1 participant