Monday, August 13, 2018

Starting the Hyperledger Indy test pool reachable on your WIFI network






Hyperledger Indy's README.md explains how to start the @Sovrin test pool on localhost using docker and in a docker network.


Doing it this way the pool is not reachable from clients that are not on your local machine.
Building a mobile app then has the problem that the phone can't talk to the test pool because neither localhost nor the private docker network are reachable.

Starting the test pool on a specific IP address

Dockerfile ci/indy-pool.dockerfile supports an optional pool_ip param that allows changing the IP address of the pool nodes in the generated pool configuration.

You can start the pool with e.g. the IP address of your development machine's WIFI interface so that mobile apps in the same network can reach the pool.

# replace 192.168.179.90 with your wifi IP address
docker build --build-arg pool_ip=192.168.179.90 -f ci/indy-pool.dockerfile -t indy_pool .
docker run -itd -p 192.168.179.90:9701-9708:9701-9708 indy_pool
 
To connect to the pool the IP addresses in /var/lib/indy/sandbox/pool_transactions_genesis (in docker) and the pool configuration you use in your mobile app must match.

Here is some Java code that creates a pool configuration. Be sure to put your IP address in there when you open the pool connection.

-------

Please contribute to Indy. Even if your company does not allow you to publish code please consider helping by improving the documentation.
Please sign-off your commits. git commit -s -m 'my first commit' README.md

Monday, August 06, 2018

Building an Android App with Sovrin





Thanks to the hard work of Mohammad Abdul Sami Sovrin enthusiasts now have support building libindy for Android in the master branch of our repo.


You can now build the libindy libraries for Android by just running a script. Yeah!
If you want to spare that building process you can download the libraries from Evernym. Thanks!

Now what? You have a libindy.so for arm, arm64 and x86, but how do you use it?

I have created an Android Studio sample application DroidLibIndy that you might use as a starting point (if you don't like reading blog posts).

Still reading? Here is a list of quirks you need in your flashy new Indy-App.

  1. First you have to put the libindy library into the correct jni folder e.g.:
    app/src/main/jniLibs/arm64-v8a
    This other way to do this did not work for me.
  2. Source code and Target compatibility have to be Java 1.8
    Otherwise CompletableFuture and other stuff do not compile
  3. You need a network security policy because libindy secures its communication using zeromq and Android only accepts HTTPS as a secure protocol.
  4. You might need a lint.xml to get JNA linked.
  5. Copy libindy's Java wrapper code to your project using the path org/hyperledger/indy/sdk.
    cp -r ~pathto/indy-sdk/wrappers/java/src/main/java/org/ pathtoyourapp/app/src/main/java/
    I did not try the maven route here.
  6. In your app's onCreate method set the environment variable 'EXTERNAL_STORAGE'
  7. Of course you need to have all the dependencies configured in your build system.
As always: PRs are welcome! Please contribute to libindy. It's easy.

Have fun exploring Hyperledger Indy on Android!





Wednesday, April 25, 2018

Building openssl for libindy and Android

Building of the indy-sdk for Android is currently not supported out of the box. The underlying issue is that libindy is implemented in Rust and the Android platform is currently not supported.

To build openssl for Android on your Ubuntu system take the following steps:
  1. Setup your build environment - missing tools are likely to be noticed by "configure" so you can install them then 
  2. Download openssl (I used version 1.0.2n) and unpack it.
  3. Setup the Android toolchain (command line tools are enough) and NDK toolchain for e.g. arm
    ${NDK_HOME}/build/tools/make_standalone_toolchain.py  --api 14 --arch arm  --install-dir ${NDK_TOOLCHAIN_DIR}/arm --stl=libc++
    or for arm64
    ${NDK_HOME}/build/tools/make_standalone_toolchain.py  --api 21 --arch arm64  --install-dir ${NDK_TOOLCHAIN_DIR}/arm64 --stl=libc++
  4. Edit the script setenv-android.sh

    I have these values:
    _ANDROID_NDK="android-ndk-r16"
    _ANDROID_EABI="arm-linux-androideabi-4.9"
    _ANDROID_ARCH=arch-arm
    _ANDROID_API="android-14"
  5. Run the script '. setenv-android.sh'
  6. run this:
    ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine      --openssldir=/usr/local/ssl/arm/$ANDROID_API --prefix=/usr/local/ssl/arm/$ANDROID_API
  7. Edit Makefile and add
    "--sysroot=/home/ignisvulpis/NDK_TOOLCHAIN_DIR/arm/sysroot/"
    to CFLAG and DEPFLAG
    Remove -mandroid where it occurs
  8. Run make. This creates the libraries in the current directory
    make build_libs
  9. Make install fails because the application openssl is not build for Android.
    So put a comment # in front of the install command.
    "#@set -e; target=install; $(RECURSIVE_BUILD_CMD)" in the target "install_sw". "make install" now installs the include files and the libs.
The include files are needed to compile libindy. The libraries need to be put into a place where the Rust build system can find them.