Skip to content

Conversation

Copy link

Copilot AI commented Nov 3, 2025

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)


✨ 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 AI changed the title [WIP] Add modexp example guest program and benchmark Add modexp-chain example and benchmark Nov 3, 2025
Copilot AI requested a review from moodlezoup November 3, 2025 18:40
Copilot finished work on behalf of moodlezoup November 3, 2025 18:40
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.

Add a modexp example guest program + benchmark

2 participants