Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

2key-ratchet

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

2key-ratchet - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

3

package.json
{
"name": "2key-ratchet",
"version": "1.0.1",
"version": "1.0.2",
"description": "2key-ratchet is an implementation of a Double Ratchet protocol and X3DH in TypeScript utilizing WebCrypto.",

@@ -58,2 +58,3 @@ "main": "dist/2key-ratchet.js",

"rollup-plugin-typescript": "^0.8.1",
"tslint": "^5.3.2",
"typescript": "^2.3.3",

@@ -60,0 +61,0 @@ "watch": "^1.0.2"

@@ -89,3 +89,3 @@ # 2key-ratchet

let AliceID;
DKeyRatchet.Identity.create(16453);
DKeyRatchet.Identity.create(16453, 1, 1)
.then((id) => {

@@ -96,12 +96,2 @@ AliceID = id;

#### Generate and sign your PreKeys
You will also need to create your signed PreKeys:
```javascript
DKeyRatchet.PreKey.create(1)
.then((preKey) => {
AliceID.signedPreKeys.save(preKey.id.toString(), preKey);
});
```
Then create your PreKey message bundle:

@@ -115,12 +105,12 @@

bundle.registrationId = AliceID.id;
const preKey = AliceID.signedPreKeys.load("1");
const preKey = AliceID.signedPreKeys[0];
bundle.preKeySigned.id = 1;
bundle.preKeySigned.key = preKey.key.publicKey;
bundle.preKeySigned.key = preKey.publicKey;
return bundle.preKeySigned.sign(AliceID.signingKey.privateKey);
})
.then(() => {
return bundle.exportProtocol();
return bundle.exportProto();
})
.then((ab) => {
console.log(ab); // ArrayBuffer {byteLength: 348}
console.log(ab); // ArrayBuffer { byteLength: 374 }
});

@@ -132,6 +122,6 @@ ```

```javascript
DKeyRatchet.PreKeyBundleProtocol.importProtocol(ab)
DKeyRatchet.PreKeyBundleProtocol.importProto(ab)
.then((bundle) => {
// check signed prekey
return bundle.preKeySigned.verify(AliceID.signingKey.public);
return bundle.preKeySigned.verify(AliceID.signingKey.publicKey);
})

@@ -147,12 +137,14 @@ .then((trusted) => {

> NOTE: For data conversion was used module `pvtsutils`.
```javascript
DKeyRatchet.AsymmetricRatchet.create(BobID, bundle)
.then((cipher) => {
return cipher.encrypt(DKeyRatchet.Convert.FromUtf8String("Hello world!"));
return cipher.encrypt(Convert.FromUtf8String("Hello world!"));
})
.then((preKeyMessage) => {
return preKeyMessage.exportProtocol();
return preKeyMessage.exportProto();
})
.then((ab) => {
console.log(ab); // ArrayBuffer {byteLength: 408}
.then((BobMessage) => {
console.log(BobMessage); // ArrayBuffer {byteLength: 408}
});

@@ -164,9 +156,13 @@ ```

```javascript
DKeyRatchet.AsymmetricRatchet.create(AliceID, preKeyMessage)
.then((cipher) => {
return cipher.decrypt(preKeyMessage.signedMessage);
})
.then((message) => {
console.log(DKeyRatchet.Convert.ToUtf8String(message)); // Hello world!
})
// Parse received bytes to proto
return DKeyRatchet.PreKeyMessageProtocol.importProto(BobMessage)
.then((proto) => {
return DKeyRatchet.AsymmetricRatchet.create(AliceID, proto)
.then((cipher) => {
return cipher.decrypt(proto.signedMessage);
})
.then((message) => {
console.log(Convert.ToUtf8String(message)); // Hello world!
});
});
```

@@ -173,0 +169,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc