phase8-p1b-argon2id-latency.test.mjs
36 lines 1.3 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 10 days ago
1 /**
2 * Phase 8 P1b — performance tier: Argon2id latency bounds (§9).
3 */
4
5 import { describe, test } from 'node:test';
6 import assert from 'node:assert/strict';
7 import {
8 hashPassphrase,
9 verifyPassphrase,
10 ARGON2_PARAMS,
11 } from '../../hub/lib/local-auth.mjs';
12
13 describe('phase8-p1b Argon2id latency (performance)', () => {
14 test('verify latency on floor params: ≥50ms and ≤2000ms', async () => {
15 let maxMs = 0;
16 for (let i = 0; i < 3; i++) {
17 const phc = await hashPassphrase(`PerfTest123!Xy${i}`);
18 const start = performance.now();
19 const ok = await verifyPassphrase(phc, `PerfTest123!Xy${i}`);
20 maxMs = Math.max(maxMs, performance.now() - start);
21 assert.equal(ok, true);
22 }
23 assert.ok(maxMs >= 50, `expected ≥50ms on at least one sample, max=${maxMs}`);
24 assert.ok(maxMs <= 2000, `expected ≤2000ms, got ${maxMs}`);
25 assert.equal(ARGON2_PARAMS.timeCost, 3);
26 assert.equal(ARGON2_PARAMS.memoryCost, 65536);
27 assert.equal(ARGON2_PARAMS.parallelism, 4);
28 });
29
30 test('hash at floor params completes within 3000ms', async () => {
31 const start = performance.now();
32 await hashPassphrase('BootstrapPerf123!');
33 const ms = performance.now() - start;
34 assert.ok(ms <= 3000, `bootstrap hash took ${ms}ms`);
35 });
36 });
File History 1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 10 days ago