Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ticesoftware/double-ratchet.js
Implementation of the Double Ratchet protocol in TypeScript based on libsodium.
https://github.com/ticesoftware/double-ratchet.js
hacktoberfest tice-app tice-crypto
Last synced: about 1 month ago
JSON representation
Implementation of the Double Ratchet protocol in TypeScript based on libsodium.
- Host: GitHub
- URL: https://github.com/ticesoftware/double-ratchet.js
- Owner: TICESoftware
- License: mit
- Created: 2019-11-03T20:54:12.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-10-25T11:32:40.000Z (about 2 years ago)
- Last Synced: 2024-11-09T08:49:29.237Z (about 1 month ago)
- Topics: hacktoberfest, tice-app, tice-crypto
- Language: TypeScript
- Homepage:
- Size: 319 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# double-ratchet.js
Implementation of the [Double Ratchet](https://www.signal.org/docs/specifications/doubleratchet/#external-functions) protocol in TypeScript. The cryptographic operations are provided by [libsodium](https://github.com/jedisct1/libsodium) entirely.
## Installation
```bash
$ yarn add double-ratchet-ts
or
$ npm i --save double-ratchet-ts
```## 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.
```typescript
import {DoubleRatchet} from "double-ratchet-ts";const sharedSecret = new Uint8Array(32).fill(1);
const info = "DoubleRatchetExample";const bob = await DoubleRatchet.init(info, 20, 20, sharedSecret, undefined, undefined);
// Bob sends his public key to Alice using another channel
// sendToAlice(bob.publicKey())const alice = await DoubleRatchet.init(info, 20, 20, sharedSecret, bob.publicKey(), undefined);
// Now the conversation begins
const message = Uint8Array.from(Array.from("Hello, Bob!").map(letter => letter.charCodeAt(0)));const encryptedMessage = await alice.encrypt(message);
const decryptedMessage = await bob.decrypt(encryptedMessage);console.log(String.fromCharCode(...decryptedMessage)); // Hello, Bob!
```## License
This library is licensed under [MIT license](LICENSE).