Skip to content

Commit 218fbc4

Browse files
committed
sending lists of minichunks but it's not great
1 parent a6443b5 commit 218fbc4

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ now you can edit js files in src/ and test/ - tests will automatically re-run
1111

1212
## TODO
1313

14+
- [ ] what/why is the limit on size of plaintext? is it my format?
1415
- [ ] why do i keep getting new remote ephemeral keys?
1516
- [ ] pad / unpad plaintext / ciphertext?

src/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
let signal = require('signal-protocol')
22
let through = require('through2')
3-
let l = require('./helpers')
3+
// let l = require('./helpers')
44
// var textsecure = require('signal-protocol/test/temp_helpers')
55
const PREKEY_BUNDLE_CODE = 3 //textsecure.protobuf.IncomingPushMessageSignal.Type.PREKEY_BUNDLE
6-
76
let pushPromise = (p, next) => p.then(x => next(null, x), next)
8-
let streamF = f => through.obj(function (buf, enc, next) { pushPromise(f(buf), next) })
9-
let duplexify = require('duplexify')
7+
let streamF = f => through.obj((buf, enc, next) => pushPromise(f(buf), next))
108

119
function encryptor (cipher) {
1210
return function (plaintext) {
13-
return cipher.encrypt(plaintext)
11+
return Promise.all([
12+
cipher.encrypt(plaintext.slice(0, 200)),
13+
cipher.encrypt(plaintext.slice(201, 400)),
14+
])
1415
}
1516
}
1617

1718
function decryptor (cipher) {
1819
// returns a promise of plaintext
19-
return function (ciphertext) {
20+
function dec (ciphertext) {
2021
// console.log('ciphertext to decrypt is', ciphertext)
2122
if (ciphertext.type == PREKEY_BUNDLE_CODE)
2223
return cipher.decryptPreKeyWhisperMessage(ciphertext.body, 'binary')
2324
return cipher.decryptWhisperMessage(ciphertext.body, 'binary')
2425
}
26+
return function (ctxts) {
27+
return Promise.all(ctxts.map(dec))
28+
}
2529
}
2630

2731
module.exports = function (cipher) {

test/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ function echo ([aliceCipher, bobCipher]) {
4949
read(__dirname + '/story.txt', 'utf-8')
5050
.pipe(alice.encrypt)
5151
.pipe(bob.decrypt)
52-
.pipe(bob.encrypt)
53-
.pipe(alice.decrypt)
54-
.on('data', d => {
52+
// .pipe(bob.encrypt)
53+
// .pipe(alice.decrypt)
54+
.on('data', ds => ds.map(d => {
5555
let pt = new Buffer.from(d).toString('utf-8')
56-
console.log(pt)
57-
})
56+
console.log('SEE', d, pt)
57+
}))
5858
.on('error', err => console.log('err', err))
5959
}

0 commit comments

Comments
 (0)