-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabio Tacke
authored
Apr 3, 2020
1 parent
07b7031
commit b2aab8c
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# AndroidDoubleRatchet | ||
|
||
Implementation of the <a href="https://www.signal.org/docs/specifications/doubleratchet/#external-functions">Double Ratchet</a> protocol in Kotlin for Android. The cryptographic operations are provided by <a href="https://github.com/terl/lazysodium-android.git">Lazysodium</a> 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! | ||
``` |