phase8-p1b-argon2id-latency.test.mjs
36 lines 1.3 KB
Raw
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 11 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:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 11 days ago