Skip to content

nistath/zprize-mobile-msm

Repository files navigation

ZPrize MSM on Mobile Reference Test Harness

Example and reference testing harness for the "Accelerating MSM on Mobile" challenge in ZPrize 2022.

Changelog

  • Use latest arkworks
  • Make serialization format compatible with arkworks 0.3.0
  • Add CPU target flags
  • Enable LTO

Build

Android app

Building the Android app can be accomplished with Android Studio:

  1. Download Android Studio and install the Android API 32 platform, NDK, and Android SDK Platform tools through the SDK Manager.
  2. Open zprize-mobile-harness/android/Zprize in Android Studio.
  3. Use Android Studio's device manager to select either an emulator or physical device.
  4. Install the app on that device using the Run > Run 'app' menu action.

Rust library

Prebuilt libraries are available in this repository as zprize-mobile-harness/android/ZPrize/app/src/main/jniLibs/armeabi-v7a. When you modify the Rust libraries, build the modified library for inclusion in the Android app:

  1. Run cargo build --target armv7-linux-androideabi --profile release
  2. Copy target/armv7-linux-androideabi/release/libcelo_zprize.so to android/ZPrize/app/src/main/jniLibs/armeabi-v7a/libmsm.so.
  3. 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

Test vectors

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.

Benchmarking on host

You can run a benchmark locally (on your computer) with run cargo run --release. The local benchmark is defined in src/main.rs.

Benchmarking on device

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

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages