@waku/message-encryption 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -1,42 +1,22 @@
1
- import * as secp from "@noble/secp256k1";
2
- import { concat, hexToBytes } from "@waku/byte-utils";
3
1
  import {
4
- DecoderV0,
5
- MessageV0,
2
+ DecodedMessage as DecodedMessageV0,
6
3
  proto,
7
- } from "@waku/core/lib/waku_message/version_0";
8
- import type {
9
- DecodedMessage,
10
- Decoder,
11
- Encoder,
12
- Message,
13
- ProtoMessage,
14
- } from "@waku/interfaces";
15
- import debug from "debug";
4
+ } from "@waku/core/lib/message/version_0";
5
+ import type { IDecodedMessage } from "@waku/interfaces";
16
6
 
17
- import { Symmetric } from "./constants.js";
18
7
  import {
19
8
  generatePrivateKey,
20
9
  generateSymmetricKey,
21
10
  getPublicKey,
22
- keccak256,
23
- randomBytes,
24
- sign,
25
- } from "./crypto.js";
26
- import * as ecies from "./ecies.js";
27
- import * as symmetric from "./symmetric.js";
11
+ } from "./crypto/index.js";
28
12
 
29
- const log = debug("waku:message:version-1");
30
-
31
- const FlagsLength = 1;
32
- const FlagMask = 3; // 0011
33
- const IsSignedMask = 4; // 0100
34
- const PaddingTarget = 256;
35
- const SignatureLength = 65;
36
- const OneMillion = BigInt(1_000_000);
13
+ export const OneMillion = BigInt(1_000_000);
37
14
 
38
15
  export { generatePrivateKey, generateSymmetricKey, getPublicKey };
39
16
 
17
+ export * as ecies from "./ecies.js";
18
+ export * as symmetric from "./symmetric.js";
19
+
40
20
  export const Version = 1;
41
21
 
