(n, op, key, keys, ciphertexts)
| 105 | } |
| 106 | |
| 107 | function measureAsyncParallel(n, op, key, keys, ciphertexts) { |
| 108 | let remaining = n; |
| 109 | function done() { |
| 110 | if (--remaining === 0) |
| 111 | bench.end(n); |
| 112 | } |
| 113 | bench.start(); |
| 114 | for (let i = 0; i < n; ++i) { |
| 115 | const k = key || keys[i]; |
| 116 | if (op === 'encapsulate') { |
| 117 | crypto.encapsulate(k, done); |
| 118 | } else { |
| 119 | crypto.decapsulate(k, ciphertexts[i], done); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | function main({ n, mode, keyFormat, keyType, op }) { |
| 125 | const isEncapsulate = op === 'encapsulate'; |