This directory contains the Android implementation of IMP1, a mobile-first zero-knowledge proving framework powered by ICICLE.
IMP1 for Android provides:
- Kotlin library with ICICLE inside
- Groth16 protocol implementation for zero-knowledge proofs
- Parallel proof generation for batch processing
- Optimized for arm64-v8a architecture
- Drop-in integration for Android applications
Before building the library, ensure you have:
- Android Studio (latest version recommended)
- Android SDK with API level 24+
- Java 21 (required for Android Gradle plugin compatibility)
- Rust toolchain installed (
rustup) - Android NDK (r27c or later)
- Git with access to the IMP1 repository
First, clone and setup the repository:
git clone https://github.com/ingonyama-zk/imp1.git
cd imp1
git submodule update --init --recursiveUse the automated build script for the complete workflow:
# Build library and example app
cd android
./scripts/build_example_app.sh
# For debug build with local testing on USB-connected device
./scripts/build_example_app.sh --debugThis script will:
- Build the Rust vendor library
- Build the AAR library (both debug and release)
- Copy the AAR to ExampleApp
- Build and install the ExampleApp (with optional local testing)
./scripts/build_vendor.shThis script will:
- Download Android NDK if not present locally
- Install Rust Android targets (aarch64-linux-android)
- Build ICICLE-SNARK for Android arm64-v8a
- Copy native libraries to the Android project
./scripts/build_lib.shThis creates:
imp1/app/build/outputs/aar/imp1-0.2.2-release.aar- Release versionimp1/app/build/outputs/aar/imp1-0.2.2-debug.aar- Debug version
./build_example_app.shFor a full development cycle:
# 1. Build everything (recommended)
cd android
./scripts/build_example_app.sh
# 2. For development with debug output
./scripts/build_example_app.sh --debug
# 3. When you make changes to the library, repeat:
./scripts/build_lib.sh
./scripts/build_example_app.shNote: All scripts should be run from the android directory.
android/
├── imp1/ # Main library project
│ ├── app/
│ │ ├── src/main/
│ │ │ ├── java/ # Kotlin source code
│ │ │ ├── cpp/ # C++ JNI bridge
│ │ │ └── jniLibs/ # Native libraries
│ │ └── build.gradle.kts # Library configuration
│ └── scripts/
│ └── build_vendor.sh # Rust dependency builder
├── ExampleApp/ # Example application
│ ├── app/
│ │ ├── src/main/
│ │ │ ├── java/ # Example app source code
│ │ │ └── assets/ # Circuit files and examples
│ │ └── libs/ # AAR library location
└── scripts/ # Build utilities
├── build_lib.sh # Library build script
├── build_example_app.sh # Complete build script
└── build_vendor.sh # Rust dependency builder
- Copy the AAR to your Android project's
libs/directory - Add dependency in your
build.gradle.kts:implementation(files("libs/imp1-0.2.2.aar")) - Import the library in your Kotlin code:
import com.ingonyama.imp1.NativeBridge import com.ingonyama.imp1.DeviceType import com.ingonyama.imp1.ProverException import com.ingonyama.imp1.VerifierResult
The library provides a simple interface through NativeBridge:
// Generate a proof
try {
NativeBridge.prove(
witnessPath = "path/to/witness.wtns",
zkeyPath = "path/to/circuit_final.zkey",
proofPath = "path/to/output.proof",
publicPath = "path/to/output.public",
deviceType = DeviceType.Cpu
)
println("Proof generated successfully!")
} catch (e: ProverException) {
println("Proof generation failed: ${e.message}")
}// Generate multiple proofs in parallel
try {
val results = NativeBridge.parallelProve(
witnessPaths = arrayOf("witness1.wtns", "witness2.wtns", "witness3.wtns"),
zkeyPath = "path/to/circuit_final.zkey",
proofPaths = arrayOf("proof1.proof", "proof2.proof", "proof3.proof"),
publicPaths = arrayOf("public1.public", "public2.public", "public3.public"),
deviceType = DeviceType.Cpu,
maxBatchSize = 0L // 0 = auto-detect optimal batch size
)
// Process results
for ((index, result) in results.withIndex()) {
when (result.value) {
0 -> println("Proof ${index + 1}: Success")
1 -> println("Proof ${index + 1}: Failed")
}
}
} catch (e: ProverException) {
println("Parallel proof generation failed: ${e.message}")
}// Verify a proof
val result = NativeBridge.verify(
proofPath = "path/to/proof.proof",
publicPath = "path/to/public.public",
vkPath = "path/to/verification_key.json"
)
when (result) {
VerifierResult.VerifierSuccess -> println("Proof verified!")
VerifierResult.VerifierFailure -> println("Proof verification failed!")
}The ExampleApp/ directory contains a complete implementation showing:
- Library integration with proper error handling
- Single and parallel proof generation
- Proof verification for all generated proofs
- UI examples with different circuit types (SHA256, AES, etc.)
- Progress indicators and user feedback
- Asset management for circuit files
- Multiple circuit examples: SHA256, AES-128-CTR, AES-256-CTR, ChaCha20
- Parallel proof testing: Generate multiple proofs simultaneously
- Real-time feedback: Progress bars and detailed status messages
- Error handling: Comprehensive error reporting and recovery
- Performance metrics: Timing information for proof generation and verification
- Android: arm64-v8a only
- Minimum SDK: API level 24 (Android 7.0)
- Target SDK: API level 36 (Android 14)
- Java: 21 (automatically detected and configured)
The library is optimized for mobile devices and includes:
- Native Rust implementation for maximum performance
- Parallel proof generation for batch processing
- JNI bridge for seamless Kotlin integration
- NDK Version: r27c (automatically downloaded if needed)
- Rust Targets: aarch64-linux-android
- C++ Standard: C++17
- STL: c++_shared
- Java: 21 (auto-detected)
scripts/build_vendor.sh- Builds Rust dependencies and native librariesscripts/build_lib.sh- Builds the AAR libraryscripts/build_example_app.sh- Complete build workflow
- Java version issues: The build scripts automatically detect and configure Java 21
- NDK not found: The build script will automatically download NDK r27c
- Rust targets missing: Run
rustup target add aarch64-linux-android - Build fails: Ensure all submodules are initialized
- Native library errors: Verify the Rust build completed successfully
- Parallel proof generation support
- Automated build scripts for easier development
MIT License - see the main project LICENSE file for details.