https://github.com/ticesoftware/androiddoubleratchet
https://github.com/ticesoftware/androiddoubleratchet
kotlin tice-app tice-crypto
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ticesoftware/androiddoubleratchet
- Owner: TICESoftware
- License: mit
- Created: 2020-04-02T11:57:17.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-08-24T11:56:06.000Z (almost 3 years ago)
- Last Synced: 2025-01-16T00:24:14.629Z (over 1 year ago)
- Topics: kotlin, tice-app, tice-crypto
- Language: Kotlin
- Homepage:
- Size: 198 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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: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!
```