Skip to content

feat: add modexp example guest program and benchmark (#1067)#1308

Open
RajeshRk18 wants to merge 2 commits intoa16z:mainfrom
RajeshRk18:add/modexp-example
Open

feat: add modexp example guest program and benchmark (#1067)#1308
RajeshRk18 wants to merge 2 commits intoa16z:mainfrom
RajeshRk18:add/modexp-example

Conversation

@RajeshRk18
Copy link
Copy Markdown

Add examples/modexp/ performing chained modular exponentiation (base^exp mod modulus) using num-bigint BigUint::modpow with configurable bit lengths and iteration count.

Add Modexp variant to e2e_profiling.rs benchmark.

Add examples/modexp/ performing chained modular exponentiation
(base^exp mod modulus) using num-bigint BigUint::modpow with
configurable bit lengths and iteration count.

Add Modexp variant to e2e_profiling.rs benchmark.
@RajeshRk18 RajeshRk18 marked this pull request as ready for review March 4, 2026 14:35
Copy link
Copy Markdown
Collaborator

@moodlezoup moodlezoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo run --release -p modexp fails (need to increase max_trace_length and CYCLES_PER_MODEXP_256 is inaccurate

@moodlezoup
Copy link
Copy Markdown
Collaborator

also, could you address the machete failure in CI?

- Switch modexp-guest to no-std with fixed [u8; 32] arrays
- Remove unused num-traits dep (fixes machete CI)
- Remove num-bigint from host (no longer needed)
- Increase max_trace_length to 2^26 (67M)
- Set CYCLES_PER_MODEXP_256 to 883493 (empirically measured)
let prover_preprocessing = guest::preprocess_prover_modexp(shared_preprocessing.clone());
let verifier_setup = prover_preprocessing.generators.to_verifier_setup();
let verifier_preprocessing =
guest::preprocess_verifier_modexp(shared_preprocessing, verifier_setup);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
guest::preprocess_verifier_modexp(shared_preprocessing, verifier_setup);
guest::preprocess_verifier_modexp(shared_preprocessing, verifier_setup, None);

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.

3 participants