@sebastienrousseau/crypto-benchmarks 0.0.9 → 0.0.24
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/benchmarks/asymmetric.d.ts.map +1 -1
- package/dist/benchmarks/asymmetric.js +34 -24
- package/dist/benchmarks/streaming.d.ts +20 -0
- package/dist/benchmarks/streaming.d.ts.map +1 -0
- package/dist/benchmarks/streaming.js +180 -0
- package/dist/benchmarks/symmetric.d.ts.map +1 -1
- package/dist/benchmarks/symmetric.js +32 -23
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +28 -27
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asymmetric.d.ts","sourceRoot":"","sources":["../../src/benchmarks/asymmetric.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"asymmetric.d.ts","sourceRoot":"","sources":["../../src/benchmarks/asymmetric.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqG/C,wBAAsB,uBAAuB,CAC3C,UAAU,SAAK,GACd,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAUhC"}
|
|
@@ -6,33 +6,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runAsymmetricBenchmarks = runAsymmetricBenchmarks;
|
|
7
7
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
8
|
const timer_1 = require("../timer");
|
|
9
|
-
async function
|
|
10
|
-
const results = [];
|
|
11
|
-
const message = Buffer.from("Financial Transaction ISO 20022 Compliance Payload");
|
|
9
|
+
async function benchEd25519(message, iterations) {
|
|
12
10
|
const edKeys = node_crypto_1.default.generateKeyPairSync("ed25519");
|
|
13
11
|
let edSig = Buffer.alloc(0);
|
|
14
12
|
const edSignStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
15
13
|
edSig = node_crypto_1.default.sign(null, message, edKeys.privateKey);
|
|
16
14
|
}, { iterations, warmup: 3 });
|
|
17
|
-
results.push({
|
|
18
|
-
name: "Ed25519 Digital Signing",
|
|
19
|
-
category: "asymmetric",
|
|
20
|
-
algorithm: "Ed25519",
|
|
21
|
-
operation: "sign",
|
|
22
|
-
quantumSafe: false,
|
|
23
|
-
stats: edSignStats,
|
|
24
|
-
});
|
|
25
15
|
const edVerifyStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
26
16
|
node_crypto_1.default.verify(null, message, edKeys.publicKey, edSig);
|
|
27
17
|
}, { iterations, warmup: 3 });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
name: "Ed25519 Digital Signing",
|
|
21
|
+
category: "asymmetric",
|
|
22
|
+
algorithm: "Ed25519",
|
|
23
|
+
operation: "sign",
|
|
24
|
+
quantumSafe: false,
|
|
25
|
+
stats: edSignStats,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "Ed25519 Signature Verification",
|
|
29
|
+
category: "asymmetric",
|
|
30
|
+
algorithm: "Ed25519",
|
|
31
|
+
operation: "verify",
|
|
32
|
+
quantumSafe: false,
|
|
33
|
+
stats: edVerifyStats,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
async function benchEcdsa(message, iterations) {
|
|
36
38
|
const ecKeys = node_crypto_1.default.generateKeyPairSync("ec", { namedCurve: "prime256v1" });
|
|
37
39
|
const ecSignStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
38
40
|
const sign = node_crypto_1.default.createSign("SHA256");
|
|
@@ -40,14 +42,16 @@ async function runAsymmetricBenchmarks(iterations = 20) {
|
|
|
40
42
|
sign.end();
|
|
41
43
|
sign.sign(ecKeys.privateKey);
|
|
42
44
|
}, { iterations, warmup: 3 });
|
|
43
|
-
|
|
45
|
+
return {
|
|
44
46
|
name: "ECDSA (P-256) Digital Signing",
|
|
45
47
|
category: "asymmetric",
|
|
46
48
|
algorithm: "ECDSA-P256",
|
|
47
49
|
operation: "sign",
|
|
48
50
|
quantumSafe: false,
|
|
49
51
|
stats: ecSignStats,
|
|
50
|
-
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function benchRsa(message, iterations) {
|
|
51
55
|
const rsaKeys = node_crypto_1.default.generateKeyPairSync("rsa", { modulusLength: 2048 });
|
|
52
56
|
const rsaSignStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
53
57
|
const sign = node_crypto_1.default.createSign("SHA256");
|
|
@@ -55,14 +59,20 @@ async function runAsymmetricBenchmarks(iterations = 20) {
|
|
|
55
59
|
sign.end();
|
|
56
60
|
sign.sign(rsaKeys.privateKey);
|
|
57
61
|
}, { iterations: Math.min(iterations, 10), warmup: 2 });
|
|
58
|
-
|
|
62
|
+
return {
|
|
59
63
|
name: "RSA-2048 Digital Signing",
|
|
60
64
|
category: "asymmetric",
|
|
61
65
|
algorithm: "RSA-2048",
|
|
62
66
|
operation: "sign",
|
|
63
67
|
quantumSafe: false,
|
|
64
68
|
stats: rsaSignStats,
|
|
65
|
-
}
|
|
66
|
-
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async function runAsymmetricBenchmarks(iterations = 20) {
|
|
72
|
+
const message = Buffer.from("Financial Transaction ISO 20022 Compliance Payload");
|
|
73
|
+
const edResults = await benchEd25519(message, iterations);
|
|
74
|
+
const ecResult = await benchEcdsa(message, iterations);
|
|
75
|
+
const rsaResult = await benchRsa(message, iterations);
|
|
76
|
+
return [...edResults, ecResult, rsaResult];
|
|
67
77
|
}
|
|
68
78
|
//# sourceMappingURL=asymmetric.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MultiPqRecipient } from "@sebastienrousseau/crypto-lib";
|
|
2
|
+
import { BenchmarkItemResult } from "../types";
|
|
3
|
+
export interface StreamingOperations {
|
|
4
|
+
payload64k: Uint8Array;
|
|
5
|
+
symmetricKey: Uint8Array;
|
|
6
|
+
symmetricCiphertext64k: Uint8Array;
|
|
7
|
+
x25519Public: string;
|
|
8
|
+
x25519Secret: string;
|
|
9
|
+
mlKemPublic: string;
|
|
10
|
+
mlKemSecret: string;
|
|
11
|
+
pqCiphertext64k: Uint8Array;
|
|
12
|
+
multiRecipients: MultiPqRecipient[];
|
|
13
|
+
aliceId: string;
|
|
14
|
+
aliceX25519Secret: string;
|
|
15
|
+
aliceMlKemSecret: string;
|
|
16
|
+
multiPqCiphertext64k: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
export declare function createStreamingOperations(): StreamingOperations;
|
|
19
|
+
export declare function runStreamingBenchmarks(iterations?: number): Promise<BenchmarkItemResult[]>;
|
|
20
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/benchmarks/streaming.ts"],"names":[],"mappings":"AAGA,OAAO,EASL,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,UAAU,CAAC;IACzB,sBAAsB,EAAE,UAAU,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,UAAU,CAAC;IAC5B,eAAe,EAAE,gBAAgB,EAAE,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,UAAU,CAAC;CAClC;AA8CD,wBAAgB,yBAAyB,IAAI,mBAAmB,CAkC/D;AA2ID,wBAAsB,sBAAsB,CAC1C,UAAU,SAAK,GACd,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAMhC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createStreamingOperations = createStreamingOperations;
|
|
7
|
+
exports.runStreamingBenchmarks = runStreamingBenchmarks;
|
|
8
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
|
+
const crypto_lib_1 = require("@sebastienrousseau/crypto-lib");
|
|
10
|
+
const timer_1 = require("../timer");
|
|
11
|
+
function createMultiRecipients() {
|
|
12
|
+
const aliceX = (0, crypto_lib_1.generateX25519KeyPair)();
|
|
13
|
+
const aliceMl = (0, crypto_lib_1.mlKemKeygen)(768);
|
|
14
|
+
const bobX = (0, crypto_lib_1.generateX25519KeyPair)();
|
|
15
|
+
const bobMl = (0, crypto_lib_1.mlKemKeygen)(768);
|
|
16
|
+
const charlieX = (0, crypto_lib_1.generateX25519KeyPair)();
|
|
17
|
+
const charlieMl = (0, crypto_lib_1.mlKemKeygen)(768);
|
|
18
|
+
const recipients = [
|
|
19
|
+
{
|
|
20
|
+
recipientId: "alice@example.com",
|
|
21
|
+
recipientX25519Public: aliceX.publicKey,
|
|
22
|
+
recipientMlKemPublic: aliceMl.publicKey,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
recipientId: "bob@example.com",
|
|
26
|
+
recipientX25519Public: bobX.publicKey,
|
|
27
|
+
recipientMlKemPublic: bobMl.publicKey,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
recipientId: "charlie@example.com",
|
|
31
|
+
recipientX25519Public: charlieX.publicKey,
|
|
32
|
+
recipientMlKemPublic: charlieMl.publicKey,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
return {
|
|
36
|
+
recipients,
|
|
37
|
+
alice: {
|
|
38
|
+
id: "alice@example.com",
|
|
39
|
+
xSec: aliceX.privateKey,
|
|
40
|
+
mlSec: aliceMl.secretKey,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createStreamingOperations() {
|
|
45
|
+
const payload64k = node_crypto_1.default.randomBytes(64 * 1024);
|
|
46
|
+
const symmetricKey = node_crypto_1.default.randomBytes(32);
|
|
47
|
+
const symEnc = (0, crypto_lib_1.streamEncrypt)({ key: symmetricKey, plaintext: payload64k });
|
|
48
|
+
const x25519 = (0, crypto_lib_1.generateX25519KeyPair)();
|
|
49
|
+
const mlkem = (0, crypto_lib_1.mlKemKeygen)(768);
|
|
50
|
+
const pqEnc = (0, crypto_lib_1.streamPqEncrypt)({
|
|
51
|
+
recipientX25519Public: x25519.publicKey,
|
|
52
|
+
recipientMlKemPublic: mlkem.publicKey,
|
|
53
|
+
plaintext: payload64k,
|
|
54
|
+
});
|
|
55
|
+
const { recipients, alice } = createMultiRecipients();
|
|
56
|
+
const multiPqEnc = (0, crypto_lib_1.streamMultiPqEncrypt)({
|
|
57
|
+
recipients,
|
|
58
|
+
plaintext: payload64k,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
payload64k,
|
|
62
|
+
symmetricKey,
|
|
63
|
+
symmetricCiphertext64k: symEnc.ciphertext,
|
|
64
|
+
x25519Public: x25519.publicKey,
|
|
65
|
+
x25519Secret: x25519.privateKey,
|
|
66
|
+
mlKemPublic: mlkem.publicKey,
|
|
67
|
+
mlKemSecret: mlkem.secretKey,
|
|
68
|
+
pqCiphertext64k: pqEnc.ciphertext,
|
|
69
|
+
multiRecipients: recipients,
|
|
70
|
+
aliceId: alice.id,
|
|
71
|
+
aliceX25519Secret: alice.xSec,
|
|
72
|
+
aliceMlKemSecret: alice.mlSec,
|
|
73
|
+
multiPqCiphertext64k: multiPqEnc.ciphertext,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function benchmarkSymmetricStreaming(ops, iterations) {
|
|
77
|
+
const encStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
78
|
+
(0, crypto_lib_1.streamEncrypt)({ key: ops.symmetricKey, plaintext: ops.payload64k });
|
|
79
|
+
}, { iterations, warmup: 5 });
|
|
80
|
+
const decStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
81
|
+
(0, crypto_lib_1.streamDecrypt)({
|
|
82
|
+
key: ops.symmetricKey,
|
|
83
|
+
ciphertext: ops.symmetricCiphertext64k,
|
|
84
|
+
});
|
|
85
|
+
}, { iterations, warmup: 5 });
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
name: "Symmetric Stream AEAD Encrypt (64KB)",
|
|
89
|
+
category: "streaming",
|
|
90
|
+
algorithm: "XChaCha20-Poly1305",
|
|
91
|
+
operation: "encrypt",
|
|
92
|
+
quantumSafe: true,
|
|
93
|
+
stats: encStats,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "Symmetric Stream AEAD Decrypt (64KB)",
|
|
97
|
+
category: "streaming",
|
|
98
|
+
algorithm: "XChaCha20-Poly1305",
|
|
99
|
+
operation: "decrypt",
|
|
100
|
+
quantumSafe: true,
|
|
101
|
+
stats: decStats,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
async function benchmarkPqStreaming(ops, iterations) {
|
|
106
|
+
const encStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
107
|
+
(0, crypto_lib_1.streamPqEncrypt)({
|
|
108
|
+
recipientX25519Public: ops.x25519Public,
|
|
109
|
+
recipientMlKemPublic: ops.mlKemPublic,
|
|
110
|
+
plaintext: ops.payload64k,
|
|
111
|
+
});
|
|
112
|
+
}, { iterations, warmup: 5 });
|
|
113
|
+
const decStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
114
|
+
(0, crypto_lib_1.streamPqDecrypt)({
|
|
115
|
+
recipientX25519Secret: ops.x25519Secret,
|
|
116
|
+
recipientMlKemSecret: ops.mlKemSecret,
|
|
117
|
+
ciphertext: ops.pqCiphertext64k,
|
|
118
|
+
});
|
|
119
|
+
}, { iterations, warmup: 5 });
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
name: "Post-Quantum Stream AEAD Encrypt (64KB)",
|
|
123
|
+
category: "streaming",
|
|
124
|
+
algorithm: "X25519+ML-KEM-768",
|
|
125
|
+
operation: "encrypt",
|
|
126
|
+
quantumSafe: true,
|
|
127
|
+
stats: encStats,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "Post-Quantum Stream AEAD Decrypt (64KB)",
|
|
131
|
+
category: "streaming",
|
|
132
|
+
algorithm: "X25519+ML-KEM-768",
|
|
133
|
+
operation: "decrypt",
|
|
134
|
+
quantumSafe: true,
|
|
135
|
+
stats: decStats,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
async function benchmarkMultiPqStreaming(ops, iterations) {
|
|
140
|
+
const encStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
141
|
+
(0, crypto_lib_1.streamMultiPqEncrypt)({
|
|
142
|
+
recipients: ops.multiRecipients,
|
|
143
|
+
plaintext: ops.payload64k,
|
|
144
|
+
});
|
|
145
|
+
}, { iterations, warmup: 5 });
|
|
146
|
+
const decStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
147
|
+
(0, crypto_lib_1.streamMultiPqDecrypt)({
|
|
148
|
+
recipientId: ops.aliceId,
|
|
149
|
+
recipientX25519Secret: ops.aliceX25519Secret,
|
|
150
|
+
recipientMlKemSecret: ops.aliceMlKemSecret,
|
|
151
|
+
ciphertext: ops.multiPqCiphertext64k,
|
|
152
|
+
});
|
|
153
|
+
}, { iterations, warmup: 5 });
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
name: "Multi-Recipient PQ Stream AEAD Encrypt (3 recipients, 64KB)",
|
|
157
|
+
category: "streaming",
|
|
158
|
+
algorithm: "Multi-X25519+ML-KEM-768",
|
|
159
|
+
operation: "encrypt",
|
|
160
|
+
quantumSafe: true,
|
|
161
|
+
stats: encStats,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "Multi-Recipient PQ Stream AEAD Decrypt (3 recipients, 64KB)",
|
|
165
|
+
category: "streaming",
|
|
166
|
+
algorithm: "Multi-X25519+ML-KEM-768",
|
|
167
|
+
operation: "decrypt",
|
|
168
|
+
quantumSafe: true,
|
|
169
|
+
stats: decStats,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
async function runStreamingBenchmarks(iterations = 30) {
|
|
174
|
+
const ops = createStreamingOperations();
|
|
175
|
+
const symmetric = await benchmarkSymmetricStreaming(ops, iterations);
|
|
176
|
+
const pq = await benchmarkPqStreaming(ops, iterations);
|
|
177
|
+
const multiPq = await benchmarkMultiPqStreaming(ops, iterations);
|
|
178
|
+
return [...symmetric, ...pq, ...multiPq];
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symmetric.d.ts","sourceRoot":"","sources":["../../src/benchmarks/symmetric.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"symmetric.d.ts","sourceRoot":"","sources":["../../src/benchmarks/symmetric.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAwF/C,wBAAsB,sBAAsB,CAC1C,UAAU,SAAK,GACd,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAYhC"}
|
|
@@ -6,56 +6,65 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runSymmetricBenchmarks = runSymmetricBenchmarks;
|
|
7
7
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
8
|
const timer_1 = require("../timer");
|
|
9
|
-
async function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const key32 = node_crypto_1.default.randomBytes(32);
|
|
13
|
-
const key16 = node_crypto_1.default.randomBytes(16);
|
|
14
|
-
const iv12 = node_crypto_1.default.randomBytes(12);
|
|
15
|
-
const iv16 = node_crypto_1.default.randomBytes(16);
|
|
16
|
-
const aesGcmEncStats = await (0, timer_1.benchmarkOperation)(() => {
|
|
17
|
-
const cipher = node_crypto_1.default.createCipheriv("aes-256-gcm", key32, iv12);
|
|
9
|
+
async function benchAesGcm(payload, key, iv, iterations) {
|
|
10
|
+
const stats = await (0, timer_1.benchmarkOperation)(() => {
|
|
11
|
+
const cipher = node_crypto_1.default.createCipheriv("aes-256-gcm", key, iv);
|
|
18
12
|
cipher.update(payload);
|
|
19
13
|
cipher.final();
|
|
20
14
|
cipher.getAuthTag();
|
|
21
15
|
}, { iterations, warmup: 5 });
|
|
22
|
-
|
|
16
|
+
return {
|
|
23
17
|
name: "AES-256-GCM Encryption (1KB)",
|
|
24
18
|
category: "symmetric",
|
|
25
19
|
algorithm: "AES-256-GCM",
|
|
26
20
|
operation: "encrypt",
|
|
27
21
|
quantumSafe: true,
|
|
28
|
-
stats
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
stats,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function benchChaCha(payload, key, iv, iterations) {
|
|
26
|
+
const stats = await (0, timer_1.benchmarkOperation)(() => {
|
|
27
|
+
const cipher = node_crypto_1.default.createCipheriv("chacha20-poly1305", key, iv, {
|
|
32
28
|
authTagLength: 16,
|
|
33
29
|
});
|
|
34
30
|
cipher.update(payload);
|
|
35
31
|
cipher.final();
|
|
36
32
|
cipher.getAuthTag();
|
|
37
33
|
}, { iterations, warmup: 5 });
|
|
38
|
-
|
|
34
|
+
return {
|
|
39
35
|
name: "ChaCha20-Poly1305 Encryption (1KB)",
|
|
40
36
|
category: "symmetric",
|
|
41
37
|
algorithm: "ChaCha20-Poly1305",
|
|
42
38
|
operation: "encrypt",
|
|
43
39
|
quantumSafe: true,
|
|
44
|
-
stats
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
stats,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function benchAesCbc(payload, key, iv, iterations) {
|
|
44
|
+
const stats = await (0, timer_1.benchmarkOperation)(() => {
|
|
45
|
+
const cipher = node_crypto_1.default.createCipheriv("aes-128-cbc", key, iv);
|
|
48
46
|
cipher.update(payload);
|
|
49
47
|
cipher.final();
|
|
50
48
|
}, { iterations, warmup: 5 });
|
|
51
|
-
|
|
49
|
+
return {
|
|
52
50
|
name: "AES-128-CBC Encryption (1KB)",
|
|
53
51
|
category: "symmetric",
|
|
54
52
|
algorithm: "AES-128-CBC",
|
|
55
53
|
operation: "encrypt",
|
|
56
54
|
quantumSafe: false,
|
|
57
|
-
stats
|
|
58
|
-
}
|
|
59
|
-
|
|
55
|
+
stats,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function runSymmetricBenchmarks(iterations = 50) {
|
|
59
|
+
const payload = node_crypto_1.default.randomBytes(1024);
|
|
60
|
+
const key32 = node_crypto_1.default.randomBytes(32);
|
|
61
|
+
const key16 = node_crypto_1.default.randomBytes(16);
|
|
62
|
+
const iv12 = node_crypto_1.default.randomBytes(12);
|
|
63
|
+
const iv16 = node_crypto_1.default.randomBytes(16);
|
|
64
|
+
return [
|
|
65
|
+
await benchAesGcm(payload, key32, iv12, iterations),
|
|
66
|
+
await benchChaCha(payload, key32, iv12, iterations),
|
|
67
|
+
await benchAesCbc(payload, key16, iv16, iterations),
|
|
68
|
+
];
|
|
60
69
|
}
|
|
61
70
|
//# sourceMappingURL=symmetric.js.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAwCA,wBAAsB,GAAG,CACvB,IAAI,GAAE,MAAM,EAA0B,GACrC,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ const SUITES = [
|
|
|
13
13
|
"asymmetric",
|
|
14
14
|
"pqc",
|
|
15
15
|
"hash",
|
|
16
|
+
"streaming",
|
|
16
17
|
];
|
|
17
18
|
const FORMATS = ["table", "json", "markdown"];
|
|
18
19
|
function optionValue(args, flag) {
|
|
@@ -31,7 +32,7 @@ async function run(args = node_process_1.default.argv.slice(2)) {
|
|
|
31
32
|
if (args.includes("--help") || args.includes("-h")) {
|
|
32
33
|
node_process_1.default.stdout.write("Usage: crypto-benchmarks [options]\n");
|
|
33
34
|
node_process_1.default.stdout.write("Options:\n");
|
|
34
|
-
node_process_1.default.stdout.write(" --suite <all|symmetric|asymmetric|pqc|hash> Benchmark suite to run (default: all)\n");
|
|
35
|
+
node_process_1.default.stdout.write(" --suite <all|symmetric|asymmetric|pqc|hash|streaming> Benchmark suite to run (default: all)\n");
|
|
35
36
|
node_process_1.default.stdout.write(" --iterations <N> Number of iterations (default: 30)\n");
|
|
36
37
|
node_process_1.default.stdout.write(" --format <table|json|markdown> Output format (default: table)\n");
|
|
37
38
|
return 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./benchmarks/symmetric";
|
|
|
4
4
|
export * from "./benchmarks/asymmetric";
|
|
5
5
|
export * from "./benchmarks/pqc";
|
|
6
6
|
export * from "./benchmarks/hash";
|
|
7
|
+
export * from "./benchmarks/streaming";
|
|
7
8
|
export * from "./runner";
|
|
8
9
|
export * from "./cli";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./benchmarks/symmetric"), exports);
|
|
|
20
20
|
__exportStar(require("./benchmarks/asymmetric"), exports);
|
|
21
21
|
__exportStar(require("./benchmarks/pqc"), exports);
|
|
22
22
|
__exportStar(require("./benchmarks/hash"), exports);
|
|
23
|
+
__exportStar(require("./benchmarks/streaming"), exports);
|
|
23
24
|
__exportStar(require("./runner"), exports);
|
|
24
25
|
__exportStar(require("./cli"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAuB,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAuB,eAAe,EAAE,MAAM,SAAS,CAAC;AAmDhF,wBAAsB,QAAQ,CAC5B,MAAM,GAAE,eAAoB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAgC1B"}
|
package/dist/runner.js
CHANGED
|
@@ -10,29 +10,13 @@ const symmetric_1 = require("./benchmarks/symmetric");
|
|
|
10
10
|
const asymmetric_1 = require("./benchmarks/asymmetric");
|
|
11
11
|
const pqc_1 = require("./benchmarks/pqc");
|
|
12
12
|
const hash_1 = require("./benchmarks/hash");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const iterations = config.iterations || 30;
|
|
16
|
-
const results = [];
|
|
17
|
-
const suites = {
|
|
18
|
-
symmetric: symmetric_1.runSymmetricBenchmarks,
|
|
19
|
-
asymmetric: asymmetric_1.runAsymmetricBenchmarks,
|
|
20
|
-
pqc: pqc_1.runPqcBenchmarks,
|
|
21
|
-
hash: hash_1.runHashBenchmarks,
|
|
22
|
-
};
|
|
23
|
-
for (const [name, run] of Object.entries(suites)) {
|
|
24
|
-
if (suite === "all" || suite === name) {
|
|
25
|
-
results.push(...(await run(iterations)));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const timestamp = new Date().toISOString();
|
|
29
|
-
const platform = `${node_os_1.default.platform()} ${node_os_1.default.arch()}`;
|
|
30
|
-
const nodeVersion = node_process_1.default.version;
|
|
13
|
+
const streaming_1 = require("./benchmarks/streaming");
|
|
14
|
+
function formatMarkdown(timestamp, platform, nodeVersion, results) {
|
|
31
15
|
const mdRows = results.map((r) => {
|
|
32
16
|
const qs = r.quantumSafe ? "✅ Yes" : "❌ No";
|
|
33
17
|
return `| ${r.name} | ${r.algorithm} | ${r.stats.meanMs.toFixed(3)} | ${r.stats.p95Ms.toFixed(3)} | ${r.stats.opsPerSec.toLocaleString()} | ${qs} |`;
|
|
34
18
|
});
|
|
35
|
-
|
|
19
|
+
return [
|
|
36
20
|
`# Cryptographic Performance Benchmark Report`,
|
|
37
21
|
``,
|
|
38
22
|
`- **Date:** ${timestamp}`,
|
|
@@ -45,6 +29,8 @@ async function runSuite(config = {}) {
|
|
|
45
29
|
...mdRows,
|
|
46
30
|
``,
|
|
47
31
|
].join("\n");
|
|
32
|
+
}
|
|
33
|
+
function formatTable(results) {
|
|
48
34
|
const tableHeader = `Name Algorithm Mean(ms) Ops/sec QuantumSafe`;
|
|
49
35
|
const tableDivider = `--------------------------------------------------------------------------------`;
|
|
50
36
|
const tableRows = results.map((r) => {
|
|
@@ -55,20 +41,35 @@ async function runSuite(config = {}) {
|
|
|
55
41
|
const qs = (r.quantumSafe ? "Yes" : "No").padStart(10);
|
|
56
42
|
return `${name} ${alg} ${mean} ${ops} ${qs}`;
|
|
57
43
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
]
|
|
44
|
+
return [tableHeader, tableDivider, ...tableRows, tableDivider].join("\n");
|
|
45
|
+
}
|
|
46
|
+
async function runSuite(config = {}) {
|
|
47
|
+
const suite = config.suite || "all";
|
|
48
|
+
const iterations = config.iterations || 30;
|
|
49
|
+
const results = [];
|
|
50
|
+
const suites = {
|
|
51
|
+
symmetric: symmetric_1.runSymmetricBenchmarks,
|
|
52
|
+
asymmetric: asymmetric_1.runAsymmetricBenchmarks,
|
|
53
|
+
pqc: pqc_1.runPqcBenchmarks,
|
|
54
|
+
hash: hash_1.runHashBenchmarks,
|
|
55
|
+
streaming: streaming_1.runStreamingBenchmarks,
|
|
56
|
+
};
|
|
57
|
+
for (const [name, run] of Object.entries(suites)) {
|
|
58
|
+
if (suite === "all" || suite === name) {
|
|
59
|
+
results.push(...(await run(iterations)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const timestamp = new Date().toISOString();
|
|
63
|
+
const platform = `${node_os_1.default.platform()} ${node_os_1.default.arch()}`;
|
|
64
|
+
const nodeVersion = node_process_1.default.version;
|
|
64
65
|
return {
|
|
65
66
|
timestamp,
|
|
66
67
|
platform,
|
|
67
68
|
nodeVersion,
|
|
68
69
|
totalBenchmarks: results.length,
|
|
69
70
|
results,
|
|
70
|
-
summaryMarkdown,
|
|
71
|
-
summaryTable,
|
|
71
|
+
summaryMarkdown: formatMarkdown(timestamp, platform, nodeVersion, results),
|
|
72
|
+
summaryTable: formatTable(results),
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
//# sourceMappingURL=runner.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SuiteName = "all" | "symmetric" | "asymmetric" | "pqc" | "hash";
|
|
1
|
+
export type SuiteName = "all" | "symmetric" | "asymmetric" | "pqc" | "hash" | "streaming";
|
|
2
2
|
export type OutputFormat = "table" | "json" | "markdown";
|
|
3
3
|
export interface BenchmarkConfig {
|
|
4
4
|
suite?: SuiteName | undefined;
|
|
@@ -19,7 +19,7 @@ export interface BenchmarkStats {
|
|
|
19
19
|
}
|
|
20
20
|
export interface BenchmarkItemResult {
|
|
21
21
|
name: string;
|
|
22
|
-
category: "symmetric" | "asymmetric" | "pqc" | "hash";
|
|
22
|
+
category: "symmetric" | "asymmetric" | "pqc" | "hash" | "streaming";
|
|
23
23
|
algorithm: string;
|
|
24
24
|
operation: string;
|
|
25
25
|
quantumSafe: boolean;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACnB,KAAK,GAAG,WAAW,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebastienrousseau/crypto-benchmarks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Performance benchmarking and latency profiling harness comparing classical vs post-quantum cryptographic primitives across JavaScript, WebAssembly, and native runtimes.",
|
|
5
5
|
"author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dist/**/*.d.ts.map"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@sebastienrousseau/crypto-lib": "0.0.
|
|
40
|
+
"@sebastienrousseau/crypto-lib": "0.0.24"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/chai": "^5.2.3",
|