This repository is an example of how to use the cryptimeleon libraries on android.
We therefore implement the Pointcheval-Sanders signature scheme from the pairing tutorial.
- Create a new android project in Android Studio.
- Add cryptimeleon dependencies to
app/build.gradle
:You can find details on the maven pages: math, cracoimplementation 'org.cryptimeleon:math:3.+' implementation 'org.cryptimeleon:craco:3.+'
Note: When running using a Virtual Device (Android Emulator), make sure to use a x86_64
image.
We use the C++ library herumi/mcl as a fast implementation of the BarretoNaehrig group. This provides a massive speedup compared to the Java implementation.
We provide a precompiled version of mcljava
for different architectures at app/src/main/jniLibs
.
To use them, you need to load the library with the System.loadLibrary("mcljava")
command.
By adding the dependency implementation 'org.cryptimeleon:mclwrap:3.0.0'
to the inner build.gradle, you get access to the MclBilinearGroup
.
This needs to be compiled using NDK and added to the project as a jniLib.
- Install NDK
- Checkout MCL with the correct version (currently v1.28, which is the first release with native android support)
- Build mcl (might not be necessary) by following the instructions
- Build mcl for android: Go to
mcl/ffi/java/android/jni
and callndk-build
(either add ndk-build to your path, or use an absolute path, e.g.$<path-to-mcl>/ffi/java/android/jni$ ~/Android/Sdk/ndk/22.1.7171670/ndk-build
). Currently, mcl's Application.mk builds native libraries for the arm64-v8a, armeabi-v7a and x86_64 architectures. If you require additional architectures (e.g. x86 for the Android emulator), add a space and the architecture name at the and of the line starting with APP_ABI in Application.mk before invoking ndk-build - Copy the directories in
mcl/ffi/java/android/libs
(which contain thelibmcljava.so
file) toapp/src/main/jniLibs
- Load mcl in the app prior usage with
System.loadLibrary("mcljava")
, e.g. inMainActivity.onCreate
. - Add the dependency
implementation 'org.cryptimeleon:mclwrap:3.0.0'
to the app's build.gradle