@the9ines/bolt-core 0.6.2 → 0.6.4
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/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/crypto.js +5 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export declare const NONCE_LENGTH = 24;
|
|
|
4
4
|
export declare const PUBLIC_KEY_LENGTH = 32;
|
|
5
5
|
/** X25519 secret key length in bytes */
|
|
6
6
|
export declare const SECRET_KEY_LENGTH = 32;
|
|
7
|
-
/** Default plaintext chunk size in bytes (
|
|
8
|
-
export declare const DEFAULT_CHUNK_SIZE =
|
|
7
|
+
/** Default plaintext chunk size in bytes (64KB) */
|
|
8
|
+
export declare const DEFAULT_CHUNK_SIZE = 65536;
|
|
9
9
|
/** Peer code length in characters */
|
|
10
10
|
export declare const PEER_CODE_LENGTH = 6;
|
|
11
11
|
/** Unambiguous base32 alphabet for peer codes (no 0/O, 1/I/L) */
|
package/dist/constants.js
CHANGED
|
@@ -4,8 +4,8 @@ export const NONCE_LENGTH = 24;
|
|
|
4
4
|
export const PUBLIC_KEY_LENGTH = 32;
|
|
5
5
|
/** X25519 secret key length in bytes */
|
|
6
6
|
export const SECRET_KEY_LENGTH = 32;
|
|
7
|
-
/** Default plaintext chunk size in bytes (
|
|
8
|
-
export const DEFAULT_CHUNK_SIZE =
|
|
7
|
+
/** Default plaintext chunk size in bytes (64KB) */
|
|
8
|
+
export const DEFAULT_CHUNK_SIZE = 65536;
|
|
9
9
|
/** Peer code length in characters */
|
|
10
10
|
export const PEER_CODE_LENGTH = 6;
|
|
11
11
|
/** Unambiguous base32 alphabet for peer codes (no 0/O, 1/I/L) */
|
package/dist/crypto.js
CHANGED
|
@@ -28,11 +28,14 @@ export function sealBoxPayload(plaintext, remotePublicKey, senderSecretKey) {
|
|
|
28
28
|
return wasm.sealBoxPayload(plaintext, remotePublicKey, senderSecretKey);
|
|
29
29
|
const nonce = randomBytes(box.nonceLength);
|
|
30
30
|
const encrypted = box(plaintext, nonce, remotePublicKey, senderSecretKey);
|
|
31
|
-
if (!encrypted)
|
|
31
|
+
if (!encrypted) {
|
|
32
|
+
nonce.fill(0); // Zeroize on error path too
|
|
32
33
|
throw new EncryptionError('Encryption returned null');
|
|
34
|
+
}
|
|
33
35
|
const combined = new Uint8Array(nonce.length + encrypted.length);
|
|
34
36
|
combined.set(nonce);
|
|
35
37
|
combined.set(encrypted, nonce.length);
|
|
38
|
+
nonce.fill(0); // Best-effort nonce zeroization (ENDPOINT-SECURITY-1, F-MED-01)
|
|
36
39
|
return toBase64(combined);
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
@@ -53,6 +56,7 @@ export function openBoxPayload(sealed, senderPublicKey, receiverSecretKey) {
|
|
|
53
56
|
const nonce = data.slice(0, box.nonceLength);
|
|
54
57
|
const ciphertext = data.slice(box.nonceLength);
|
|
55
58
|
const decrypted = box.open(ciphertext, nonce, senderPublicKey, receiverSecretKey);
|
|
59
|
+
nonce.fill(0); // Best-effort nonce zeroization (ENDPOINT-SECURITY-1, F-MED-01)
|
|
56
60
|
if (!decrypted)
|
|
57
61
|
throw new EncryptionError('Decryption failed');
|
|
58
62
|
return decrypted;
|