spd-lib 1.4.0 → 1.4.2
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/index.d.mts +109 -1
- package/index.d.ts +109 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1366,4 +1366,112 @@ declare class SPDShamir {
|
|
|
1366
1366
|
static decodeShare(encoded: string): SPDShamirShare;
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
1369
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* SPDHandshake — Ephemeral X25519 ECDH key agreement for SPD sessions.
|
|
1371
|
+
*
|
|
1372
|
+
* Aligns with SPD v29 security model:
|
|
1373
|
+
* - X25519 ECDH ephemeral keypair — perfect forward secrecy
|
|
1374
|
+
* - Private key blinded in memory (XOR mask) between create() and derive()
|
|
1375
|
+
* - HKDF-SHA-512 with SHA3-512 transcript hash as salt (domain-separated,
|
|
1376
|
+
* consistent with SPD's spd-aead-key-v1 / spd-mac-key-v1 pattern)
|
|
1377
|
+
* - Session nonce mixed into HKDF — prevents cross-session reuse attacks
|
|
1378
|
+
* - CMT-4 key commitment: SHA3-256(sessionKey ∥ sessionNonce) returned so
|
|
1379
|
+
* both sides can verify they derived the same key without revealing it
|
|
1380
|
+
* - timingSafeEqual for all public key comparisons
|
|
1381
|
+
* - All key material zeroed immediately after use
|
|
1382
|
+
*
|
|
1383
|
+
* ## Usage
|
|
1384
|
+
*
|
|
1385
|
+
* ```ts
|
|
1386
|
+
* // ── Server ──────────────────────────────────────────────────────
|
|
1387
|
+
* const server = SPDHandshake.create();
|
|
1388
|
+
* // send to client: { publicKey: server.publicKey, nonce: server.sessionNonce }
|
|
1389
|
+
*
|
|
1390
|
+
* // ── Client (after receiving server publicKey + nonce) ────────────
|
|
1391
|
+
* const client = SPDHandshake.create();
|
|
1392
|
+
* // send to server: { publicKey: client.publicKey, nonce: client.sessionNonce }
|
|
1393
|
+
* const clientResult = client.derive(server.publicKey, server.sessionNonce);
|
|
1394
|
+
*
|
|
1395
|
+
* // ── Server (after receiving client publicKey + nonce) ────────────
|
|
1396
|
+
* const serverResult = server.derive(client.publicKey, client.sessionNonce);
|
|
1397
|
+
*
|
|
1398
|
+
* // Verify both sides derived the same key (compare commitments over the wire)
|
|
1399
|
+
* // clientResult.commitment === serverResult.commitment → true
|
|
1400
|
+
*
|
|
1401
|
+
* // Use session passphrase directly with SPD (already 256-bit entropy)
|
|
1402
|
+
* const spd = new SPD();
|
|
1403
|
+
* spd.setKeyProfile('standard');
|
|
1404
|
+
* await spd.setPassKey(serverResult.sessionKey);
|
|
1405
|
+
*
|
|
1406
|
+
* // Zero the passphrase from memory when done with setup
|
|
1407
|
+
* serverResult.destroy();
|
|
1408
|
+
* ```
|
|
1409
|
+
*/
|
|
1410
|
+
/**
|
|
1411
|
+
* Result of a completed handshake derivation.
|
|
1412
|
+
* Holds the session passphrase and key commitment.
|
|
1413
|
+
* Call `destroy()` once the passphrase has been handed to SPD's `setPassKey`.
|
|
1414
|
+
*/
|
|
1415
|
+
declare class SPDHandshakeResult {
|
|
1416
|
+
/** 64-char hex session passphrase (256 bits). Pass to `spd.setPassKey()`. */
|
|
1417
|
+
readonly sessionKey: string;
|
|
1418
|
+
/**
|
|
1419
|
+
* CMT-4 key commitment: SHA3-256(sessionKeyBytes ∥ sessionNonce).
|
|
1420
|
+
* Base64url-encoded, 32 bytes. Share over the wire so both parties can
|
|
1421
|
+
* verify they derived the same secret without revealing the secret itself.
|
|
1422
|
+
*/
|
|
1423
|
+
readonly commitment: string;
|
|
1424
|
+
private _raw;
|
|
1425
|
+
/** @internal */
|
|
1426
|
+
constructor(raw: Buffer, nonce: Buffer);
|
|
1427
|
+
/** Zero the raw session key bytes from memory. */
|
|
1428
|
+
destroy(): void;
|
|
1429
|
+
}
|
|
1430
|
+
/** An ephemeral X25519 handshake participant. */
|
|
1431
|
+
declare class SPDHandshake {
|
|
1432
|
+
/**
|
|
1433
|
+
* Base64url-encoded X25519 public key (32 bytes).
|
|
1434
|
+
* Transmit this to the other party.
|
|
1435
|
+
*/
|
|
1436
|
+
readonly publicKey: string;
|
|
1437
|
+
/**
|
|
1438
|
+
* Cryptographically random session nonce (32 bytes, base64url).
|
|
1439
|
+
* Transmit this alongside `publicKey`. Mixed into HKDF to prevent
|
|
1440
|
+
* cross-session key reuse even if the same ephemeral keypair were
|
|
1441
|
+
* somehow reused.
|
|
1442
|
+
*/
|
|
1443
|
+
readonly sessionNonce: string;
|
|
1444
|
+
private _blindedPriv;
|
|
1445
|
+
private _privMask;
|
|
1446
|
+
private _nonceRaw;
|
|
1447
|
+
private constructor();
|
|
1448
|
+
/**
|
|
1449
|
+
* Create a new ephemeral participant with a freshly generated X25519 keypair
|
|
1450
|
+
* and a random session nonce.
|
|
1451
|
+
*/
|
|
1452
|
+
static create(): SPDHandshake;
|
|
1453
|
+
/**
|
|
1454
|
+
* Derive the shared session key from the other party's public key and nonce.
|
|
1455
|
+
*
|
|
1456
|
+
* Both parties must call `derive()` with each other's `publicKey` and
|
|
1457
|
+
* `sessionNonce`. The resulting `SPDHandshakeResult.commitment` values will
|
|
1458
|
+
* match if and only if both sides derived the same key.
|
|
1459
|
+
*
|
|
1460
|
+
* @param theirPublicKey The other party's `publicKey` string.
|
|
1461
|
+
* @param theirSessionNonce The other party's `sessionNonce` string.
|
|
1462
|
+
* @returns `SPDHandshakeResult` containing the session passphrase and
|
|
1463
|
+
* CMT-4 key commitment. Call `.destroy()` after handing the
|
|
1464
|
+
* passphrase to `spd.setPassKey()`.
|
|
1465
|
+
* @throws If `derive()` has already been called on this instance.
|
|
1466
|
+
* @throws If the public key is malformed or the low-order point check fails.
|
|
1467
|
+
*/
|
|
1468
|
+
derive(theirPublicKey: string, theirSessionNonce: string): SPDHandshakeResult;
|
|
1469
|
+
/**
|
|
1470
|
+
* Zero and release all key material.
|
|
1471
|
+
* Called automatically by `derive()`. Call manually if you abandon the
|
|
1472
|
+
* handshake without completing it.
|
|
1473
|
+
*/
|
|
1474
|
+
destroy(): void;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
export { ARGON2_MEMORY_HIGH, ARGON2_MEMORY_PARANOID, ARGON2_TIME_HIGH, ARGON2_TIME_PARANOID, type DataInput, type EncryptedDataEntry, type EncryptedSaltResult, type HashAlgorithm, type PBKResult, type PQCKey, type PQCKeyResult, SPD, type SPDBenchmarkResult, type SPDChunkManifest, type SPDClientConnectOptions, type SPDClientHandshake, type SPDDiffResult, type SPDGetEntryResult, SPDHandshake, SPDHandshakeResult, type SPDIndexEntry, type SPDInspectResult, type SPDKeyProfile, type SPDKeyProvider, SPDLegacy, type SPDLegacyPayload, type SPDLogEvent, type SPDMergeOptions, type SPDPayload, type SPDRepairResult, type SPDServerIdentity, type SPDSession, SPDShamir, type SPDShamirShare, type SPDSigningKeyPair, type SPDSnapshot, SPDTransport, SPDVault, type SPDVerifyResult, SPDWriter, type SPDWriterOptions, SPDLegacy as SPD_LEG, SPDVault as SPD_Vault, type SerializedDataEntry, type SerializedWrappedPayload, type SupportedDataType, type SupportedValue, type TypedArray, type WrappedPayload };
|
package/index.d.ts
CHANGED
|
@@ -1366,4 +1366,112 @@ declare class SPDShamir {
|
|
|
1366
1366
|
static decodeShare(encoded: string): SPDShamirShare;
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
1369
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* SPDHandshake — Ephemeral X25519 ECDH key agreement for SPD sessions.
|
|
1371
|
+
*
|
|
1372
|
+
* Aligns with SPD v29 security model:
|
|
1373
|
+
* - X25519 ECDH ephemeral keypair — perfect forward secrecy
|
|
1374
|
+
* - Private key blinded in memory (XOR mask) between create() and derive()
|
|
1375
|
+
* - HKDF-SHA-512 with SHA3-512 transcript hash as salt (domain-separated,
|
|
1376
|
+
* consistent with SPD's spd-aead-key-v1 / spd-mac-key-v1 pattern)
|
|
1377
|
+
* - Session nonce mixed into HKDF — prevents cross-session reuse attacks
|
|
1378
|
+
* - CMT-4 key commitment: SHA3-256(sessionKey ∥ sessionNonce) returned so
|
|
1379
|
+
* both sides can verify they derived the same key without revealing it
|
|
1380
|
+
* - timingSafeEqual for all public key comparisons
|
|
1381
|
+
* - All key material zeroed immediately after use
|
|
1382
|
+
*
|
|
1383
|
+
* ## Usage
|
|
1384
|
+
*
|
|
1385
|
+
* ```ts
|
|
1386
|
+
* // ── Server ──────────────────────────────────────────────────────
|
|
1387
|
+
* const server = SPDHandshake.create();
|
|
1388
|
+
* // send to client: { publicKey: server.publicKey, nonce: server.sessionNonce }
|
|
1389
|
+
*
|
|
1390
|
+
* // ── Client (after receiving server publicKey + nonce) ────────────
|
|
1391
|
+
* const client = SPDHandshake.create();
|
|
1392
|
+
* // send to server: { publicKey: client.publicKey, nonce: client.sessionNonce }
|
|
1393
|
+
* const clientResult = client.derive(server.publicKey, server.sessionNonce);
|
|
1394
|
+
*
|
|
1395
|
+
* // ── Server (after receiving client publicKey + nonce) ────────────
|
|
1396
|
+
* const serverResult = server.derive(client.publicKey, client.sessionNonce);
|
|
1397
|
+
*
|
|
1398
|
+
* // Verify both sides derived the same key (compare commitments over the wire)
|
|
1399
|
+
* // clientResult.commitment === serverResult.commitment → true
|
|
1400
|
+
*
|
|
1401
|
+
* // Use session passphrase directly with SPD (already 256-bit entropy)
|
|
1402
|
+
* const spd = new SPD();
|
|
1403
|
+
* spd.setKeyProfile('standard');
|
|
1404
|
+
* await spd.setPassKey(serverResult.sessionKey);
|
|
1405
|
+
*
|
|
1406
|
+
* // Zero the passphrase from memory when done with setup
|
|
1407
|
+
* serverResult.destroy();
|
|
1408
|
+
* ```
|
|
1409
|
+
*/
|
|
1410
|
+
/**
|
|
1411
|
+
* Result of a completed handshake derivation.
|
|
1412
|
+
* Holds the session passphrase and key commitment.
|
|
1413
|
+
* Call `destroy()` once the passphrase has been handed to SPD's `setPassKey`.
|
|
1414
|
+
*/
|
|
1415
|
+
declare class SPDHandshakeResult {
|
|
1416
|
+
/** 64-char hex session passphrase (256 bits). Pass to `spd.setPassKey()`. */
|
|
1417
|
+
readonly sessionKey: string;
|
|
1418
|
+
/**
|
|
1419
|
+
* CMT-4 key commitment: SHA3-256(sessionKeyBytes ∥ sessionNonce).
|
|
1420
|
+
* Base64url-encoded, 32 bytes. Share over the wire so both parties can
|
|
1421
|
+
* verify they derived the same secret without revealing the secret itself.
|
|
1422
|
+
*/
|
|
1423
|
+
readonly commitment: string;
|
|
1424
|
+
private _raw;
|
|
1425
|
+
/** @internal */
|
|
1426
|
+
constructor(raw: Buffer, nonce: Buffer);
|
|
1427
|
+
/** Zero the raw session key bytes from memory. */
|
|
1428
|
+
destroy(): void;
|
|
1429
|
+
}
|
|
1430
|
+
/** An ephemeral X25519 handshake participant. */
|
|
1431
|
+
declare class SPDHandshake {
|
|
1432
|
+
/**
|
|
1433
|
+
* Base64url-encoded X25519 public key (32 bytes).
|
|
1434
|
+
* Transmit this to the other party.
|
|
1435
|
+
*/
|
|
1436
|
+
readonly publicKey: string;
|
|
1437
|
+
/**
|
|
1438
|
+
* Cryptographically random session nonce (32 bytes, base64url).
|
|
1439
|
+
* Transmit this alongside `publicKey`. Mixed into HKDF to prevent
|
|
1440
|
+
* cross-session key reuse even if the same ephemeral keypair were
|
|
1441
|
+
* somehow reused.
|
|
1442
|
+
*/
|
|
1443
|
+
readonly sessionNonce: string;
|
|
1444
|
+
private _blindedPriv;
|
|
1445
|
+
private _privMask;
|
|
1446
|
+
private _nonceRaw;
|
|
1447
|
+
private constructor();
|
|
1448
|
+
/**
|
|
1449
|
+
* Create a new ephemeral participant with a freshly generated X25519 keypair
|
|
1450
|
+
* and a random session nonce.
|
|
1451
|
+
*/
|
|
1452
|
+
static create(): SPDHandshake;
|
|
1453
|
+
/**
|
|
1454
|
+
* Derive the shared session key from the other party's public key and nonce.
|
|
1455
|
+
*
|
|
1456
|
+
* Both parties must call `derive()` with each other's `publicKey` and
|
|
1457
|
+
* `sessionNonce`. The resulting `SPDHandshakeResult.commitment` values will
|
|
1458
|
+
* match if and only if both sides derived the same key.
|
|
1459
|
+
*
|
|
1460
|
+
* @param theirPublicKey The other party's `publicKey` string.
|
|
1461
|
+
* @param theirSessionNonce The other party's `sessionNonce` string.
|
|
1462
|
+
* @returns `SPDHandshakeResult` containing the session passphrase and
|
|
1463
|
+
* CMT-4 key commitment. Call `.destroy()` after handing the
|
|
1464
|
+
* passphrase to `spd.setPassKey()`.
|
|
1465
|
+
* @throws If `derive()` has already been called on this instance.
|
|
1466
|
+
* @throws If the public key is malformed or the low-order point check fails.
|
|
1467
|
+
*/
|
|
1468
|
+
derive(theirPublicKey: string, theirSessionNonce: string): SPDHandshakeResult;
|
|
1469
|
+
/**
|
|
1470
|
+
* Zero and release all key material.
|
|
1471
|
+
* Called automatically by `derive()`. Call manually if you abandon the
|
|
1472
|
+
* handshake without completing it.
|
|
1473
|
+
*/
|
|
1474
|
+
destroy(): void;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
export { ARGON2_MEMORY_HIGH, ARGON2_MEMORY_PARANOID, ARGON2_TIME_HIGH, ARGON2_TIME_PARANOID, type DataInput, type EncryptedDataEntry, type EncryptedSaltResult, type HashAlgorithm, type PBKResult, type PQCKey, type PQCKeyResult, SPD, type SPDBenchmarkResult, type SPDChunkManifest, type SPDClientConnectOptions, type SPDClientHandshake, type SPDDiffResult, type SPDGetEntryResult, SPDHandshake, SPDHandshakeResult, type SPDIndexEntry, type SPDInspectResult, type SPDKeyProfile, type SPDKeyProvider, SPDLegacy, type SPDLegacyPayload, type SPDLogEvent, type SPDMergeOptions, type SPDPayload, type SPDRepairResult, type SPDServerIdentity, type SPDSession, SPDShamir, type SPDShamirShare, type SPDSigningKeyPair, type SPDSnapshot, SPDTransport, SPDVault, type SPDVerifyResult, SPDWriter, type SPDWriterOptions, SPDLegacy as SPD_LEG, SPDVault as SPD_Vault, type SerializedDataEntry, type SerializedWrappedPayload, type SupportedDataType, type SupportedValue, type TypedArray, type WrappedPayload };
|