https://github.com/cryptimeleon/android-demo
An example project with instructions on how to use cryptimeleon on android.
https://github.com/cryptimeleon/android-demo
android android-app cryptography mcl pairing
Last synced: about 1 month ago
JSON representation
An example project with instructions on how to use cryptimeleon on android.
- Host: GitHub
- URL: https://github.com/cryptimeleon/android-demo
- Owner: cryptimeleon
- License: apache-2.0
- Created: 2021-06-25T07:37:27.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-03T17:08:56.000Z (about 4 years ago)
- Last Synced: 2025-09-10T06:27:01.470Z (5 months ago)
- Topics: android, android-app, cryptography, mcl, pairing
- Language: Java
- Homepage: https://cryptimeleon.org/getting-started/pairing-tutorial.html
- Size: 6.87 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/cryptimeleon/android-demo/actions/workflows/workflow.yaml)
# Cryptimeleon on Android
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](https://cryptimeleon.github.io/getting-started/pairing-tutorial.html).

## How to use cryptimeleon on android
1. Create a new android project in Android Studio.
2. Add cryptimeleon dependencies to `app/build.gradle`:
```
implementation 'org.cryptimeleon:math:3.+'
implementation 'org.cryptimeleon:craco:3.+'
```
You can find details on the maven pages: [math](https://search.maven.org/artifact/org.cryptimeleon/math/3.0.1/jar), [craco](https://search.maven.org/artifact/org.cryptimeleon/craco/3.0.1/jar)
**Note:** When running using a Virtual Device (Android Emulator), make sure to use a `x86_64` image.
## Faster pairings with mcl
We use the C++ library [herumi/mcl](https://github.com/herumi/mcl) as a fast implementation of the BarretoNaehrig group.
This provides a massive speedup compared to the Java implementation.
### Precompiled library
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`.
### Compile MCL for android
This needs to be compiled using NDK and added to the project as a jniLib.
1. Install [NDK](https://developer.android.com/studio/projects/install-ndk)
2. Checkout [MCL](https://github.com/herumi/mcl) with the *correct version* (currently v1.28, which is the first release with native android support)
3. Build mcl (might not be necessary) by following the instructions
4. Build mcl for android: Go to `mcl/ffi/java/android/jni` and call `ndk-build` (either add ndk-build to your path, or use an absolute path, e.g. `$/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
5. Copy the directories in `mcl/ffi/java/android/libs` (which contain the `libmcljava.so` file) to `app/src/main/jniLibs`
6. Load mcl in the app prior usage with `System.loadLibrary("mcljava")`, e.g. in `MainActivity.onCreate`.
7. Add the dependency `implementation 'org.cryptimeleon:mclwrap:3.0.0'` to the app's build.gradle