This repository contains the implementation of a Stylus-based Compute Provider for encrypted execution environments, designed to securely process votes using Fully Homomorphic Encryption (FHE) directly on-chain. This compute provider leverages Arbitrum Stylus to perform on-chain computations efficiently while ensuring data privacy and integrity.
Check ensures the contract can be compiled and deployed to Stylus.
cargo stylus check --verbose
To use a different endpoint
cargo stylus check --verbose --endpoint='http://127.0.0.1:8449'
cargo stylus deploy --no-verify --verbose \
--endpoint='http://127.0.0.1:8449' \
--private-key="<PRIVATE_KEY>"
Run the unit and integration tests to verify the FHE computation functionality:
# Run all tests
cargo test
You can run the FHE computation locally without connecting to an RPC endpoint:
# Set environment variable to run locally
export RUN_LOCAL=true
# Run the example
cargo run --example stylus_provider
To run the computation via RPC against a deployed contract:
# Create a .env file with your configuration
cp .env.example .env
# Edit .env with your private key, RPC URL, and contract address
# Run the example
RUN_LOCAL=false cargo run --example stylus_provider
src/lib.rs
- Main library and contract implementationsrc/processor.rs
- FHE computation logicsrc/merkle.rs
- Merkle tree implementation for verificationexamples/stylus_provider.rs
- Example client for interacting with the contracttests/integration_test.rs
- Integration tests
To add new FHE operations, modify the fhe_processor
function in src/processor.rs
. The current implementation performs a simple summation of all ciphertexts.