Skip to content

Conversation

yczhangsjtu
Copy link
Collaborator

@yczhangsjtu yczhangsjtu commented Aug 7, 2025

Summary

Resolves #47. This PR computes the verifier_folding_coeffs_level(log2_height, idx) in a iterative way.

Math

The underlying math behind this new iterative algorithm is

  1. For level $L$, we have the coeff $c = 1/2 * g^{-bitrev(i)}$ where $g^{2^L} = -1$.
  2. Given the little-endian bits representation of $i$ we have $i = i_0 + i_1 * 2^1 + ... + i_{L-1} * 2^{L-1}$;
  3. It's easy to see $bitrev(i) = bitrev(i/2) + i_0 * 2^{L-1}$;
  4. For level $L-1$, we have the coeff $c' = 1/2 * g'^{-bitrev(i/2)}$ where $g' = g^2$;
  5. This is equivalent to $c' = 1/2 * g^{-2*bitrev(i) + i_0 * 2^L} = 2 * c^2 * (-1)^{i_0} $.

Therefore we have this recursive formula

$$c' = 2 * c^2 * (-1)^{i_0}$$

Performance

ceno guest program cycle (before) cycle (after)
fib(2^10) 1402187 1292138 (8%⬇️)
fib(2^20) 1899653 1698723 (10%⬇️)

@kunxian-xia kunxian-xia linked an issue Aug 7, 2025 that may be closed by this pull request
@kunxian-xia kunxian-xia added the enhancement New feature or request label Aug 7, 2025
@kunxian-xia kunxian-xia changed the base branch from feat/zkvm-profile-cycles-split-basefold to main August 7, 2025 12:23
@kunxian-xia kunxian-xia changed the base branch from main to feat/zkvm-profile-cycles-split-basefold August 7, 2025 12:23
@yczhangsjtu yczhangsjtu changed the base branch from feat/zkvm-profile-cycles-split-basefold to main August 7, 2025 12:25
@kunxian-xia kunxian-xia self-requested a review August 7, 2025 14:20
@kunxian-xia kunxian-xia merged commit df96d8b into main Aug 7, 2025
2 checks passed
@kunxian-xia kunxian-xia deleted the feat/zkvm-profile-cycles-split-fri branch August 7, 2025 15:55
@kunxian-xia kunxian-xia mentioned this pull request Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BaseFold verifier cycle reduction: FRI rounds part
2 participants