Example and reference testing harness for the "Accelerating MSM on Mobile" challenge in ZPrize 2022.
Building the Android app can be accomplished with Android Studio:
- Download Android Studio and install the Android API 32 platform, NDK, and Android SDK Platform tools through the SDK Manager.
- Open
android/Zprize
in Android Studio. - Use Android Studio's device manager to select either an emulator or physical device.
- Install the app on that device using the Run > Run 'app' menu action.
Prebuilt libraries are available in this repository as android/ZPrize/app/src/main/jniLibs/armeabi-v7a
.
When you modify the Rust libraries, build the modified library for inclusion in the Android app:
- Download the cross crate.
- Run
cross build --target armv7-linux-androideabi --release
- Copy
target/armv7-linux-androideabi/release/libcelo_zprize.so
toandroid/ZPrize/app/src/main/jniLibs/armeabi-v7a/libmsm.so
. - Rebuild and install the app as described above.
Building for aarch64
can also be achieved by with cross build --target aarch64-linux-android --release
and placing the resulting library in android/ZPrize/app/src/main/jniLibs/arm64-v8a/libmsm.so
A number of static test vectors to check the basic correctness of the MSM implementation are included, as described in the prize specification.
To modify the fixed test vectors, add the new test vector files to android/ZPrize/app/src/main/assets/points
and android/ZPrize/app/src/main/assets/scalars
, then recompile the app.
To generate new test vector files, first generate the vectors, then run serialize_input
once per vector with the same directory specified, with the append
option set to true
. This process is demonstrated in src/main.rs
for one vector.
You can run a benchmark locally (on your computer) with run cargo run --release
. The local
benchmark is defined in src/main.rs
.
On the Android device, output files were stored to data/data/com.example.zprize/files/
.
The output group elements of the MSM, one per iteration, are stored in result.txt
.
The time per iteration is recorded in resulttimes.txt
.
When running test vectors, the files will contain the results for each vector of inputs in sequence.
Pulling files from the device filesystem to your host can be accomplished with Android Studio or
with ADB. Below is an example for getting the resulttimes.txt
file.
adb -d shell 'run-as com.example.zprize cat /data/data/com.example.zprize/files/resulttimes.txt' > resulttimes.txt