@voidly/agent-sdk 3.3.1 → 3.3.2
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/dist/index.js +49 -0
- package/dist/index.mjs +49 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4979,6 +4979,55 @@ var VoidlyAgent = class _VoidlyAgent {
|
|
|
4979
4979
|
rawPlaintext = import_tweetnacl.default.secretbox.open(ciphertext, nonce, messageKey);
|
|
4980
4980
|
}
|
|
4981
4981
|
}
|
|
4982
|
+
if (!rawPlaintext && envelopeDhRatchetKey && this.doubleRatchet && state) {
|
|
4983
|
+
try {
|
|
4984
|
+
const x25519Shared2 = import_tweetnacl.default.box.before(senderEncPub, this.encryptionKeyPair.secretKey);
|
|
4985
|
+
let initialKey2;
|
|
4986
|
+
if (envelopePqCiphertext && this.mlkemSecretKey) {
|
|
4987
|
+
try {
|
|
4988
|
+
const pqCt2 = (0, import_tweetnacl_util.decodeBase64)(envelopePqCiphertext);
|
|
4989
|
+
const kem2 = new MlKem768();
|
|
4990
|
+
const pqShared2 = await kem2.decap(pqCt2, this.mlkemSecretKey);
|
|
4991
|
+
const combined2 = new Uint8Array(x25519Shared2.length + pqShared2.length);
|
|
4992
|
+
combined2.set(x25519Shared2, 0);
|
|
4993
|
+
combined2.set(pqShared2, x25519Shared2.length);
|
|
4994
|
+
initialKey2 = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", combined2));
|
|
4995
|
+
} catch {
|
|
4996
|
+
initialKey2 = x25519Shared2;
|
|
4997
|
+
}
|
|
4998
|
+
} else {
|
|
4999
|
+
initialKey2 = x25519Shared2;
|
|
5000
|
+
}
|
|
5001
|
+
const senderDhPub2 = (0, import_tweetnacl_util.decodeBase64)(envelopeDhRatchetKey);
|
|
5002
|
+
const dhOutput2 = import_tweetnacl.default.box.before(senderDhPub2, this.encryptionKeyPair.secretKey);
|
|
5003
|
+
const { newRootKey: rk2, newChainKey: ck2 } = await kdfRK(initialKey2, dhOutput2);
|
|
5004
|
+
let freshCk = ck2;
|
|
5005
|
+
for (let fi = 1; fi < envelopeRatchetStep; fi++) {
|
|
5006
|
+
const { nextChainKey: nck } = await ratchetStep(freshCk);
|
|
5007
|
+
freshCk = nck;
|
|
5008
|
+
}
|
|
5009
|
+
const { nextChainKey: finalCk, messageKey: freshMk } = await ratchetStep(freshCk);
|
|
5010
|
+
const freshPlain = import_tweetnacl.default.secretbox.open(ciphertext, nonce, freshMk);
|
|
5011
|
+
if (freshPlain) {
|
|
5012
|
+
rawPlaintext = freshPlain;
|
|
5013
|
+
state.recvChainKey = finalCk;
|
|
5014
|
+
state.recvStep = envelopeRatchetStep;
|
|
5015
|
+
state.rootKey = rk2;
|
|
5016
|
+
state.dhRecvPubKey = senderDhPub2;
|
|
5017
|
+
state.prevSendStep = state.sendStep;
|
|
5018
|
+
state.dhSendKeyPair = import_tweetnacl.default.box.keyPair();
|
|
5019
|
+
state.sendStep = 0;
|
|
5020
|
+
state.sendChainKey = initialKey2;
|
|
5021
|
+
const dhOut3 = import_tweetnacl.default.box.before(senderDhPub2, state.dhSendKeyPair.secretKey);
|
|
5022
|
+
const kdf3 = await kdfRK(state.rootKey, dhOut3);
|
|
5023
|
+
state.rootKey = kdf3.newRootKey;
|
|
5024
|
+
state.sendChainKey = kdf3.newChainKey;
|
|
5025
|
+
if (state.dhSkippedKeys) state.dhSkippedKeys.clear();
|
|
5026
|
+
if (state.skippedKeys) state.skippedKeys.clear();
|
|
5027
|
+
}
|
|
5028
|
+
} catch {
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
4982
5031
|
if (!rawPlaintext) {
|
|
4983
5032
|
rawPlaintext = import_tweetnacl.default.box.open(ciphertext, nonce, senderEncPub, this.encryptionKeyPair.secretKey);
|
|
4984
5033
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4969,6 +4969,55 @@ var VoidlyAgent = class _VoidlyAgent {
|
|
|
4969
4969
|
rawPlaintext = import_tweetnacl.default.secretbox.open(ciphertext, nonce, messageKey);
|
|
4970
4970
|
}
|
|
4971
4971
|
}
|
|
4972
|
+
if (!rawPlaintext && envelopeDhRatchetKey && this.doubleRatchet && state) {
|
|
4973
|
+
try {
|
|
4974
|
+
const x25519Shared2 = import_tweetnacl.default.box.before(senderEncPub, this.encryptionKeyPair.secretKey);
|
|
4975
|
+
let initialKey2;
|
|
4976
|
+
if (envelopePqCiphertext && this.mlkemSecretKey) {
|
|
4977
|
+
try {
|
|
4978
|
+
const pqCt2 = (0, import_tweetnacl_util.decodeBase64)(envelopePqCiphertext);
|
|
4979
|
+
const kem2 = new MlKem768();
|
|
4980
|
+
const pqShared2 = await kem2.decap(pqCt2, this.mlkemSecretKey);
|
|
4981
|
+
const combined2 = new Uint8Array(x25519Shared2.length + pqShared2.length);
|
|
4982
|
+
combined2.set(x25519Shared2, 0);
|
|
4983
|
+
combined2.set(pqShared2, x25519Shared2.length);
|
|
4984
|
+
initialKey2 = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", combined2));
|
|
4985
|
+
} catch {
|
|
4986
|
+
initialKey2 = x25519Shared2;
|
|
4987
|
+
}
|
|
4988
|
+
} else {
|
|
4989
|
+
initialKey2 = x25519Shared2;
|
|
4990
|
+
}
|
|
4991
|
+
const senderDhPub2 = (0, import_tweetnacl_util.decodeBase64)(envelopeDhRatchetKey);
|
|
4992
|
+
const dhOutput2 = import_tweetnacl.default.box.before(senderDhPub2, this.encryptionKeyPair.secretKey);
|
|
4993
|
+
const { newRootKey: rk2, newChainKey: ck2 } = await kdfRK(initialKey2, dhOutput2);
|
|
4994
|
+
let freshCk = ck2;
|
|
4995
|
+
for (let fi = 1; fi < envelopeRatchetStep; fi++) {
|
|
4996
|
+
const { nextChainKey: nck } = await ratchetStep(freshCk);
|
|
4997
|
+
freshCk = nck;
|
|
4998
|
+
}
|
|
4999
|
+
const { nextChainKey: finalCk, messageKey: freshMk } = await ratchetStep(freshCk);
|
|
5000
|
+
const freshPlain = import_tweetnacl.default.secretbox.open(ciphertext, nonce, freshMk);
|
|
5001
|
+
if (freshPlain) {
|
|
5002
|
+
rawPlaintext = freshPlain;
|
|
5003
|
+
state.recvChainKey = finalCk;
|
|
5004
|
+
state.recvStep = envelopeRatchetStep;
|
|
5005
|
+
state.rootKey = rk2;
|
|
5006
|
+
state.dhRecvPubKey = senderDhPub2;
|
|
5007
|
+
state.prevSendStep = state.sendStep;
|
|
5008
|
+
state.dhSendKeyPair = import_tweetnacl.default.box.keyPair();
|
|
5009
|
+
state.sendStep = 0;
|
|
5010
|
+
state.sendChainKey = initialKey2;
|
|
5011
|
+
const dhOut3 = import_tweetnacl.default.box.before(senderDhPub2, state.dhSendKeyPair.secretKey);
|
|
5012
|
+
const kdf3 = await kdfRK(state.rootKey, dhOut3);
|
|
5013
|
+
state.rootKey = kdf3.newRootKey;
|
|
5014
|
+
state.sendChainKey = kdf3.newChainKey;
|
|
5015
|
+
if (state.dhSkippedKeys) state.dhSkippedKeys.clear();
|
|
5016
|
+
if (state.skippedKeys) state.skippedKeys.clear();
|
|
5017
|
+
}
|
|
5018
|
+
} catch {
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
4972
5021
|
if (!rawPlaintext) {
|
|
4973
5022
|
rawPlaintext = import_tweetnacl.default.box.open(ciphertext, nonce, senderEncPub, this.encryptionKeyPair.secretKey);
|
|
4974
5023
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidly/agent-sdk",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "E2E encrypted agent-to-agent communication SDK — Double Ratchet, X3DH, deniable auth, ML-KEM-768 post-quantum, SSE streaming, ratchet persistence, multi-relay federation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|