internxt-crypto 0.0.14 → 1.0.0
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/README.md +44 -72
- package/dist/aes-B8TA-JKq.mjs +49 -0
- package/dist/aes-B8TA-JKq.mjs.map +1 -0
- package/dist/aes-CuW_SPl-.js +67 -0
- package/dist/aes-CuW_SPl-.js.map +1 -0
- package/dist/asymmetric-crypto.d.mts +8 -31
- package/dist/asymmetric-crypto.d.mts.map +1 -1
- package/dist/asymmetric-crypto.d.ts +8 -31
- package/dist/asymmetric-crypto.d.ts.map +1 -1
- package/dist/asymmetric-crypto.js +30 -7
- package/dist/asymmetric-crypto.js.map +1 -0
- package/dist/asymmetric-crypto.mjs +28 -2
- package/dist/asymmetric-crypto.mjs.map +1 -0
- package/dist/constants.d.mts +3 -10
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.d.ts +3 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -17
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +3 -10
- package/dist/constants.mjs.map +1 -1
- package/dist/core-Bj26rNdA.js +227 -0
- package/dist/core-Bj26rNdA.js.map +1 -0
- package/dist/core-pEGygy6S.mjs +173 -0
- package/dist/core-pEGygy6S.mjs.map +1 -0
- package/dist/derive-key.d.mts +1 -74
- package/dist/derive-key.d.mts.map +1 -1
- package/dist/derive-key.d.ts +1 -74
- package/dist/derive-key.d.ts.map +1 -1
- package/dist/derive-key.js +3 -11
- package/dist/derive-key.mjs +2 -2
- package/dist/derive-password.d.mts +22 -0
- package/dist/derive-password.d.mts.map +1 -0
- package/dist/derive-password.d.ts +22 -0
- package/dist/derive-password.d.ts.map +1 -0
- package/dist/derive-password.js +5 -0
- package/dist/derive-password.mjs +3 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js +47 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js.map +1 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs +35 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +1 -0
- package/dist/{deriveKeysFromPassword-BYaiSGKL.js → deriveKeysFromPassword-C7xAGGsh.js} +5 -172
- package/dist/deriveKeysFromPassword-C7xAGGsh.js.map +1 -0
- package/dist/{deriveKeysFromPassword-XIwzErlL.mjs → deriveKeysFromPassword-DXgSvTNC.mjs} +6 -125
- package/dist/deriveKeysFromPassword-DXgSvTNC.mjs.map +1 -0
- package/dist/email-crypto.d.mts +24 -46
- package/dist/email-crypto.d.mts.map +1 -1
- package/dist/email-crypto.d.ts +24 -46
- package/dist/email-crypto.d.ts.map +1 -1
- package/dist/email-crypto.js +121 -12
- package/dist/email-crypto.js.map +1 -0
- package/dist/email-crypto.mjs +115 -2
- package/dist/email-crypto.mjs.map +1 -0
- package/dist/email-search.d.mts.map +1 -1
- package/dist/email-search.d.ts.map +1 -1
- package/dist/email-search.js +25 -597
- package/dist/email-search.mjs +2 -573
- package/dist/{emailEncryptionKey-B9xHw1h_.mjs → emailEncryptionKey-BtSPYd9M.mjs} +22 -45
- package/dist/emailEncryptionKey-BtSPYd9M.mjs.map +1 -0
- package/dist/{emailEncryptionKey-CQNe5W_T.js → emailEncryptionKey-C4X1Bwy4.js} +22 -45
- package/dist/emailEncryptionKey-C4X1Bwy4.js.map +1 -0
- package/dist/{genID-3Er5IowC.mjs → genID-D08K7JPr.mjs} +4 -40
- package/dist/genID-D08K7JPr.mjs.map +1 -0
- package/dist/{genID-YJSl3YhL.js → genID-cWOPmspk.js} +2 -50
- package/dist/genID-cWOPmspk.js.map +1 -0
- package/dist/hash.d.mts +24 -36
- package/dist/hash.d.mts.map +1 -1
- package/dist/hash.d.ts +24 -36
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +88 -10
- package/dist/hash.js.map +1 -0
- package/dist/hash.mjs +82 -2
- package/dist/hash.mjs.map +1 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -79
- package/dist/index.mjs +13 -11
- package/dist/keystore-crypto.d.mts +6 -6
- package/dist/keystore-crypto.d.mts.map +1 -1
- package/dist/keystore-crypto.d.ts +6 -6
- package/dist/keystore-crypto.d.ts.map +1 -1
- package/dist/keystore-crypto.js +1 -1
- package/dist/keystore-crypto.mjs +1 -1
- package/dist/post-quantum-crypto.js +49 -4
- package/dist/post-quantum-crypto.js.map +1 -0
- package/dist/post-quantum-crypto.mjs +46 -2
- package/dist/post-quantum-crypto.mjs.map +1 -0
- package/dist/search-B9YM3XAA.mjs +587 -0
- package/dist/search-B9YM3XAA.mjs.map +1 -0
- package/dist/search-DUTm4-rN.js +731 -0
- package/dist/search-DUTm4-rN.js.map +1 -0
- package/dist/symmetric-crypto.d.mts +11 -40
- package/dist/symmetric-crypto.d.mts.map +1 -1
- package/dist/symmetric-crypto.d.ts +11 -40
- package/dist/symmetric-crypto.d.ts.map +1 -1
- package/dist/symmetric-crypto.js +2 -6
- package/dist/symmetric-crypto.mjs +2 -2
- package/dist/types.d.mts +13 -40
- package/dist/types.d.mts.map +1 -1
- package/dist/types.d.ts +13 -40
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.d.mts +1 -19
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.d.ts +1 -19
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -3
- package/dist/utils.mjs +2 -2
- package/dist/xwing-CQmQX6hn.mjs +16 -0
- package/dist/xwing-CQmQX6hn.mjs.map +1 -0
- package/dist/xwing-iRWVRtNE.js +34 -0
- package/dist/xwing-iRWVRtNE.js.map +1 -0
- package/package.json +3 -2
- package/dist/aes-DCb9dJqb.mjs +0 -161
- package/dist/aes-DCb9dJqb.mjs.map +0 -1
- package/dist/aes-DQo1MyCz.js +0 -203
- package/dist/aes-DQo1MyCz.js.map +0 -1
- package/dist/deriveKeysFromPassword-BYaiSGKL.js.map +0 -1
- package/dist/deriveKeysFromPassword-XIwzErlL.mjs.map +0 -1
- package/dist/email-search.js.map +0 -1
- package/dist/email-search.mjs.map +0 -1
- package/dist/emailEncryptionKey-B9xHw1h_.mjs.map +0 -1
- package/dist/emailEncryptionKey-CQNe5W_T.js.map +0 -1
- package/dist/emailKeys-C0KhtfNP.js +0 -572
- package/dist/emailKeys-C0KhtfNP.js.map +0 -1
- package/dist/emailKeys-D4lp9NRv.mjs +0 -488
- package/dist/emailKeys-D4lp9NRv.mjs.map +0 -1
- package/dist/genID-3Er5IowC.mjs.map +0 -1
- package/dist/genID-YJSl3YhL.js.map +0 -1
- package/dist/keys-BfcaiAOv.mjs +0 -90
- package/dist/keys-BfcaiAOv.mjs.map +0 -1
- package/dist/keys-CinT7kEY.js +0 -125
- package/dist/keys-CinT7kEY.js.map +0 -1
- package/dist/kyber768-SXnIo-Nw.mjs +0 -47
- package/dist/kyber768-SXnIo-Nw.mjs.map +0 -1
- package/dist/kyber768-WUVc2fIR.js +0 -65
- package/dist/kyber768-WUVc2fIR.js.map +0 -1
- package/dist/mac-BMb1F0dN.js +0 -170
- package/dist/mac-BMb1F0dN.js.map +0 -1
- package/dist/mac-ZpRlx8Fs.mjs +0 -116
- package/dist/mac-ZpRlx8Fs.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -43,16 +43,15 @@ Builds the app for production to the `build` folder.
|
|
|
43
43
|
|
|
44
44
|
### Key Management
|
|
45
45
|
|
|
46
|
-
- **`derive-key`** - Key derivation functions for deriving cryptographic keys from
|
|
46
|
+
- **`derive-key`** - Key derivation functions for deriving cryptographic keys from base key (BLAKE3 in KDF mode)
|
|
47
|
+
- **`derive-password`** - Key derivation functions for deriving cryptographic keys from passwords (ARGON2)
|
|
47
48
|
- **`key-wrapper`** - Key wrapping and unwrapping functions for secure symmetric key storage and transport
|
|
48
49
|
- **`keystore-crypto`** - Keystore cryptographic operations for securing user's keys
|
|
49
|
-
- **`keystore-service`** - Keystore management service for communicating with the server
|
|
50
50
|
|
|
51
51
|
### Email Security
|
|
52
52
|
|
|
53
53
|
- **`email-crypto`** - End-to-end email encryption and decryption using hybrid cryptography and password-protection
|
|
54
54
|
- **`email-search`** - Email indexing on the client side to enable search while preserving privacy
|
|
55
|
-
- **`email-service`** - Email management service for communicating with the server
|
|
56
55
|
|
|
57
56
|
### Infrastructure
|
|
58
57
|
|
|
@@ -65,109 +64,82 @@ Builds the app for production to the `build` folder.
|
|
|
65
64
|
|
|
66
65
|
```typescript
|
|
67
66
|
import {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
keystoreService,
|
|
74
|
-
deriveKey,
|
|
75
|
-
hash,
|
|
67
|
+
generateEccKeys,
|
|
68
|
+
deriveSecretKey,
|
|
69
|
+
UTF8ToUint8,
|
|
70
|
+
genSymmetricKey,
|
|
71
|
+
encryptSymmetrically,
|
|
76
72
|
} from 'internxt-crypto';
|
|
77
73
|
|
|
78
74
|
// Asymmetric encryption
|
|
79
|
-
const keysAlice = await
|
|
80
|
-
const keysBob = await
|
|
81
|
-
const resultAlice = await
|
|
82
|
-
const resultBob = await
|
|
75
|
+
const keysAlice = await generateEccKeys();
|
|
76
|
+
const keysBob = await generateEccKeys();
|
|
77
|
+
const resultAlice = await deriveSecretKey(keysBob.publicKey, keysAlice.privateKey);
|
|
78
|
+
const resultBob = await deriveSecretKey(keysAlice.publicKey, keysBob.privateKey);
|
|
83
79
|
expect(resultAlice).toStrictEqual(resultBob);
|
|
84
80
|
|
|
85
81
|
// Symmetric encryption
|
|
86
|
-
const data =
|
|
82
|
+
const data = UTF8ToUint8('Sensitive information to encrypt'); // convert to Uint8Array
|
|
87
83
|
const additionalData = 'Additional non-secret data';
|
|
88
|
-
const key =
|
|
89
|
-
const ciphertext: Uint8Array = await
|
|
90
|
-
const plainText = await
|
|
84
|
+
const key = genSymmetricKey();
|
|
85
|
+
const ciphertext: Uint8Array = await encryptSymmetrically(key, data, additionalData);
|
|
86
|
+
const plainText = await decryptSymmetrically(encryptionKey, ciphertext, additionalData);
|
|
91
87
|
expect(data).toStrictEqual(plainText);
|
|
92
88
|
|
|
93
89
|
// Post qunatum cryptography
|
|
94
|
-
const keys =
|
|
95
|
-
const { cipherText, sharedSecret } =
|
|
96
|
-
const result =
|
|
90
|
+
const keys = generateKyberKeys();
|
|
91
|
+
const { cipherText, sharedSecret } = encapsulateKyber(keys.publicKey);
|
|
92
|
+
const result = decapsulateKyber(cipherText, keys.secretKey);
|
|
97
93
|
expect(result).toStrictEqual(sharedSecret);
|
|
98
94
|
|
|
99
95
|
// Hash
|
|
100
|
-
const result =
|
|
96
|
+
const result = hashData(['']);
|
|
101
97
|
const expectedResult = 'af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262';
|
|
102
98
|
expect(result).toStrictEqual(expectedResult);
|
|
103
99
|
|
|
104
100
|
// Key derivation
|
|
105
101
|
const context = 'BLAKE3 2019-12-27 16:29:52 test vectors context';
|
|
106
|
-
const baseKey =
|
|
107
|
-
const key =
|
|
108
|
-
expect(key).instanceOf(CryptoKey);
|
|
102
|
+
const baseKey = genSymmetricKey();
|
|
103
|
+
const key = deriveSymmetricKeyFromContext(context, baseKey);
|
|
109
104
|
|
|
105
|
+
// Key derivation from password
|
|
110
106
|
const password = 'your password';
|
|
111
|
-
const {
|
|
112
|
-
const result = await deriveKey.verifyKeyFromPasswordHex(password, saltHex, keyHex);
|
|
113
|
-
expect(result).toBe(true);
|
|
107
|
+
const { key, salt } = await getKeyFromPassword(password);
|
|
114
108
|
|
|
115
109
|
// Hybrid email encryption
|
|
116
|
-
|
|
117
|
-
const emailBody: EmailBody = {
|
|
110
|
+
const email: EmailBody = {
|
|
118
111
|
text: 'email text',
|
|
119
|
-
|
|
120
|
-
labels: ['label 1', 'label2'],
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const userAlice = {
|
|
124
|
-
email: 'alice email',
|
|
125
|
-
name: 'alice',
|
|
112
|
+
subject: 'email subject',
|
|
126
113
|
};
|
|
127
|
-
|
|
128
|
-
const
|
|
114
|
+
const { secretKey: bobPrivateKeys, publicKey: bobPublicKeys } = await generateEmailKeys();
|
|
115
|
+
const bobWithPublicKeys = {
|
|
129
116
|
email: 'bob email',
|
|
130
|
-
|
|
117
|
+
publicHybridKey: bobPublicKeys,
|
|
131
118
|
};
|
|
132
|
-
const
|
|
133
|
-
const
|
|
119
|
+
const encryptedEmail = await encryptEmailHybrid(email, bobWithPublicKeys);
|
|
120
|
+
const decryptedEmail = await decryptEmailHybrid(encryptedEmail, bobPrivateKeys);
|
|
134
121
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const emailParams: EmailPublicParameters = {
|
|
140
|
-
labels: ['label 1', 'label2'],
|
|
141
|
-
createdAt: '2025-06-14T08:11:22.000Z',
|
|
142
|
-
subject: 'email subject',
|
|
143
|
-
sender: userAlice,
|
|
144
|
-
recipient: userBob,
|
|
145
|
-
replyToEmailID: generateUuid(),
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const email: Email = {
|
|
149
|
-
id: generateUuid(),
|
|
150
|
-
params: emailParams,
|
|
151
|
-
body: emailBody,
|
|
152
|
-
};
|
|
153
|
-
const encryptedEmail = await emailCrypto.encryptEmailHybrid(email, bobPublicKeys, alicePrivateKeys);
|
|
154
|
-
const decryptedEmail = await emailCrypto.decryptEmailHybrid(encryptedEmail, alicePublicKeys, bobPrivateKeys);
|
|
155
|
-
expect(decryptedEmail).toStrictEqual(email);
|
|
122
|
+
expect(encryptedEmail.encEmailBody.encSubject).not.toBe(email.subject);
|
|
123
|
+
expect(decryptedEmailBody).toStrictEqual(email);
|
|
156
124
|
|
|
157
125
|
|
|
158
126
|
// password-protected email
|
|
159
127
|
const sharedSecret = 'secret shared between Alice and Bob';
|
|
160
|
-
const encryptedEmail = await
|
|
161
|
-
const decryptedEmail = await
|
|
128
|
+
const encryptedEmail = await createPwdProtectedEmail(email, sharedSecret);
|
|
129
|
+
const decryptedEmail = await decryptPwdProtectedEmail(encryptedEmail, sharedSecret);
|
|
162
130
|
expect(decryptedEmail).toStrictEqual(email);
|
|
163
131
|
|
|
164
132
|
// keystore
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const { encryptionKeystore, recoveryKeystore, recoveryCodes } = await createEncryptionAndRecoveryKeystores(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
const userEmail = 'user email';
|
|
134
|
+
const secretKey = genSymmetricKey();
|
|
135
|
+
const { encryptionKeystore, recoveryKeystore, recoveryCodes } = await createEncryptionAndRecoveryKeystores(
|
|
136
|
+
userEmail,
|
|
137
|
+
secretKey,
|
|
138
|
+
);
|
|
139
|
+
const resultEnc = await openEncryptionKeystore(encryptionKeystore, secretKey);
|
|
140
|
+
const resultRec = await openRecoveryKeystore(recoveryCodes, recoveryKeystore);
|
|
141
|
+
|
|
142
|
+
expect(resultEnc).toStrictEqual(resultRec);
|
|
171
143
|
|
|
172
144
|
// Email storage and search
|
|
173
145
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AES_KEY_BYTE_LENGTH, IV_LEN_BYTES } from "./constants.mjs";
|
|
2
|
+
import { concatBytes, randomBytes } from "@noble/hashes/utils.js";
|
|
3
|
+
import { gcm } from "@noble/ciphers/webcrypto.js";
|
|
4
|
+
|
|
5
|
+
//#region src/symmetric-crypto/aes.ts
|
|
6
|
+
/**
|
|
7
|
+
* Symmetrically encrypts the message
|
|
8
|
+
*
|
|
9
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
10
|
+
* @param message - The message to encrypt
|
|
11
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
12
|
+
* @returns The resulting ciphertext.
|
|
13
|
+
*/
|
|
14
|
+
async function encryptSymmetrically(encryptionKey, message, aux) {
|
|
15
|
+
try {
|
|
16
|
+
const iv = randomBytes(IV_LEN_BYTES);
|
|
17
|
+
return concatBytes(await gcm(encryptionKey, iv, aux).encrypt(message), iv);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error("Failed to encrypt symmetrically", { cause: error });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decryps symmetrically encrypted message
|
|
24
|
+
*
|
|
25
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
26
|
+
* @param encryptedMessage - The ciphertext
|
|
27
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
28
|
+
* @returns The resulting ciphertext.
|
|
29
|
+
*/
|
|
30
|
+
async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
|
|
31
|
+
try {
|
|
32
|
+
const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);
|
|
33
|
+
return await gcm(encryptionKey, encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES), aux).decrypt(ciphertext);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error("Failed to decrypt symmetrically", { cause: error });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generates symmetric key as Uint8Array
|
|
40
|
+
*
|
|
41
|
+
* @returns The generated Uint8Array.
|
|
42
|
+
*/
|
|
43
|
+
function genSymmetricKey() {
|
|
44
|
+
return randomBytes(AES_KEY_BYTE_LENGTH);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { encryptSymmetrically as n, genSymmetricKey as r, decryptSymmetrically as t };
|
|
49
|
+
//# sourceMappingURL=aes-B8TA-JKq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes-B8TA-JKq.mjs","names":["aeadCipher"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,KAAK,YAAY,aAAa;AAEpC,SAAO,YADY,MAAMA,IAAW,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAAS,aAAa;AAGpF,SADe,MAAMA,IAAW,eADrB,iBAAiB,MAAM,iBAAiB,SAAS,aAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,QAAO,YAAY,oBAAoB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-EbLFQX5m.js');
|
|
2
|
+
const require_constants = require('./constants.js');
|
|
3
|
+
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
4
|
+
let _noble_ciphers_webcrypto_js = require("@noble/ciphers/webcrypto.js");
|
|
5
|
+
|
|
6
|
+
//#region src/symmetric-crypto/aes.ts
|
|
7
|
+
/**
|
|
8
|
+
* Symmetrically encrypts the message
|
|
9
|
+
*
|
|
10
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
11
|
+
* @param message - The message to encrypt
|
|
12
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
13
|
+
* @returns The resulting ciphertext.
|
|
14
|
+
*/
|
|
15
|
+
async function encryptSymmetrically(encryptionKey, message, aux) {
|
|
16
|
+
try {
|
|
17
|
+
const iv = (0, _noble_hashes_utils_js.randomBytes)(require_constants.IV_LEN_BYTES);
|
|
18
|
+
return (0, _noble_hashes_utils_js.concatBytes)(await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, iv, aux).encrypt(message), iv);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error("Failed to encrypt symmetrically", { cause: error });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decryps symmetrically encrypted message
|
|
25
|
+
*
|
|
26
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
27
|
+
* @param encryptedMessage - The ciphertext
|
|
28
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
29
|
+
* @returns The resulting ciphertext.
|
|
30
|
+
*/
|
|
31
|
+
async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
|
|
32
|
+
try {
|
|
33
|
+
const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - require_constants.IV_LEN_BYTES);
|
|
34
|
+
return await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, encryptedMessage.slice(encryptedMessage.length - require_constants.IV_LEN_BYTES), aux).decrypt(ciphertext);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error("Failed to decrypt symmetrically", { cause: error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates symmetric key as Uint8Array
|
|
41
|
+
*
|
|
42
|
+
* @returns The generated Uint8Array.
|
|
43
|
+
*/
|
|
44
|
+
function genSymmetricKey() {
|
|
45
|
+
return (0, _noble_hashes_utils_js.randomBytes)(require_constants.AES_KEY_BYTE_LENGTH);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
Object.defineProperty(exports, 'decryptSymmetrically', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return decryptSymmetrically;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'encryptSymmetrically', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return encryptSymmetrically;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, 'genSymmetricKey', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return genSymmetricKey;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=aes-CuW_SPl-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes-CuW_SPl-.js","names":["IV_LEN_BYTES","AES_KEY_BYTE_LENGTH"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,6CAAiBA,+BAAa;AAEpC,iDADmB,2CAAiB,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAASA,+BAAa;AAGpF,SADe,2CAAiB,eADrB,iBAAiB,MAAM,iBAAiB,SAASA,+BAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,gDAAmBC,sCAAoB"}
|
|
@@ -2,43 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Derives secret key from the other user's public key and own private key
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
5
|
+
* @param aliceSecretKey - The secret key of the user deriving the shared secret key
|
|
6
|
+
* @param bobPublicKey - The public key of the other user
|
|
7
7
|
* @returns The derived secret key bits
|
|
8
8
|
*/
|
|
9
|
-
declare function deriveSecretKey(
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/asymmetric-crypto/keys.d.ts
|
|
9
|
+
declare function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array>;
|
|
12
10
|
/**
|
|
13
11
|
* Generates elliptic curve key pair
|
|
14
12
|
*
|
|
15
13
|
* @returns The generated key pair
|
|
16
14
|
*/
|
|
17
|
-
declare function generateEccKeys(): Promise<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @returns The Uint8Array representation of the public key
|
|
22
|
-
*/
|
|
23
|
-
declare function exportPublicKey(key: CryptoKey): Promise<Uint8Array>;
|
|
24
|
-
/**
|
|
25
|
-
* Converts public key in SubjectPublicKeyInfo format (RFC 5280) to CryptoKey
|
|
26
|
-
*
|
|
27
|
-
* @returns The CryptoKey representation of the public key
|
|
28
|
-
*/
|
|
29
|
-
declare function importPublicKey(spkiKeyData: Uint8Array): Promise<CryptoKey>;
|
|
30
|
-
/**
|
|
31
|
-
* Converts private key in CryptoKey to PKCS #8 format (RFC 5208)
|
|
32
|
-
*
|
|
33
|
-
* @returns The Uint8Array representation of the private key
|
|
34
|
-
*/
|
|
35
|
-
declare function exportPrivateKey(key: CryptoKey): Promise<Uint8Array>;
|
|
36
|
-
/**
|
|
37
|
-
* Converts private key in PKCS #8 format (RFC 5208) to CryptoKey
|
|
38
|
-
*
|
|
39
|
-
* @returns The CryptoKey representation of the private key
|
|
40
|
-
*/
|
|
41
|
-
declare function importPrivateKey(pkcs8KeyData: Uint8Array): Promise<CryptoKey>;
|
|
15
|
+
declare function generateEccKeys(): Promise<{
|
|
16
|
+
secretKey: Uint8Array;
|
|
17
|
+
publicKey: Uint8Array;
|
|
18
|
+
}>;
|
|
42
19
|
//#endregion
|
|
43
|
-
export { deriveSecretKey,
|
|
20
|
+
export { deriveSecretKey, generateEccKeys };
|
|
44
21
|
//# sourceMappingURL=asymmetric-crypto.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asymmetric-crypto.d.mts","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.d.mts","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"mappings":";;AASA;;;;;;iBAAsB,eAAA,CAAgB,cAAA,EAAgB,UAAA,EAAY,YAAA,EAAc,UAAA,GAAa,OAAA,CAAQ,UAAA;;;;;;iBAa/E,eAAA,CAAA,GAAmB,OAAA;EAAU,SAAA,EAAW,UAAA;EAAY,SAAA,EAAW,UAAA;AAAA"}
|
|
@@ -2,43 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Derives secret key from the other user's public key and own private key
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
5
|
+
* @param aliceSecretKey - The secret key of the user deriving the shared secret key
|
|
6
|
+
* @param bobPublicKey - The public key of the other user
|
|
7
7
|
* @returns The derived secret key bits
|
|
8
8
|
*/
|
|
9
|
-
declare function deriveSecretKey(
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/asymmetric-crypto/keys.d.ts
|
|
9
|
+
declare function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array>;
|
|
12
10
|
/**
|
|
13
11
|
* Generates elliptic curve key pair
|
|
14
12
|
*
|
|
15
13
|
* @returns The generated key pair
|
|
16
14
|
*/
|
|
17
|
-
declare function generateEccKeys(): Promise<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @returns The Uint8Array representation of the public key
|
|
22
|
-
*/
|
|
23
|
-
declare function exportPublicKey(key: CryptoKey): Promise<Uint8Array>;
|
|
24
|
-
/**
|
|
25
|
-
* Converts public key in SubjectPublicKeyInfo format (RFC 5280) to CryptoKey
|
|
26
|
-
*
|
|
27
|
-
* @returns The CryptoKey representation of the public key
|
|
28
|
-
*/
|
|
29
|
-
declare function importPublicKey(spkiKeyData: Uint8Array): Promise<CryptoKey>;
|
|
30
|
-
/**
|
|
31
|
-
* Converts private key in CryptoKey to PKCS #8 format (RFC 5208)
|
|
32
|
-
*
|
|
33
|
-
* @returns The Uint8Array representation of the private key
|
|
34
|
-
*/
|
|
35
|
-
declare function exportPrivateKey(key: CryptoKey): Promise<Uint8Array>;
|
|
36
|
-
/**
|
|
37
|
-
* Converts private key in PKCS #8 format (RFC 5208) to CryptoKey
|
|
38
|
-
*
|
|
39
|
-
* @returns The CryptoKey representation of the private key
|
|
40
|
-
*/
|
|
41
|
-
declare function importPrivateKey(pkcs8KeyData: Uint8Array): Promise<CryptoKey>;
|
|
15
|
+
declare function generateEccKeys(): Promise<{
|
|
16
|
+
secretKey: Uint8Array;
|
|
17
|
+
publicKey: Uint8Array;
|
|
18
|
+
}>;
|
|
42
19
|
//#endregion
|
|
43
|
-
export { deriveSecretKey,
|
|
20
|
+
export { deriveSecretKey, generateEccKeys };
|
|
44
21
|
//# sourceMappingURL=asymmetric-crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asymmetric-crypto.d.ts","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.d.ts","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"mappings":";;AASA;;;;;;iBAAsB,eAAA,CAAgB,cAAA,EAAgB,UAAA,EAAY,YAAA,EAAc,UAAA,GAAa,OAAA,CAAQ,UAAA;;;;;;iBAa/E,eAAA,CAAA,GAAmB,OAAA;EAAU,SAAA,EAAW,UAAA;EAAY,SAAA,EAAW,UAAA;AAAA"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_chunk = require('./chunk-EbLFQX5m.js');
|
|
3
|
+
let _noble_curves_webcrypto_js = require("@noble/curves/webcrypto.js");
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
//#region src/asymmetric-crypto/ellipticCurve.ts
|
|
6
|
+
/**
|
|
7
|
+
* Derives secret key from the other user's public key and own private key
|
|
8
|
+
*
|
|
9
|
+
* @param aliceSecretKey - The secret key of the user deriving the shared secret key
|
|
10
|
+
* @param bobPublicKey - The public key of the other user
|
|
11
|
+
* @returns The derived secret key bits
|
|
12
|
+
*/
|
|
13
|
+
async function deriveSecretKey(aliceSecretKey, bobPublicKey) {
|
|
14
|
+
try {
|
|
15
|
+
return await _noble_curves_webcrypto_js.x25519.getSharedSecret(aliceSecretKey, bobPublicKey);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
throw new Error("Failed to derive elliptic curve secret key", { cause: error });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generates elliptic curve key pair
|
|
22
|
+
*
|
|
23
|
+
* @returns The generated key pair
|
|
24
|
+
*/
|
|
25
|
+
async function generateEccKeys() {
|
|
26
|
+
return _noble_curves_webcrypto_js.x25519.keygen();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.deriveSecretKey = deriveSecretKey;
|
|
31
|
+
exports.generateEccKeys = generateEccKeys;
|
|
32
|
+
//# sourceMappingURL=asymmetric-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.js","names":["x25519"],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":";;;;;;;;;;;;AASA,eAAsB,gBAAgB,gBAA4B,cAA+C;AAC/G,KAAI;AACF,SAAO,MAAMA,kCAAO,gBAAgB,gBAAgB,aAAa;UAC1D,OAAO;AACd,QAAM,IAAI,MAAM,8CAA8C,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASnF,eAAsB,kBAA6E;AACjG,QAAOA,kCAAO,QAAQ"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x25519 } from "@noble/curves/webcrypto.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/asymmetric-crypto/ellipticCurve.ts
|
|
4
|
+
/**
|
|
5
|
+
* Derives secret key from the other user's public key and own private key
|
|
6
|
+
*
|
|
7
|
+
* @param aliceSecretKey - The secret key of the user deriving the shared secret key
|
|
8
|
+
* @param bobPublicKey - The public key of the other user
|
|
9
|
+
* @returns The derived secret key bits
|
|
10
|
+
*/
|
|
11
|
+
async function deriveSecretKey(aliceSecretKey, bobPublicKey) {
|
|
12
|
+
try {
|
|
13
|
+
return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new Error("Failed to derive elliptic curve secret key", { cause: error });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates elliptic curve key pair
|
|
20
|
+
*
|
|
21
|
+
* @returns The generated key pair
|
|
22
|
+
*/
|
|
23
|
+
async function generateEccKeys() {
|
|
24
|
+
return x25519.keygen();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { deriveSecretKey, generateEccKeys };
|
|
29
|
+
//# sourceMappingURL=asymmetric-crypto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.mjs","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,gBAAgB,gBAA4B,cAA+C;AAC/G,KAAI;AACF,SAAO,MAAM,OAAO,gBAAgB,gBAAgB,aAAa;UAC1D,OAAO;AACd,QAAM,IAAI,MAAM,8CAA8C,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASnF,eAAsB,kBAA6E;AACjG,QAAO,OAAO,QAAQ"}
|
package/dist/constants.d.mts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
//#region src/constants.d.ts
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const AUX_BYTE_LEN = 16;
|
|
5
|
-
declare const IV_LEN_BYTES = 16;
|
|
6
|
-
declare const KEY_WRAPPING_ALGORITHM = "AES-KW";
|
|
7
|
-
declare const KEY_FORMAT = "raw";
|
|
8
|
-
declare const CONTEXT_WRAPPING = "CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets";
|
|
9
|
-
declare const ECC_ALGORITHM = "X25519";
|
|
2
|
+
declare const AES_KEY_BYTE_LENGTH = 32;
|
|
3
|
+
declare const IV_LEN_BYTES = 12;
|
|
10
4
|
declare const CONTEXT_ENC_KEYSTORE = "CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore";
|
|
11
5
|
declare const CONTEXT_RECOVERY = "CRYPTO library 2025-07-30 16:20:00 key for account recovery";
|
|
12
6
|
declare const CONTEXT_INDEX = "CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices";
|
|
@@ -19,7 +13,6 @@ declare const ARGON2ID_OUTPUT_BYTE_LENGTH = 32;
|
|
|
19
13
|
declare const KYBER768_PUBLIC_KEY_LENGTH = 1184;
|
|
20
14
|
declare const KYBER768_SECRET_KEY_LENGTH = 2400;
|
|
21
15
|
declare const KYBER_SEED_LENGTH = 64;
|
|
22
|
-
declare const HASH_BIT_LEN = 256;
|
|
23
16
|
declare const MAX_CACHE_SIZE = 600000000;
|
|
24
17
|
declare const MAX_EMAIL_PER_BATCH = 100;
|
|
25
18
|
declare const DB_LABEL = "email";
|
|
@@ -29,5 +22,5 @@ declare const XWING_SECRET_KEY_LENGTH = 32;
|
|
|
29
22
|
declare const XWING_SEED_BYTE_LENGTH = 32;
|
|
30
23
|
declare const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;
|
|
31
24
|
//#endregion
|
|
32
|
-
export {
|
|
25
|
+
export { AES_KEY_BYTE_LENGTH, ARGON2ID_ITERATIONS, ARGON2ID_MEMORY_SIZE, ARGON2ID_OUTPUT_BYTE_LENGTH, ARGON2ID_PARALLELISM, ARGON2ID_SALT_BYTE_LENGTH, CONTEXT_DERIVE, CONTEXT_ENC_KEYSTORE, CONTEXT_INDEX, CONTEXT_RECOVERY, DB_LABEL, DB_VERSION, IV_LEN_BYTES, KYBER768_PUBLIC_KEY_LENGTH, KYBER768_SECRET_KEY_LENGTH, KYBER_SEED_LENGTH, MAX_CACHE_SIZE, MAX_EMAIL_PER_BATCH, XWING_CIPHERTEXT_BYTE_LENGTH, XWING_PUBLIC_KEY_LENGTH, XWING_SECRET_KEY_LENGTH, XWING_SEED_BYTE_LENGTH };
|
|
33
26
|
//# sourceMappingURL=constants.d.mts.map
|
package/dist/constants.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"mappings":";cAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"mappings":";cAAa,mBAAA;AAAA,cACA,YAAA;AAAA,cAEA,oBAAA;AAAA,cACA,gBAAA;AAAA,cACA,aAAA;AAAA,cACA,cAAA;AAAA,cAGA,oBAAA;AAAA,cACA,mBAAA;AAAA,cACA,oBAAA;AAAA,cACA,yBAAA;AAAA,cACA,2BAAA;AAAA,cAEA,0BAAA;AAAA,cACA,0BAAA;AAAA,cACA,iBAAA;AAAA,cAEA,cAAA;AAAA,cACA,mBAAA;AAAA,cACA,QAAA;AAAA,cACA,UAAA;AAAA,cAEA,uBAAA;AAAA,cACA,uBAAA;AAAA,cACA,sBAAA;AAAA,cACA,4BAAA"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
//#region src/constants.d.ts
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const AUX_BYTE_LEN = 16;
|
|
5
|
-
declare const IV_LEN_BYTES = 16;
|
|
6
|
-
declare const KEY_WRAPPING_ALGORITHM = "AES-KW";
|
|
7
|
-
declare const KEY_FORMAT = "raw";
|
|
8
|
-
declare const CONTEXT_WRAPPING = "CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets";
|
|
9
|
-
declare const ECC_ALGORITHM = "X25519";
|
|
2
|
+
declare const AES_KEY_BYTE_LENGTH = 32;
|
|
3
|
+
declare const IV_LEN_BYTES = 12;
|
|
10
4
|
declare const CONTEXT_ENC_KEYSTORE = "CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore";
|
|
11
5
|
declare const CONTEXT_RECOVERY = "CRYPTO library 2025-07-30 16:20:00 key for account recovery";
|
|
12
6
|
declare const CONTEXT_INDEX = "CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices";
|
|
@@ -19,7 +13,6 @@ declare const ARGON2ID_OUTPUT_BYTE_LENGTH = 32;
|
|
|
19
13
|
declare const KYBER768_PUBLIC_KEY_LENGTH = 1184;
|
|
20
14
|
declare const KYBER768_SECRET_KEY_LENGTH = 2400;
|
|
21
15
|
declare const KYBER_SEED_LENGTH = 64;
|
|
22
|
-
declare const HASH_BIT_LEN = 256;
|
|
23
16
|
declare const MAX_CACHE_SIZE = 600000000;
|
|
24
17
|
declare const MAX_EMAIL_PER_BATCH = 100;
|
|
25
18
|
declare const DB_LABEL = "email";
|
|
@@ -29,5 +22,5 @@ declare const XWING_SECRET_KEY_LENGTH = 32;
|
|
|
29
22
|
declare const XWING_SEED_BYTE_LENGTH = 32;
|
|
30
23
|
declare const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;
|
|
31
24
|
//#endregion
|
|
32
|
-
export {
|
|
25
|
+
export { AES_KEY_BYTE_LENGTH, ARGON2ID_ITERATIONS, ARGON2ID_MEMORY_SIZE, ARGON2ID_OUTPUT_BYTE_LENGTH, ARGON2ID_PARALLELISM, ARGON2ID_SALT_BYTE_LENGTH, CONTEXT_DERIVE, CONTEXT_ENC_KEYSTORE, CONTEXT_INDEX, CONTEXT_RECOVERY, DB_LABEL, DB_VERSION, IV_LEN_BYTES, KYBER768_PUBLIC_KEY_LENGTH, KYBER768_SECRET_KEY_LENGTH, KYBER_SEED_LENGTH, MAX_CACHE_SIZE, MAX_EMAIL_PER_BATCH, XWING_CIPHERTEXT_BYTE_LENGTH, XWING_PUBLIC_KEY_LENGTH, XWING_SECRET_KEY_LENGTH, XWING_SEED_BYTE_LENGTH };
|
|
33
26
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";cAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";cAAa,mBAAA;AAAA,cACA,YAAA;AAAA,cAEA,oBAAA;AAAA,cACA,gBAAA;AAAA,cACA,aAAA;AAAA,cACA,cAAA;AAAA,cAGA,oBAAA;AAAA,cACA,mBAAA;AAAA,cACA,oBAAA;AAAA,cACA,yBAAA;AAAA,cACA,2BAAA;AAAA,cAEA,0BAAA;AAAA,cACA,0BAAA;AAAA,cACA,iBAAA;AAAA,cAEA,cAAA;AAAA,cACA,mBAAA;AAAA,cACA,QAAA;AAAA,cACA,UAAA;AAAA,cAEA,uBAAA;AAAA,cACA,uBAAA;AAAA,cACA,sBAAA;AAAA,cACA,4BAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
//#region src/constants.ts
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const AUX_BYTE_LEN = 16;
|
|
7
|
-
const IV_LEN_BYTES = 16;
|
|
8
|
-
const KEY_WRAPPING_ALGORITHM = "AES-KW";
|
|
9
|
-
const KEY_FORMAT = "raw";
|
|
10
|
-
const CONTEXT_WRAPPING = "CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets";
|
|
11
|
-
const ECC_ALGORITHM = "X25519";
|
|
4
|
+
const AES_KEY_BYTE_LENGTH = 32;
|
|
5
|
+
const IV_LEN_BYTES = 12;
|
|
12
6
|
const CONTEXT_ENC_KEYSTORE = "CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore";
|
|
13
7
|
const CONTEXT_RECOVERY = "CRYPTO library 2025-07-30 16:20:00 key for account recovery";
|
|
14
8
|
const CONTEXT_INDEX = "CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices";
|
|
@@ -21,7 +15,6 @@ const ARGON2ID_OUTPUT_BYTE_LENGTH = 32;
|
|
|
21
15
|
const KYBER768_PUBLIC_KEY_LENGTH = 1184;
|
|
22
16
|
const KYBER768_SECRET_KEY_LENGTH = 2400;
|
|
23
17
|
const KYBER_SEED_LENGTH = 64;
|
|
24
|
-
const HASH_BIT_LEN = 256;
|
|
25
18
|
const MAX_CACHE_SIZE = 6e8;
|
|
26
19
|
const MAX_EMAIL_PER_BATCH = 100;
|
|
27
20
|
const DB_LABEL = "email";
|
|
@@ -32,26 +25,19 @@ const XWING_SEED_BYTE_LENGTH = 32;
|
|
|
32
25
|
const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;
|
|
33
26
|
|
|
34
27
|
//#endregion
|
|
35
|
-
exports.
|
|
36
|
-
exports.AES_KEY_BIT_LENGTH = AES_KEY_BIT_LENGTH;
|
|
28
|
+
exports.AES_KEY_BYTE_LENGTH = AES_KEY_BYTE_LENGTH;
|
|
37
29
|
exports.ARGON2ID_ITERATIONS = ARGON2ID_ITERATIONS;
|
|
38
30
|
exports.ARGON2ID_MEMORY_SIZE = ARGON2ID_MEMORY_SIZE;
|
|
39
31
|
exports.ARGON2ID_OUTPUT_BYTE_LENGTH = ARGON2ID_OUTPUT_BYTE_LENGTH;
|
|
40
32
|
exports.ARGON2ID_PARALLELISM = ARGON2ID_PARALLELISM;
|
|
41
33
|
exports.ARGON2ID_SALT_BYTE_LENGTH = ARGON2ID_SALT_BYTE_LENGTH;
|
|
42
|
-
exports.AUX_BYTE_LEN = AUX_BYTE_LEN;
|
|
43
34
|
exports.CONTEXT_DERIVE = CONTEXT_DERIVE;
|
|
44
35
|
exports.CONTEXT_ENC_KEYSTORE = CONTEXT_ENC_KEYSTORE;
|
|
45
36
|
exports.CONTEXT_INDEX = CONTEXT_INDEX;
|
|
46
37
|
exports.CONTEXT_RECOVERY = CONTEXT_RECOVERY;
|
|
47
|
-
exports.CONTEXT_WRAPPING = CONTEXT_WRAPPING;
|
|
48
38
|
exports.DB_LABEL = DB_LABEL;
|
|
49
39
|
exports.DB_VERSION = DB_VERSION;
|
|
50
|
-
exports.ECC_ALGORITHM = ECC_ALGORITHM;
|
|
51
|
-
exports.HASH_BIT_LEN = HASH_BIT_LEN;
|
|
52
40
|
exports.IV_LEN_BYTES = IV_LEN_BYTES;
|
|
53
|
-
exports.KEY_FORMAT = KEY_FORMAT;
|
|
54
|
-
exports.KEY_WRAPPING_ALGORITHM = KEY_WRAPPING_ALGORITHM;
|
|
55
41
|
exports.KYBER768_PUBLIC_KEY_LENGTH = KYBER768_PUBLIC_KEY_LENGTH;
|
|
56
42
|
exports.KYBER768_SECRET_KEY_LENGTH = KYBER768_SECRET_KEY_LENGTH;
|
|
57
43
|
exports.KYBER_SEED_LENGTH = KYBER_SEED_LENGTH;
|