Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@adiwajshing/baileys/WASignalGroup/sender_message_key.js
1126 views
1
const { deriveSecrets } = require('libsignal/src/crypto');
2
class SenderMessageKey {
3
iteration = 0;
4
5
iv = Buffer.alloc(0);
6
7
cipherKey = Buffer.alloc(0);
8
9
seed = Buffer.alloc(0);
10
11
constructor(iteration, seed) {
12
const derivative = deriveSecrets(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'));
13
const keys = new Uint8Array(32);
14
keys.set(new Uint8Array(derivative[0].slice(16)));
15
keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16);
16
this.iv = Buffer.from(derivative[0].slice(0, 16));
17
this.cipherKey = Buffer.from(keys.buffer);
18
19
this.iteration = iteration;
20
this.seed = seed;
21
}
22
23
getIteration() {
24
return this.iteration;
25
}
26
27
getIv() {
28
return this.iv;
29
}
30
31
getCipherKey() {
32
return this.cipherKey;
33
}
34
35
getSeed() {
36
return this.seed;
37
}
38
}
39
module.exports = SenderMessageKey;
40