@sebastienrousseau/crypto-lib 0.0.39 → 0.0.40
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/modern/aead-open.d.ts +5 -0
- package/dist/modern/aead-open.d.ts.map +1 -0
- package/dist/modern/aead-open.js +13 -0
- package/dist/modern/aead.d.ts.map +1 -1
- package/dist/modern/aead.js +2 -1
- package/dist/modern/aes.d.ts.map +1 -1
- package/dist/modern/aes.js +3 -2
- package/dist/protocols/threshold.d.ts.map +1 -1
- package/dist/protocols/threshold.js +7 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aead-open.d.ts","sourceRoot":"","sources":["../../src/modern/aead-open.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACzC;AAWD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CASzE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openSealed = openSealed;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
function openSealed(cipher, sealed) {
|
|
6
|
+
try {
|
|
7
|
+
return cipher.decrypt(sealed);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
throw new errors_1.CryptoError("Authentication failed: wrong key, wrong associated data or modified ciphertext", errors_1.CryptoErrorCode.AUTH_FAILED);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=aead-open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aead.d.ts","sourceRoot":"","sources":["../../src/modern/aead.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aead.d.ts","sourceRoot":"","sources":["../../src/modern/aead.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,iBAAiB;IAEhC,UAAU,EAAE,MAAM,CAAC;IAEnB,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAGD,MAAM,WAAW,kBAAkB;IAEjC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;IAE/B,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,kBAAkB;IAEjC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,UAAU,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAyBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAwB1E;AAOD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU,CAsBnE"}
|
package/dist/modern/aead.js
CHANGED
|
@@ -6,6 +6,7 @@ const chacha_js_1 = require("@noble/ciphers/chacha.js");
|
|
|
6
6
|
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
7
7
|
const errors_1 = require("../errors");
|
|
8
8
|
const encoding_1 = require("../encoding");
|
|
9
|
+
const aead_open_1 = require("./aead-open");
|
|
9
10
|
function toBytes(input, encoding = "utf8") {
|
|
10
11
|
if (input instanceof Uint8Array)
|
|
11
12
|
return input;
|
|
@@ -47,6 +48,6 @@ function aeadDecrypt(options) {
|
|
|
47
48
|
const nonce = combined.subarray(0, NONCE_LENGTH);
|
|
48
49
|
const sealed = combined.subarray(NONCE_LENGTH);
|
|
49
50
|
const cipher = (0, chacha_js_1.xchacha20poly1305)(key, nonce, options.aad);
|
|
50
|
-
return
|
|
51
|
+
return (0, aead_open_1.openSealed)(cipher, sealed);
|
|
51
52
|
}
|
|
52
53
|
//# sourceMappingURL=aead.js.map
|
package/dist/modern/aes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aes.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,GAC/B,sBAAsB,CAcxB;AAOD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,UAAU,CAK7E"}
|
package/dist/modern/aes.js
CHANGED
|
@@ -8,6 +8,7 @@ const aes_js_1 = require("@noble/ciphers/aes.js");
|
|
|
8
8
|
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
9
9
|
const errors_1 = require("../errors");
|
|
10
10
|
const encoding_1 = require("../encoding");
|
|
11
|
+
const aead_open_1 = require("./aead-open");
|
|
11
12
|
function toBytes(input, encoding = "utf8") {
|
|
12
13
|
if (input instanceof Uint8Array)
|
|
13
14
|
return input;
|
|
@@ -60,7 +61,7 @@ function aesGcmDecrypt(options) {
|
|
|
60
61
|
const key = validateAesKey(options.key);
|
|
61
62
|
const { nonce, sealed } = unpackNonceAndSealed(options.ciphertext);
|
|
62
63
|
const cipher = (0, aes_js_1.gcm)(key, nonce, options.aad);
|
|
63
|
-
return
|
|
64
|
+
return (0, aead_open_1.openSealed)(cipher, sealed);
|
|
64
65
|
}
|
|
65
66
|
function aesGcmSivEncrypt(options) {
|
|
66
67
|
const key = validateAesKey(options.key);
|
|
@@ -78,6 +79,6 @@ function aesGcmSivDecrypt(options) {
|
|
|
78
79
|
const key = validateAesKey(options.key);
|
|
79
80
|
const { nonce, sealed } = unpackNonceAndSealed(options.ciphertext);
|
|
80
81
|
const cipher = (0, aes_js_1.gcmsiv)(key, nonce, options.aad);
|
|
81
|
-
return
|
|
82
|
+
return (0, aead_open_1.openSealed)(cipher, sealed);
|
|
82
83
|
}
|
|
83
84
|
//# sourceMappingURL=aes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threshold.d.ts","sourceRoot":"","sources":["../../src/protocols/threshold.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,KAAK;IAEpB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAGD,MAAM,WAAW,kBAAkB;IAEjC,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,SAAS,EAAE,qBAAqB,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"threshold.d.ts","sourceRoot":"","sources":["../../src/protocols/threshold.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,KAAK;IAEpB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAGD,MAAM,WAAW,kBAAkB;IAEjC,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,SAAS,EAAE,qBAAqB,CAAC;CAClC;AAyID,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,GAChB,WAAW,CAoDb;AAQD,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAuCrD;AAaD,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EAAE,GACrB,kBAAkB,CAoBpB;AAYD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAsBT;AAUD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,MAAM,GAChB;IAED,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,WAAW,EAAE,kBAAkB,CAAC;IAEhC,SAAS,EAAE,MAAM,CAAC;CACnB,CAoDA"}
|
|
@@ -17,6 +17,12 @@ function scalarToHex(scalar) {
|
|
|
17
17
|
const hex = scalar.toString(16).padStart(64, "0");
|
|
18
18
|
return hex;
|
|
19
19
|
}
|
|
20
|
+
function commitmentPoint(hex) {
|
|
21
|
+
if (!(0, encoding_1.isHex)(hex)) {
|
|
22
|
+
throw new errors_1.CryptoError("Invalid hex string", errors_1.CryptoErrorCode.INVALID_HEX);
|
|
23
|
+
}
|
|
24
|
+
return ed25519_js_1.ed25519.Point.fromHex(hex);
|
|
25
|
+
}
|
|
20
26
|
function hexToScalar(hex) {
|
|
21
27
|
if (!(0, encoding_1.isHex)(hex)) {
|
|
22
28
|
throw new errors_1.CryptoError("Invalid hex string", errors_1.CryptoErrorCode.INVALID_HEX);
|
|
@@ -151,7 +157,7 @@ function verifyFeldmanShare(share, commitments) {
|
|
|
151
157
|
let rhs = ed25519_js_1.ed25519.Point.ZERO;
|
|
152
158
|
let power = BigInt(1);
|
|
153
159
|
for (const commitHex of commitments.commitments) {
|
|
154
|
-
const commitPoint =
|
|
160
|
+
const commitPoint = commitmentPoint(commitHex);
|
|
155
161
|
const term = commitPoint.multiply(power);
|
|
156
162
|
rhs = rhs.add(term);
|
|
157
163
|
power = modMul(power, x);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebastienrousseau/crypto-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "Post-quantum cryptography library for TypeScript and Node.js: ML-KEM, ML-DSA, SLH-DSA, HPKE, AES-GCM, XChaCha20-Poly1305, Ed25519, X25519, SHA-3, BLAKE3, Argon2id and OpenPGP.",
|
|
5
5
|
"author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -122,14 +122,14 @@
|
|
|
122
122
|
"@types/chai": "^5.2.3",
|
|
123
123
|
"@types/chai-as-promised": "^8.0.2",
|
|
124
124
|
"@types/mocha": "^10.0.10",
|
|
125
|
-
"@types/node": "^26.6.
|
|
125
|
+
"@types/node": "^26.6.6",
|
|
126
126
|
"c8": "^12.0.0",
|
|
127
127
|
"chai": "^6.3.0",
|
|
128
128
|
"chai-as-promised": "^8.0.2",
|
|
129
129
|
"fast-check": "^4.10.2",
|
|
130
130
|
"mocha": "^12.0.3",
|
|
131
131
|
"prettier": "^3.9.10",
|
|
132
|
-
"rimraf": "^6.1.
|
|
132
|
+
"rimraf": "^6.1.4",
|
|
133
133
|
"ts-node": "^10.9.2",
|
|
134
134
|
"typedoc": "^0.28.20",
|
|
135
135
|
"typescript": "~5.9.3"
|