From b2aab8c94f201145ad7bd3fbda00fe1991a3b69c Mon Sep 17 00:00:00 2001 From: Fabio Tacke Date: Fri, 3 Apr 2020 14:33:41 +0200 Subject: [PATCH] Create README --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0b3c369 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# AndroidDoubleRatchet + +Implementation of the Double Ratchet protocol in Kotlin for Android. The cryptographic operations are provided by Lazysodium entirely. + +## Installation + +### Jitpack +To integrate the library via jitpack add the jitpack repository to your root `build.gradle` file: + +``` +allprojects { + repositories { + ... + maven { url "https://dl.bintray.com/terl/lazysodium-maven" } + maven { url 'https://jitpack.io' } + } +} +``` + +You can then add the dependency to your app's `build.gradle` file where `$VERSION` specifies the specific version of the library: + +``` +dependencies { + implementation 'com.github.TICESoftware:AndroidDoubleRatchet:$VERSION' + implementation "com.goterl.lazycode:lazysodium-android:4.1.0@aar" + implementation 'net.java.dev.jna:jna:5.5.0@aar' +} + ``` + + +## Usage + +Alice and Bob calculate a shared secret using a secure channel. After that one party can start the conversation as soon as she gets to know the public key of the other one. + +```kotlin +import com.ticeapp.androiddoubleratchet.DoubleRatchet + +val sharedSecret: ByteArray = ... +val info = "DoubleRatchetExample" + +val bob = DoubleRatchet(keyPair = null, remotePublicKey = null, sharedSecret = sharedSecret, maxSkip = 20, maxCache = 20, info = info) + +// Bob sends his public key to Alice using another channel +// sendToAlice(bob.publicKey) + +val alice = DoubleRatchet(keyPair = null, remotePublicKey = bob.publicKey, sharedSecret = sharedSecret, maxSkip = 20, maxCache = 20, info = info) + +// Now the conversation begins +val message = "Hello, Bob!".encodeToByteArray() +val encryptedMessage = alice.encrypt(message) +val decryptedMessage = bob.decrypt(encryptedMessage) + +println(decryptedMessage.decodeToString()) // Hello, Bob! +```