42
22
  export type Signature = {
@@ -44,7 +24,10 @@ export type Signature = {
44
24
  publicKey: Uint8Array | undefined;
45
25
  };
46
26
 
47
- export class MessageV1 extends MessageV0 implements DecodedMessage {
27
+ export class DecodedMessage
28
+ extends DecodedMessageV0
29
+ implements IDecodedMessage
30
+ {
48
31
  private readonly _decodedPayload: Uint8Array;
49
32
 
50
33
  constructor(
@@ -61,418 +44,3 @@ export class MessageV1 extends MessageV0 implements DecodedMessage {
61
44
  return this._decodedPayload;
62
45
  }
63
46
  }
64
-
65
- export class AsymEncoder implements Encoder {
66
- constructor(
67
- public contentTopic: string,
68
- private publicKey: Uint8Array,
69
- private sigPrivKey?: Uint8Array,
70
- public ephemeral: boolean = false
71
- ) {}
72
-
73
- async toWire(message: Partial<Message>): Promise<Uint8Array | undefined> {
74
- const protoMessage = await this.toProtoObj(message);
75
- if (!protoMessage) return;
76
-
77
- return proto.WakuMessage.encode(protoMessage);
78
- }
79
-
80
- async toProtoObj(
81
- message: Partial<Message>
82
- ): Promise<ProtoMessage | undefined> {
83
- const timestamp = message.timestamp ?? new Date();
84
- if (!message.payload) {
85
- log("No payload to encrypt, skipping: ", message);
86
- return;
87
- }
88
- const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
89
-
90
- const payload = await encryptAsymmetric(preparedPayload, this.publicKey);
91
-
92
- return {
93
- payload,
94
- version: Version,
95
- contentTopic: this.contentTopic,
96
- timestamp: BigInt(timestamp.valueOf()) * OneMillion,
97
- rateLimitProof: message.rateLimitProof,
98
- ephemeral: this.ephemeral,
99
- };
100
- }
101
- }
102
-
103
- export class SymEncoder implements Encoder {
104
- constructor(
105
- public contentTopic: string,
106
- private symKey: Uint8Array,
107
- private sigPrivKey?: Uint8Array,
108
- public ephemeral: boolean = false
109
- ) {}
110
-
111
- async toWire(message: Partial<Message>): Promise<Uint8Array | undefined> {
112
- const protoMessage = await this.toProtoObj(message);
113
- if (!protoMessage) return;
114
-
115
- return proto.WakuMessage.encode(protoMessage);
116
- }
117
-
118
- async toProtoObj(
119
- message: Partial<Message>
120
- ): Promise<ProtoMessage | undefined> {
121
- const timestamp = message.timestamp ?? new Date();
122
- if (!message.payload) {
123
- log("No payload to encrypt, skipping: ", message);
124
- return;
125
- }
126
- const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
127
-
128
- const payload = await encryptSymmetric(preparedPayload, this.symKey);
129
- return {
130
- payload,
131
- version: Version,
132
- contentTopic: this.contentTopic,
133
- timestamp: BigInt(timestamp.valueOf()) * OneMillion,
134
- rateLimitProof: message.rateLimitProof,
135
- ephemeral: this.ephemeral,
136
- };
137
- }
138
- }
139
-
140
- export class AsymDecoder extends DecoderV0 implements Decoder<MessageV1> {
141
- constructor(contentTopic: string, private privateKey: Uint8Array) {
142
- super(contentTopic);
143
- }
144
-
145
- async fromProtoObj(
146
- protoMessage: ProtoMessage
147
- ): Promise<MessageV1 | undefined> {
148
- const cipherPayload = protoMessage.payload;
149
-
150
- if (protoMessage.version !== Version) {
151
- log(
152
- "Failed to decrypt due to incorrect version, expected:",
153
- Version,
154
- ", actual:",
155
- protoMessage.version
156
- );
157
- return;
158
- }
159
-
160
- let payload;
161
- if (!cipherPayload) {
162
- log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
163
- return;
164
- }
165
-
166
- try {
167
- payload = await decryptAsymmetric(cipherPayload, this.privateKey);
168
- } catch (e) {
169
- log(
170
- `Failed to decrypt message using asymmetric decryption for contentTopic: ${this.contentTopic}`,
171
- e
172
- );
173
- return;
174
- }
175
-
176
- if (!payload) {
177
- log(`Failed to decrypt payload for contentTopic ${this.contentTopic}`);
178
- return;
179
- }
180
-
181
- const res = await postCipher(payload);
182
-
183
- if (!res) {
184
- log(`Failed to decode payload for contentTopic ${this.contentTopic}`);
185
- return;
186
- }
187
-
188
- log("Message decrypted", protoMessage);
189
- return new MessageV1(
190
- protoMessage,
191
- res.payload,
192
- res.sig?.signature,
193
- res.sig?.publicKey
194
- );
195
- }
196
- }
197
-
198
- export class SymDecoder extends DecoderV0 implements Decoder<MessageV1> {
199
- constructor(contentTopic: string, private symKey: Uint8Array) {
200
- super(contentTopic);
201
- }
202
-
203
- async fromProtoObj(
204
- protoMessage: ProtoMessage
205
- ): Promise<MessageV1 | undefined> {
206
- const cipherPayload = protoMessage.payload;
207
-
208
- if (protoMessage.version !== Version) {
209
- log(
210
- "Failed to decrypt due to incorrect version, expected:",
211
- Version,
212
- ", actual:",
213
- protoMessage.version
214
- );
215
- return;
216
- }
217
-
218
- let payload;
219
- if (!cipherPayload) {
220
- log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
221
- return;
222
- }
223
-
224
- try {
225
- payload = await decryptSymmetric(cipherPayload, this.symKey);
226
- } catch (e) {
227
- log(
228
- `Failed to decrypt message using asymmetric decryption for contentTopic: ${this.contentTopic}`,
229
- e
230
- );
231
- return;
232
- }
233
-
234
- if (!payload) {
235
- log(`Failed to decrypt payload for contentTopic ${this.contentTopic}`);
236
- return;
237
- }
238
-
239
- const res = await postCipher(payload);
240
-
241
- if (!res) {
242
- log(`Failed to decode payload for contentTopic ${this.contentTopic}`);
243
- return;
244
- }
245
-
246
- log("Message decrypted", protoMessage);
247
- return new MessageV1(
248
- protoMessage,
249
- res.payload,
250
- res.sig?.signature,
251
- res.sig?.publicKey
252
- );
253
- }
254
- }
255
-
256
- function getSizeOfPayloadSizeField(message: Uint8Array): number {
257
- const messageDataView = new DataView(message.buffer);
258
- return messageDataView.getUint8(0) & FlagMask;
259
- }
260
-
261
- function getPayloadSize(
262
- message: Uint8Array,
263
- sizeOfPayloadSizeField: number
264
- ): number {
265
- let payloadSizeBytes = message.slice(1, 1 + sizeOfPayloadSizeField);
266
- // int 32 == 4 bytes
267
- if (sizeOfPayloadSizeField < 4) {
268
- // If less than 4 bytes pad right (Little Endian).
269
- payloadSizeBytes = concat(
270
- [payloadSizeBytes, new Uint8Array(4 - sizeOfPayloadSizeField)],
271
- 4
272
- );
273
- }
274
- const payloadSizeDataView = new DataView(payloadSizeBytes.buffer);
275
- return payloadSizeDataView.getInt32(0, true);
276
- }
277
-
278
- function isMessageSigned(message: Uint8Array): boolean {
279
- const messageDataView = new DataView(message.buffer);
280
- return (messageDataView.getUint8(0) & IsSignedMask) == IsSignedMask;
281
- }
282
-
283
- /**
284
- * Proceed with Asymmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
285
- * The data MUST be flags | payload-length | payload | [signature].
286
- * The returned result can be set to `WakuMessage.payload`.
287
- *
288
- * @internal
289
- */
290
- export async function encryptAsymmetric(
291
- data: Uint8Array,
292
- publicKey: Uint8Array | string
293
- ): Promise<Uint8Array> {
294
- return ecies.encrypt(hexToBytes(publicKey), data);
295
- }
296
-
297
- /**
298
- * Proceed with Asymmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
299
- * The returned data is expected to be `flags | payload-length | payload | [signature]`.
300
- *
301
- * @internal
302
- */
303
- export async function decryptAsymmetric(
304
- payload: Uint8Array,
305
- privKey: Uint8Array
306
- ): Promise<Uint8Array> {
307
- return ecies.decrypt(privKey, payload);
308
- }
309
-
310
- /**
311
- * Proceed with Symmetric encryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
312
- *
313
- * @param data The data to encrypt, expected to be `flags | payload-length | payload | [signature]`.
314
- * @param key The key to use for encryption.
315
- * @returns The decrypted data, `cipherText | tag | iv` and can be set to `WakuMessage.payload`.
316
- *
317
- * @internal
318
- */
319
- export async function encryptSymmetric(
320
- data: Uint8Array,
321
- key: Uint8Array | string
322
- ): Promise<Uint8Array> {
323
- const iv = symmetric.generateIv();
324
-
325
- // Returns `cipher | tag`
326
- const cipher = await symmetric.encrypt(iv, hexToBytes(key), data);
327
- return concat([cipher, iv]);
328
- }
329
-
330
- /**
331
- * Proceed with Symmetric decryption of the data as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
332
- *
333
- * @param payload The cipher data, it is expected to be `cipherText | tag | iv`.
334
- * @param key The key to use for decryption.
335
- * @returns The decrypted data, expected to be `flags | payload-length | payload | [signature]`.
336
- *
337
- * @internal
338
- */
339
- export async function decryptSymmetric(
340
- payload: Uint8Array,
341
- key: Uint8Array | string
342
- ): Promise<Uint8Array> {
343
- const ivStart = payload.length - Symmetric.ivSize;
344
- const cipher = payload.slice(0, ivStart);
345
- const iv = payload.slice(ivStart);
346
-
347
- return symmetric.decrypt(iv, hexToBytes(key), cipher);
348
- }
349
-
350
- /**
351
- * Computes the flags & auxiliary-field as per [26/WAKU-PAYLOAD](https://rfc.vac.dev/spec/26/).
352
- */
353
- function addPayloadSizeField(msg: Uint8Array, payload: Uint8Array): Uint8Array {
354
- const fieldSize = computeSizeOfPayloadSizeField(payload);
355
- let field = new Uint8Array(4);
356
- const fieldDataView = new DataView(field.buffer);
357
- fieldDataView.setUint32(0, payload.length, true);
358
- field = field.slice(0, fieldSize);
359
- msg = concat([msg, field]);
360
- msg[0] |= fieldSize;
361
- return msg;
362
- }
363
-
364
- /**
365
- * Returns the size of the auxiliary-field which in turns contains the payload size
366
- */
367
- function computeSizeOfPayloadSizeField(payload: Uint8Array): number {
368
- let s = 1;
369
- for (let i = payload.length; i >= 256; i /= 256) {
370
- s++;
371
- }
372
- return s;
373
- }
374
-
375
- function validateDataIntegrity(
376
- value: Uint8Array,
377
- expectedSize: number
378
- ): boolean {
379
- if (value.length !== expectedSize) {
380
- return false;
381
- }
382
-
383
- return expectedSize <= 3 || value.findIndex((i) => i !== 0) !== -1;
384
- }
385
-
386
- function getSignature(message: Uint8Array): Uint8Array {
387
- return message.slice(message.length - SignatureLength, message.length);
388
- }
389
-
390
- function getHash(message: Uint8Array, isSigned: boolean): Uint8Array {
391
- if (isSigned) {
392
- return keccak256(message.slice(0, message.length - SignatureLength));
393
- }
394
- return keccak256(message);
395
- }
396
-
397
- function ecRecoverPubKey(
398
- messageHash: Uint8Array,
399
- signature: Uint8Array
400
- ): Uint8Array | undefined {
401
- const recoveryDataView = new DataView(signature.slice(64).buffer);
402
- const recovery = recoveryDataView.getUint8(0);
403
- const _signature = secp.Signature.fromCompact(signature.slice(0, 64));
404
-
405
- return secp.recoverPublicKey(messageHash, _signature, recovery, false);
406
- }
407
-
408
- /**
409
- * Prepare the payload pre-encryption.
410
- *
411
- * @internal
412
- * @returns The encoded payload, ready for encryption using {@link encryptAsymmetric}
413
- * or {@link encryptSymmetric}.
414
- */
415
- export async function preCipher(
416
- messagePayload: Uint8Array,
417
- sigPrivKey?: Uint8Array
418
- ): Promise<Uint8Array> {
419
- let envelope = new Uint8Array([0]); // No flags
420
- envelope = addPayloadSizeField(envelope, messagePayload);
421
- envelope = concat([envelope, messagePayload]);
422
-
423
- // Calculate padding:
424
- let rawSize =
425
- FlagsLength +
426
- computeSizeOfPayloadSizeField(messagePayload) +
427
- messagePayload.length;
428
-
429
- if (sigPrivKey) {
430
- rawSize += SignatureLength;
431
- }
432
-
433
- const remainder = rawSize % PaddingTarget;
434
- const paddingSize = PaddingTarget - remainder;
435
- const pad = randomBytes(paddingSize);
436
-
437
- if (!validateDataIntegrity(pad, paddingSize)) {
438
- throw new Error("failed to generate random padding of size " + paddingSize);
439
- }
440
-
441
- envelope = concat([envelope, pad]);
442
- if (sigPrivKey) {
443
- envelope[0] |= IsSignedMask;
444
- const hash = keccak256(envelope);
445
- const bytesSignature = await sign(hash, sigPrivKey);
446
- envelope = concat([envelope, bytesSignature]);
447
- }
448
-
449
- return envelope;
450
- }
451
-
452
- /**
453
- * Decode a decrypted payload.
454
- *
455
- * @internal
456
- */
457
- export function postCipher(
458
- message: Uint8Array
459
- ): { payload: Uint8Array; sig?: Signature } | undefined {
460
- const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message);
461
- if (sizeOfPayloadSizeField === 0) return;
462
-
463
- const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField);
464
- const payloadStart = 1 + sizeOfPayloadSizeField;
465
- const payload = message.slice(payloadStart, payloadStart + payloadSize);
466
-
467
- const isSigned = isMessageSigned(message);
468
-
469
- let sig;
470
- if (isSigned) {
471
- const signature = getSignature(message);
472
- const hash = getHash(message, isSigned);
473
- const publicKey = ecRecoverPubKey(hash, signature);
474
- sig = { signature, publicKey };
475
- }
476
-
477
- return { payload, sig };
478
- }
package/src/symmetric.ts CHANGED
@@ -1,32 +1,166 @@
1
- import { Symmetric } from "./constants.js";
2
- import { getSubtle, randomBytes } from "./crypto.js";
3
-
4
- export async function encrypt(
5
- iv: Uint8Array,
6
- key: Uint8Array,
7
- clearText: Uint8Array
8
- ): Promise<Uint8Array> {
9
- return getSubtle()
10
- .importKey("raw", key, Symmetric.algorithm, false, ["encrypt"])
11
- .then((cryptoKey) =>
12
- getSubtle().encrypt({ iv, ...Symmetric.algorithm }, cryptoKey, clearText)
13
- )
14
- .then((cipher) => new Uint8Array(cipher));
1
+ import { Decoder as DecoderV0, proto } from "@waku/core/lib/message/version_0";
2
+ import type {
3
+ IDecoder,
4
+ IEncoder,
5
+ IMessage,
6
+ IProtoMessage,
7
+ } from "@waku/interfaces";
8
+ import debug from "debug";
9
+
10
+ import {
11
+ decryptSymmetric,
12
+ encryptSymmetric,
13
+ postCipher,
14
+ preCipher,
15
+ } from "./waku_payload.js";
16
+
17
+ import {
18
+ DecodedMessage,
19
+ generateSymmetricKey,
20
+ OneMillion,
21
+ Version,
22
+ } from "./index.js";
23
+
24
+ export { DecodedMessage, generateSymmetricKey };
25
+
26
+ const log = debug("waku:message-encryption:symmetric");
27
+
28
+ class Encoder implements IEncoder {
29
+ constructor(
30
+ public contentTopic: string,
31
+ private symKey: Uint8Array,
32
+ private sigPrivKey?: Uint8Array,
33
+ public ephemeral: boolean = false
34
+ ) {}
35
+
36
+ async toWire(message: IMessage): Promise<Uint8Array | undefined> {
37
+ const protoMessage = await this.toProtoObj(message);
38
+ if (!protoMessage) return;
39
+
40
+ return proto.WakuMessage.encode(protoMessage);
41
+ }
42
+
43
+ async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
44
+ const timestamp = message.timestamp ?? new Date();
45
+ if (!message.payload) {
46
+ log("No payload to encrypt, skipping: ", message);
47
+ return;
48
+ }
49
+ const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
50
+
51
+ const payload = await encryptSymmetric(preparedPayload, this.symKey);
52
+ return {
53
+ payload,
54
+ version: Version,
55
+ contentTopic: this.contentTopic,
56
+ timestamp: BigInt(timestamp.valueOf()) * OneMillion,
57
+ rateLimitProof: message.rateLimitProof,
58
+ ephemeral: this.ephemeral,
59
+ };
60
+ }
15
61
  }
16
62
 
17
- export async function decrypt(
18
- iv: Uint8Array,
19
- key: Uint8Array,
20
- cipherText: Uint8Array
21
- ): Promise<Uint8Array> {
22
- return getSubtle()
23
- .importKey("raw", key, Symmetric.algorithm, false, ["decrypt"])
24
- .then((cryptoKey) =>
25
- getSubtle().decrypt({ iv, ...Symmetric.algorithm }, cryptoKey, cipherText)
26
- )
27
- .then((clear) => new Uint8Array(clear));
63
+ /**
64
+ * Creates an encoder that encrypts messages using symmetric encryption for the
65
+ * given key, as defined in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
66
+ *
67
+ * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
68
+ * format to be sent over the Waku network. The resulting encoder can then be
69
+ * pass to { @link @waku/interfaces.LightPush.push } or
70
+ * { @link @waku/interfaces.Relay.send } to automatically encrypt
71
+ * and encode outgoing messages.
72
+ *
73
+ * The payload can optionally be signed with the given private key as defined
74
+ * in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
75
+ *
76
+ * @param contentTopic The content topic to set on outgoing messages.
77
+ * @param symKey The symmetric key to encrypt the payload with.
78
+ * @param sigPrivKey An optional private key to used to sign the payload before encryption.
79
+ * @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
80
+ */
81
+ export function createEncoder(
82
+ contentTopic: string,
83
+ symKey: Uint8Array,
84
+ sigPrivKey?: Uint8Array,
85
+ ephemeral = false
86
+ ): Encoder {
87
+ return new Encoder(contentTopic, symKey, sigPrivKey, ephemeral);
88
+ }
89
+
90
+ class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
91
+ constructor(contentTopic: string, private symKey: Uint8Array) {
92
+ super(contentTopic);
93
+ }
94
+
95
+ async fromProtoObj(
96
+ protoMessage: IProtoMessage
97
+ ): Promise<DecodedMessage | undefined> {
98
+ const cipherPayload = protoMessage.payload;
99
+
100
+ if (protoMessage.version !== Version) {
101
+ log(
102
+ "Failed to decrypt due to incorrect version, expected:",
103
+ Version,
104
+ ", actual:",
105
+ protoMessage.version
106
+ );
107
+ return;
108
+ }
109
+
110
+ let payload;
111
+ if (!cipherPayload) {
112
+ log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
113
+ return;
114
+ }
115
+
116
+ try {
117
+ payload = await decryptSymmetric(cipherPayload, this.symKey);
118
+ } catch (e) {
119
+ log(
120
+ `Failed to decrypt message using asymmetric decryption for contentTopic: ${this.contentTopic}`,
121
+ e
122
+ );
123
+ return;
124
+ }
125
+
126
+ if (!payload) {
127
+ log(`Failed to decrypt payload for contentTopic ${this.contentTopic}`);
128
+ return;
129
+ }
130
+
131
+ const res = await postCipher(payload);
132
+
133
+ if (!res) {
134
+ log(`Failed to decode payload for contentTopic ${this.contentTopic}`);
135
+ return;
136
+ }
137
+
138
+ log("Message decrypted", protoMessage);
139
+ return new DecodedMessage(
140
+ protoMessage,
141
+ res.payload,
142
+ res.sig?.signature,
143
+ res.sig?.publicKey
144
+ );
145
+ }
28
146
  }
29
147
 
30
- export function generateIv(): Uint8Array {
31
- return randomBytes(Symmetric.ivSize);
148
+ /**
149
+ * Creates a decoder that decrypts messages using symmetric encryption, using
150
+ * the given key as defined in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
151
+ *
152
+ * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
153
+ * format when received from the Waku network. The resulting decoder can then be
154
+ * pass to { @link @waku/interfaces.Filter.subscribe } or
155
+ * { @link @waku/interfaces.Relay.subscribe } to automatically decrypt and
156
+ * decode incoming messages.
157
+ *
158
+ * @param contentTopic The resulting decoder will only decode messages with this content topic.
159
+ * @param symKey The symmetric key used to decrypt the message.
160
+ */
161
+ export function createDecoder(
162
+ contentTopic: string,
163
+ symKey: Uint8Array
164
+ ): Decoder {
165
+ return new Decoder(contentTopic, symKey);
32
166
  }