jolt icon indicating copy to clipboard operation
jolt copied to clipboard

Add modexp-chain example and benchmark

Open Copilot opened this issue 4 months ago • 0 comments

Adds a modular exponentiation example guest program and corresponding benchmark, following the pattern established by sha2-chain.

Implementation

  • Guest program (examples/modexp-chain/): Implements chained modexp operations using num-bigint's modpow method. Configurable at compile-time via BITLEN_BYTES constant (default: 256-bit) and runtime via num_iters parameter. Includes modulus validation.

  • Benchmark integration (jolt-core/benches/e2e_profiling.rs): Adds ModexpChain variant with scaling based on estimated 50k cycles per operation. Follows existing benchmark patterns for sha2/sha3 chains.

Example Usage

// Change bit length at compile time in guest/src/lib.rs
const BITLEN_BYTES: usize = 32;  // 256-bit (default)
const BITLEN_BYTES: usize = 64;  // 512-bit
const BITLEN_BYTES: usize = 128; // 1024-bit

// Configure iterations at runtime in src/main.rs
let iters = 10; // Number of modexp operations to chain

Run example: cargo run --release -p modexp-chain

Run benchmark: cargo bench --bench e2e_profiling -- --bench-type modexp-chain

Dependencies

Adds num-bigint (0.4.6) and num-traits (0.2.19) with no_std support for guest program.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a modexp example guest program + benchmark</issue_title> <issue_description>Add a guest program performing modexp (a la EVM) operations to examples/ and a corresponding benchmark to e2e_profiling.rs. The bitlength of the base, modulus, and exponent should be configurable, as well as the number of iterations (similar to the sha2-chain example). </issue_description>

<agent_instructions>Refer to the other example guest programs (specifically, sha2-chain is instructive) under the examples/ directory to write the modexp example. Similarly, you can pattern match on the sha2-chain stuff in e2e_profiling.rs. You'll probably want to pull in some dependencies for the modexp implementation. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

  • Fixes a16z/jolt#1067

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Nov 03 '25 17:11 Copilot