@katlux/toolkit 0.1.1-alpha.140 → 0.1.1-alpha.141
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/module.json +1 -1
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
- package/dist/skills/katlux-config/SKILL.md +7 -7
- package/dist/skills/katlux-providers/SKILL.md +1 -1
- package/dist/skills/katlux-providers/providers/encryption-asymmetric.md +102 -0
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +260 -0
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +196 -0
- package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +115 -0
- package/dist/skills/katlux-providers/providers/encryption-streaming.md +84 -0
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +139 -0
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +110 -0
- package/dist/skills/katlux-providers/providers/encryption.md +44 -267
- package/package.json +2 -2
package/dist/module.json
CHANGED
|
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
56
56
|
}>, {
|
|
57
57
|
size: "small" | "large" | "medium" | undefined;
|
|
58
58
|
type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
|
|
59
|
-
iconOnly: boolean;
|
|
60
59
|
disabled: boolean;
|
|
61
60
|
href: string;
|
|
62
61
|
loading: boolean;
|
|
62
|
+
iconOnly: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
export default _default;
|
|
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
56
56
|
}>, {
|
|
57
57
|
size: "small" | "large" | "medium" | undefined;
|
|
58
58
|
type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
|
|
59
|
-
iconOnly: boolean;
|
|
60
59
|
disabled: boolean;
|
|
61
60
|
href: string;
|
|
62
61
|
loading: boolean;
|
|
62
|
+
iconOnly: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
export default _default;
|
|
@@ -75,8 +75,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
75
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
76
|
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
77
77
|
}>, {
|
|
78
|
-
label: string;
|
|
79
78
|
disabled: boolean;
|
|
79
|
+
label: string;
|
|
80
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
81
81
|
validationText: string;
|
|
82
82
|
idKey: string;
|
|
@@ -75,8 +75,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
75
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
76
|
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
77
77
|
}>, {
|
|
78
|
-
label: string;
|
|
79
78
|
disabled: boolean;
|
|
79
|
+
label: string;
|
|
80
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
81
81
|
validationText: string;
|
|
82
82
|
idKey: string;
|
|
@@ -223,8 +223,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
223
223
|
}) => any) | undefined;
|
|
224
224
|
}>, {
|
|
225
225
|
modelValue: any;
|
|
226
|
-
label: string;
|
|
227
226
|
disabled: boolean;
|
|
227
|
+
label: string;
|
|
228
228
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
229
229
|
validationText: string;
|
|
230
230
|
searchbox: boolean;
|
|
@@ -223,8 +223,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
223
223
|
}) => any) | undefined;
|
|
224
224
|
}>, {
|
|
225
225
|
modelValue: any;
|
|
226
|
-
label: string;
|
|
227
226
|
disabled: boolean;
|
|
227
|
+
label: string;
|
|
228
228
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
229
229
|
validationText: string;
|
|
230
230
|
searchbox: boolean;
|
|
@@ -40,10 +40,10 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
40
40
|
"onSearch-change"?: ((value: string) => any) | undefined;
|
|
41
41
|
}>, {
|
|
42
42
|
search: string;
|
|
43
|
+
loading: boolean;
|
|
43
44
|
selectedRows: any[];
|
|
44
45
|
bulkActions: IKDatatableAction[];
|
|
45
46
|
selectAll: boolean;
|
|
46
|
-
loading: boolean;
|
|
47
47
|
currentPage: number;
|
|
48
48
|
pageSize: number;
|
|
49
49
|
virtualScroll: boolean;
|
|
@@ -40,10 +40,10 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
40
40
|
"onSearch-change"?: ((value: string) => any) | undefined;
|
|
41
41
|
}>, {
|
|
42
42
|
search: string;
|
|
43
|
+
loading: boolean;
|
|
43
44
|
selectedRows: any[];
|
|
44
45
|
bulkActions: IKDatatableAction[];
|
|
45
46
|
selectAll: boolean;
|
|
46
|
-
loading: boolean;
|
|
47
47
|
currentPage: number;
|
|
48
48
|
pageSize: number;
|
|
49
49
|
virtualScroll: boolean;
|
|
@@ -135,8 +135,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
135
135
|
placeholder: string;
|
|
136
136
|
teleportTo: string;
|
|
137
137
|
showClear: boolean;
|
|
138
|
-
format: string;
|
|
139
138
|
align: "left" | "right" | undefined;
|
|
139
|
+
format: string;
|
|
140
140
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
141
141
|
declare const _default: typeof __VLS_export;
|
|
142
142
|
export default _default;
|
|
@@ -135,8 +135,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
135
135
|
placeholder: string;
|
|
136
136
|
teleportTo: string;
|
|
137
137
|
showClear: boolean;
|
|
138
|
-
format: string;
|
|
139
138
|
align: "left" | "right" | undefined;
|
|
139
|
+
format: string;
|
|
140
140
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
141
141
|
declare const _default: typeof __VLS_export;
|
|
142
142
|
export default _default;
|
|
@@ -108,8 +108,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
}>, {
|
|
109
109
|
modelValue: string;
|
|
110
110
|
isOpen: boolean;
|
|
111
|
-
label: string;
|
|
112
111
|
disabled: boolean;
|
|
112
|
+
label: string;
|
|
113
113
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
114
114
|
validationText: string;
|
|
115
115
|
placeholder: string;
|
|
@@ -108,8 +108,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
}>, {
|
|
109
109
|
modelValue: string;
|
|
110
110
|
isOpen: boolean;
|
|
111
|
-
label: string;
|
|
112
111
|
disabled: boolean;
|
|
112
|
+
label: string;
|
|
113
113
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
114
114
|
validationText: string;
|
|
115
115
|
placeholder: string;
|
|
@@ -74,8 +74,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
"onUpdate:maxValue"?: ((value: number | undefined) => any) | undefined;
|
|
75
75
|
}>, {
|
|
76
76
|
modelValue: number[] | [number, number];
|
|
77
|
-
label: string;
|
|
78
77
|
disabled: boolean;
|
|
78
|
+
label: string;
|
|
79
79
|
step: number;
|
|
80
80
|
min: number;
|
|
81
81
|
max: number;
|
|
@@ -74,8 +74,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
"onUpdate:maxValue"?: ((value: number | undefined) => any) | undefined;
|
|
75
75
|
}>, {
|
|
76
76
|
modelValue: number[] | [number, number];
|
|
77
|
-
label: string;
|
|
78
77
|
disabled: boolean;
|
|
78
|
+
label: string;
|
|
79
79
|
step: number;
|
|
80
80
|
min: number;
|
|
81
81
|
max: number;
|
|
@@ -64,8 +64,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
"onUpdate:value"?: ((value: number | undefined) => any) | undefined;
|
|
65
65
|
}>, {
|
|
66
66
|
modelValue: number;
|
|
67
|
-
label: string;
|
|
68
67
|
disabled: boolean;
|
|
68
|
+
label: string;
|
|
69
69
|
value: number;
|
|
70
70
|
step: number;
|
|
71
71
|
min: number;
|
|
@@ -64,8 +64,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
"onUpdate:value"?: ((value: number | undefined) => any) | undefined;
|
|
65
65
|
}>, {
|
|
66
66
|
modelValue: number;
|
|
67
|
-
label: string;
|
|
68
67
|
disabled: boolean;
|
|
68
|
+
label: string;
|
|
69
69
|
value: number;
|
|
70
70
|
step: number;
|
|
71
71
|
min: number;
|
|
@@ -232,9 +232,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
232
232
|
"onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
|
|
233
233
|
}>, {
|
|
234
234
|
modelValue: any;
|
|
235
|
-
label: string;
|
|
236
235
|
disabled: boolean;
|
|
237
236
|
loading: boolean;
|
|
237
|
+
label: string;
|
|
238
238
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
239
239
|
validationText: string;
|
|
240
240
|
idKey: string;
|
|
@@ -232,9 +232,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
232
232
|
"onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
|
|
233
233
|
}>, {
|
|
234
234
|
modelValue: any;
|
|
235
|
-
label: string;
|
|
236
235
|
disabled: boolean;
|
|
237
236
|
loading: boolean;
|
|
237
|
+
label: string;
|
|
238
238
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
239
239
|
validationText: string;
|
|
240
240
|
idKey: string;
|
|
@@ -104,13 +104,13 @@ export default defineAppConfig({
|
|
|
104
104
|
|
|
105
105
|
| Package Name | Current Version | Description | Installation Command |
|
|
106
106
|
| --- | --- | --- | --- |
|
|
107
|
-
| `@katlux/toolkit` | `0.1.1-alpha.
|
|
108
|
-
| `@katlux/providers` | `0.1.1-alpha.
|
|
109
|
-
| `@katlux/preset-modern` | `0.1.1-alpha.
|
|
110
|
-
| `@katlux/preset-dark` | `0.1.1-alpha.
|
|
111
|
-
| `@katlux/block-charts` | `0.1.1-alpha.
|
|
112
|
-
| `@katlux/block-ecommerce` | `0.1.1-alpha.
|
|
113
|
-
| `@katlux/mcp` | `0.1.0-alpha.
|
|
107
|
+
| `@katlux/toolkit` | `0.1.1-alpha.140` | Core Nuxt module, UI toolkit, presets, and components | `npm install @katlux/toolkit@alpha` |
|
|
108
|
+
| `@katlux/providers` | `0.1.1-alpha.128` | Core data providers, client caching, and state structures | `npm install @katlux/providers@alpha` |
|
|
109
|
+
| `@katlux/preset-modern` | `0.1.1-alpha.115` | Modern design preset and styling variables | `npm install @katlux/preset-modern@alpha` |
|
|
110
|
+
| `@katlux/preset-dark` | `0.1.1-alpha.46` | Sleek Dark Mode design preset | `npm install @katlux/preset-dark@alpha` |
|
|
111
|
+
| `@katlux/block-charts` | `0.1.1-alpha.115` | Pre-built charting block components | `npm install @katlux/block-charts@alpha` |
|
|
112
|
+
| `@katlux/block-ecommerce` | `0.1.1-alpha.115` | Pre-built eCommerce block components | `npm install @katlux/block-ecommerce@alpha` |
|
|
113
|
+
| `@katlux/mcp` | `0.1.0-alpha.20` | Model Context Protocol server for AI assistant integration | `npm install @katlux/mcp@alpha` |
|
|
114
114
|
|
|
115
115
|
> [!NOTE]
|
|
116
116
|
> Katlux packages are currently published under the `@alpha` tag on NPM. Always append `@alpha` or the specific version tag when adding dependencies.
|
|
@@ -50,7 +50,7 @@ description: Complete reference and atomic index for Katlux data management arch
|
|
|
50
50
|
| `RequestQueue` | Offline PWA operation queue | Queues mutations offline in IndexedDB, auto-flushes on reconnect | [RequestQueue.md](providers/RequestQueue.md) |
|
|
51
51
|
| `KatluxIndexedDB` | High-performance IndexedDB wrapper | Client-side persistent storage for offline data and large cache entries | [KatluxIndexedDB.md](providers/KatluxIndexedDB.md) |
|
|
52
52
|
| `CacheProvider` | Tiered multi-layer caching engine | Memory, BrowserSession, LocalStorage, IndexedDB, Cookie tiers | [caching.md](providers/caching.md) |
|
|
53
|
-
| `EncryptionProvider` & `CKeyManager` | WebCrypto & NodeCrypto cryptographic suite | AES-GCM
|
|
53
|
+
| `EncryptionProvider` & `CKeyManager` | WebCrypto & NodeCrypto cryptographic suite | AES-GCM, asymmetric hybrid, ADEK re-wrapping, RFC 8785 grants, domain KDF, TOFU pinning, streaming AEAD, blind indexing | [encryption.md](providers/encryption.md) (Index: [threat-model](providers/encryption-threat-model.md) · [symmetric](providers/encryption-symmetric.md) · [asymmetric](providers/encryption-asymmetric.md) · [key-mgmt](providers/encryption-key-management.md) · [key-pinning](providers/encryption-key-pinning.md) · [streaming](providers/encryption-streaming.md) · [field-level](providers/encryption-field-level.md)) |
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Katlux Encryption Architecture: Asymmetric & Hybrid Cipher Providers
|
|
2
|
+
|
|
3
|
+
> Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
|
|
4
|
+
> See [encryption.md](encryption.md) for the master index.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Overview of Hybrid Asymmetric Ciphers
|
|
9
|
+
|
|
10
|
+
Asymmetric cryptography alone cannot efficiently encrypt arbitrary-sized payloads. Katlux hybrid providers combine public-key cryptography with AES-256-GCM symmetric session keys:
|
|
11
|
+
- The sender generates a random 256-bit AES-GCM Data Encryption Key (DEK).
|
|
12
|
+
- The DEK encrypts the payload.
|
|
13
|
+
- The recipient's public key encrypts/derives the DEK.
|
|
14
|
+
- Only the holder of the recipient's private key can decrypt the DEK and recover the payload.
|
|
15
|
+
|
|
16
|
+
| Provider | Asymmetric Primitive | Symmetric Primitive | Primary Use Case |
|
|
17
|
+
| :--- | :--- | :--- | :--- |
|
|
18
|
+
| `CRSAEncryptionProvider` | RSA-OAEP-4096 / 2048 | AES-GCM-256 | Single-recipient arbitrary payload encryption, user keypair delivery |
|
|
19
|
+
| `CECDHEncryptionProvider` | ECDH (P-256, P-384, P-521) + HKDF | AES-GCM-256 | Forward-secure ephemeral key exchange, role-based key sharing |
|
|
20
|
+
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
> **Sender Authenticity Boundary**:
|
|
23
|
+
> Asymmetric hybrid encryption provides **recipient confidentiality**, not sender authenticity. Anyone with the recipient's public key can encrypt envelopes. For write authenticity, combine with digital signatures (`CKeyManager.sign` / `CKeyManager.verify`) or symmetric role keys.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. `CRSAEncryptionProvider` (RSA-OAEP-4096 Hybrid)
|
|
28
|
+
|
|
29
|
+
Combines RSA-OAEP key wrapping with AES-256-GCM payload encryption.
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
```ts
|
|
33
|
+
import { CRSAEncryptionProvider, CKeyManager } from '@katlux/providers'
|
|
34
|
+
|
|
35
|
+
// 1. Generate or import recipient keypair:
|
|
36
|
+
const keypair = await CKeyManager.generateRSAKeyPair(4096, 'SHA-256', true)
|
|
37
|
+
|
|
38
|
+
// 2. Sender configures provider with recipient public key:
|
|
39
|
+
const senderCipher = new CRSAEncryptionProvider({
|
|
40
|
+
recipientPublicKey: keypair.publicKey
|
|
41
|
+
})
|
|
42
|
+
const envelope = await senderCipher.encrypt({ secretDocument: 'Confidential content' })
|
|
43
|
+
|
|
44
|
+
// 3. Recipient configures provider with private key:
|
|
45
|
+
const recipientCipher = new CRSAEncryptionProvider({
|
|
46
|
+
recipientPrivateKey: keypair.privateKey
|
|
47
|
+
})
|
|
48
|
+
const data = await recipientCipher.decrypt(envelope)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 3. `CECDHEncryptionProvider` (ECDH Ephemeral Hybrid)
|
|
54
|
+
|
|
55
|
+
Uses Elliptic Curve Diffie-Hellman (P-256 by default) with an ephemeral keypair per encryption operation, stretched via HKDF to derive an AES-256-GCM key.
|
|
56
|
+
|
|
57
|
+
### Basic Usage
|
|
58
|
+
```ts
|
|
59
|
+
import { CECDHEncryptionProvider, CKeyManager } from '@katlux/providers'
|
|
60
|
+
|
|
61
|
+
// 1. Recipient generates ECDH keypair:
|
|
62
|
+
const keypair = await CKeyManager.generateECDHKeyPair('P-256')
|
|
63
|
+
|
|
64
|
+
// 2. Sender encrypts using recipient's public key (generates fresh ephemeral key):
|
|
65
|
+
const senderCipher = new CECDHEncryptionProvider({
|
|
66
|
+
recipientPublicKey: keypair.publicKey,
|
|
67
|
+
curve: 'P-256',
|
|
68
|
+
info: 'tenant-sharing-v1'
|
|
69
|
+
})
|
|
70
|
+
const envelope = await senderCipher.encrypt({ tenantKey: 'wrapped-bytes' })
|
|
71
|
+
// Envelope contains `epk` (ephemeral public key in JWK format)
|
|
72
|
+
|
|
73
|
+
// 3. Recipient derives matching shared secret and decrypts:
|
|
74
|
+
const recipientCipher = new CECDHEncryptionProvider({
|
|
75
|
+
recipientPrivateKey: keypair.privateKey,
|
|
76
|
+
curve: 'P-256',
|
|
77
|
+
info: 'tenant-sharing-v1'
|
|
78
|
+
})
|
|
79
|
+
const decrypted = await recipientCipher.decrypt(envelope)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 4. PEM Key Import & Export (`CKeyManager`)
|
|
85
|
+
|
|
86
|
+
Katlux providers natively support standard SPKI and PKCS#8 PEM strings without third-party libraries:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { CKeyManager } from '@katlux/providers'
|
|
90
|
+
|
|
91
|
+
// Exporting keys:
|
|
92
|
+
const publicPem = await CKeyManager.exportPublicKeyToPEM(keypair.publicKey)
|
|
93
|
+
const privatePem = await CKeyManager.exportPrivateKeyToPEM(keypair.privateKey)
|
|
94
|
+
|
|
95
|
+
// Importing keys:
|
|
96
|
+
const importedPubKey = await CKeyManager.importPublicKeyFromPEM(publicPem, 'RSA-OAEP', undefined, 'SHA-256')
|
|
97
|
+
const importedPrivKey = await CKeyManager.importPrivateKeyFromPEM(privatePem, 'RSA-OAEP', undefined, 'SHA-256')
|
|
98
|
+
|
|
99
|
+
// ECDSA signing keys:
|
|
100
|
+
const ecdsaPubKey = await CKeyManager.importECDSAPublicKeyFromPEM(ecdsaPubPem, 'P-256')
|
|
101
|
+
const ecdsaPrivKey = await CKeyManager.importECDSAPrivateKeyFromPEM(ecdsaPrivPem, 'P-256')
|
|
102
|
+
```
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Katlux Encryption Architecture: Field-Level Encryption, Ingestion & Blind Indexing
|
|
2
|
+
|
|
3
|
+
> Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
|
|
4
|
+
> See [encryption.md](encryption.md) for the master index.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Overview
|
|
9
|
+
|
|
10
|
+
Katlux supports selective **field-level encryption** across data rows, allowing public identifiers (such as `id`, `status`, `role`) to remain in plaintext for sorting and routing, while sensitive PII (such as `ssn`, `salary`, `email`) is encrypted into individual `IEncryptedPayload` envelopes.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 2. Scalar Field Encryption (`encryptField` / `decryptField`)
|
|
15
|
+
|
|
16
|
+
Encrypt single fields with contextual AAD binding without allocating dummy wrapper objects:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { CWebCryptoEncryptionProvider } from '@katlux/providers'
|
|
20
|
+
|
|
21
|
+
const cipher = new CWebCryptoEncryptionProvider({
|
|
22
|
+
key: process.env.DATA_KEY,
|
|
23
|
+
kid: 'v1',
|
|
24
|
+
baseAad: 'tenant:corp'
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Encrypt a single field:
|
|
28
|
+
const envelope = await cipher.encryptField('123-45-6789', {
|
|
29
|
+
recordId: 'REC-101',
|
|
30
|
+
fieldName: 'ssn'
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// Decrypt verifying contextual AAD:
|
|
34
|
+
const plainSSN = await cipher.decryptField(envelope, {
|
|
35
|
+
recordId: 'REC-101',
|
|
36
|
+
fieldName: 'ssn'
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 3. DataProvider Integration (`AEncryptedClientProvider`)
|
|
43
|
+
|
|
44
|
+
Supported uniformly across all client providers (`CFlatClientDataProvider`, `CTreeClientDataProvider`):
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { CFlatClientDataProvider } from '@katlux/providers'
|
|
48
|
+
|
|
49
|
+
const customerProvider = new CFlatClientDataProvider({
|
|
50
|
+
pageSize: 20,
|
|
51
|
+
encryption: {
|
|
52
|
+
enabled: true,
|
|
53
|
+
key: 'secret-key-32-chars-long-12345!',
|
|
54
|
+
kid: 'tenant-key-v1',
|
|
55
|
+
fields: ['ssn', 'salary', 'creditCard'],
|
|
56
|
+
searchIndex: true // Enables search/filter on encrypted fields via CSearchIndex
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Eagerly encrypts sensitive fields; leaves id, role, department in plaintext:
|
|
61
|
+
await customerProvider.setData(rawEmployees)
|
|
62
|
+
|
|
63
|
+
// Large dataset ingestion with progress reporting:
|
|
64
|
+
await customerProvider.setDataChunked(largeEmployees, {
|
|
65
|
+
chunkSize: 500,
|
|
66
|
+
onProgress: (p) => console.log(`Encryption progress: ${(p * 100).toFixed(0)}%`)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Lazy Page-Level Decryption:
|
|
70
|
+
// loadPageData() decrypts only the active page (pageSize rows) into pageData.
|
|
71
|
+
// Plaintext never persists in allData.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Pre-Encrypted Dataset Ingestion (`preEncrypted: true`)
|
|
75
|
+
When datasets arrive already encrypted from server endpoints, data providers perform a transient in-memory decryption pass on indexed fields to populate `CSearchIndex` without modifying or leaking persistent ciphertext rows in `allData`.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 4. Blind Index Search & Substring Trigram Indexing (`CSearchIndex`)
|
|
80
|
+
|
|
81
|
+
Enables fast exact match (`==`, `!=`) and substring search (`in`) over encrypted fields without full dataset decryption.
|
|
82
|
+
|
|
83
|
+
### Ingestion Pipeline
|
|
84
|
+
1. **Normalization**: Normalize plaintext (`NFKC` + lowercase).
|
|
85
|
+
2. **Blind Index Token**: Generate exact blind index token via `CKeyManager.computeBlindIndex(plain, hmacKey)`.
|
|
86
|
+
3. **Trigram Slices**: Extract 3-character slices via `extractTrigrams(plain)` and hash each trigram with `searchIndex.computeTrigramTokens(plain)`.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 5. Backend Persistence & Datatable Encrypted Search
|
|
91
|
+
|
|
92
|
+
To enable fast exact-match and substring search across AES-256-GCM encrypted records in persisted PostgreSQL/MySQL databases:
|
|
93
|
+
|
|
94
|
+
### 1. Database Schema
|
|
95
|
+
```sql
|
|
96
|
+
CREATE TABLE contacts (
|
|
97
|
+
id SERIAL PRIMARY KEY,
|
|
98
|
+
name_encrypted JSONB NOT NULL,
|
|
99
|
+
email_encrypted JSONB NOT NULL,
|
|
100
|
+
salary_encrypted JSONB,
|
|
101
|
+
name_bidx CHAR(64) NOT NULL,
|
|
102
|
+
email_bidx CHAR(64) NOT NULL,
|
|
103
|
+
name_trigrams TEXT[] NOT NULL,
|
|
104
|
+
email_trigrams TEXT[] NOT NULL,
|
|
105
|
+
role VARCHAR(100),
|
|
106
|
+
department VARCHAR(100),
|
|
107
|
+
status VARCHAR(50) DEFAULT 'Active'
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
-- B-Tree for O(log N) exact lookups:
|
|
111
|
+
CREATE INDEX idx_contacts_name_bidx ON contacts (name_bidx);
|
|
112
|
+
CREATE INDEX idx_contacts_email_bidx ON contacts (email_bidx);
|
|
113
|
+
|
|
114
|
+
-- Inverted index for fast array containment substring search:
|
|
115
|
+
CREATE INDEX idx_contacts_name_trigrams ON contacts USING GIN (name_trigrams);
|
|
116
|
+
CREATE INDEX idx_contacts_email_trigrams ON contacts USING GIN (email_trigrams);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 2. Query Execution
|
|
120
|
+
- **Exact Match (`name = $1`)**:
|
|
121
|
+
```sql
|
|
122
|
+
-- Compute HMAC token in API, then point-lookup using B-Tree:
|
|
123
|
+
SELECT id, name_encrypted, email_encrypted, role FROM contacts WHERE name_bidx = $1;
|
|
124
|
+
```
|
|
125
|
+
- **Substring Search (`name CONTAINS $1`)**:
|
|
126
|
+
```sql
|
|
127
|
+
-- Extract & hash search query trigrams, then query via array containment operator (@>):
|
|
128
|
+
SELECT id, name_encrypted, email_encrypted, role
|
|
129
|
+
FROM contacts
|
|
130
|
+
WHERE name_trigrams @> $1::text[]
|
|
131
|
+
ORDER BY id ASC
|
|
132
|
+
LIMIT 10 OFFSET 0;
|
|
133
|
+
```
|
|
134
|
+
- **Compound Filtering**:
|
|
135
|
+
```sql
|
|
136
|
+
WHERE name_trigrams @> $1::text[] AND department = 'Security'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 3. Production Best Practices
|
|
140
|
+
- **Strict Key Isolation**: Isolate `DATA_ENCRYPTION_KEY` (AES-256-GCM) from `BLIND_INDEX_HMAC_KEY`.
|
|
141
|
+
- **Short Queries (< 3 chars)**: Substring search requires at least 3 characters to form a valid trigram. Enforce a 3-character minimum in client UI.
|
|
142
|
+
- **Low-Cardinality Isolation**: Never blind index low-cardinality fields (boolean flags, binary status) to prevent frequency analysis leakage.
|
|
143
|
+
- **Client Decryption Pipeline**: API responses return encrypted envelopes (`__encrypted: true`). Frontend `CAPIFlatServerDataProvider` decrypts only the received page slice via `decryptPageRows()` on arrival.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 6. Multi-KID Blind Index Search & Query Resolution (`IBlindIndexKeyring`)
|
|
148
|
+
|
|
149
|
+
In production environments with periodic cryptographic key rotation, records in storage will be indexed under different key versions (`v1`, `v2`, etc.). Blind index HMAC tokens are deterministic with respect to their key, meaning searching for an exact value under only the active key would fail to find records created before the rotation.
|
|
150
|
+
|
|
151
|
+
Katlux solves this using `IBlindIndexKeyring` and multi-token query expansion (`computeMultiBlindIndex` and `rewriteEncryptedFilters`).
|
|
152
|
+
|
|
153
|
+
### Keyring Schema & Lifecycle Statuses
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import type { IBlindIndexKeyring, TBlindIndexKeyStatus } from '@katlux/providers'
|
|
157
|
+
|
|
158
|
+
const keyring: IBlindIndexKeyring = {
|
|
159
|
+
activeKid: 'bidx-v2',
|
|
160
|
+
keys: {
|
|
161
|
+
'bidx-v2': {
|
|
162
|
+
key: activeHmacKey,
|
|
163
|
+
status: 'active', // Exactly ONE key must be active
|
|
164
|
+
algorithm: 'HMAC'
|
|
165
|
+
},
|
|
166
|
+
'bidx-v1': {
|
|
167
|
+
key: oldHmacKey,
|
|
168
|
+
status: 'search-only', // Historical key used for querying existing rows
|
|
169
|
+
algorithm: 'HMAC'
|
|
170
|
+
},
|
|
171
|
+
'bidx-v0': {
|
|
172
|
+
key: retiredHmacKey,
|
|
173
|
+
status: 'retired', // Completely ignored; rows must already be re-indexed
|
|
174
|
+
algorithm: 'HMAC'
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- `'active'`: Used for all outbound writes (`computeWriteBlindIndex`) and included first in search tokens.
|
|
181
|
+
- `'search-only'`: Used during queries (`computeMultiBlindIndex`) to match rows created under historical key versions.
|
|
182
|
+
- `'retired'`: Excluded from all token generation. Zero candidate tokens are generated.
|
|
183
|
+
|
|
184
|
+
### Candidate Token Generation
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { CKeyManager } from '@katlux/providers'
|
|
188
|
+
|
|
189
|
+
// Multi-token generation for search (returns tokens for active + search-only keys):
|
|
190
|
+
const tokens = await CKeyManager.computeMultiBlindIndex('user@example.com', keyring)
|
|
191
|
+
// Output: [token_v2, token_v1] (active key token is always first, de-duplicated)
|
|
192
|
+
|
|
193
|
+
// Single-token generation for record insertion / update:
|
|
194
|
+
const writeToken = await CKeyManager.computeWriteBlindIndex('user@example.com', keyring)
|
|
195
|
+
// Output: token_v2
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Encrypted Query Rewriting (`rewriteEncryptedFilters`)
|
|
199
|
+
|
|
200
|
+
When an application receives datatable or ORM filter criteria targeting encrypted fields, `rewriteEncryptedFilters` expands the filter predicates into database clauses:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
import { rewriteEncryptedFilters } from '@katlux/providers'
|
|
204
|
+
|
|
205
|
+
const rewritten = await rewriteEncryptedFilters(
|
|
206
|
+
[
|
|
207
|
+
{ field: 'email', operator: '==', value: 'user@example.com' },
|
|
208
|
+
{ field: 'status', operator: '==', value: 'Active' } // unencrypted passthrough
|
|
209
|
+
],
|
|
210
|
+
{
|
|
211
|
+
dialect: 'postgres',
|
|
212
|
+
fields: {
|
|
213
|
+
email: {
|
|
214
|
+
encrypted: true,
|
|
215
|
+
blindIndex: true,
|
|
216
|
+
keyring: emailKeyring,
|
|
217
|
+
column: 'email_bidx'
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
maxCandidateTokens: 500
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
// SQL Generation:
|
|
225
|
+
// email_bidx = ANY($1::text[]) AND status = 'Active'
|
|
226
|
+
// Parameters: [['bidx_hash_v2', 'bidx_hash_v1']]
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Operator Mapping & Negation Semantics
|
|
230
|
+
- **Equality (`==`) / Set Membership (`in`)**: Expands to an abstract `in` clause over candidate tokens generated from active and `search-only` keys.
|
|
231
|
+
- **Negation (`!=`) / Exclusion (`nin` / `not in`)**: Expands to an abstract `notIn` clause requiring the column to not match *any* active or `search-only` tokens. For PostgreSQL: `!= ALL($1::text[])`. For SQLite/MySQL: `NOT IN (?, ?)`.
|
|
232
|
+
- **Pass-through**: Unencrypted fields (e.g. `status = 'Active'`) pass through unmodified.
|
|
233
|
+
|
|
234
|
+
#### Guard Rails
|
|
235
|
+
- `maxCandidateTokens` (default: 500): Prevents query explosion from large `in` lists combined with multiple key versions. Throws `ERR_BIDX_TOO_MANY_CANDIDATES` if exceeded.
|
|
236
|
+
- Parameter Chunking: SQLite/MySQL dialect chunking breaks down long `IN` lists when exceeding parameter limits.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 7. Key Rotation Runbook for Blind-Indexed Fields
|
|
241
|
+
|
|
242
|
+
When rotating a blind index HMAC key:
|
|
243
|
+
|
|
244
|
+
1. **Step 1: Introduce New Key**:
|
|
245
|
+
- Generate a new HMAC key (`v2`).
|
|
246
|
+
- Add `v2` to the keyring with `status: 'active'`.
|
|
247
|
+
- Demote `v1` from `'active'` to `'search-only'`.
|
|
248
|
+
- Deploy backend/client updates. Queries will now check both `v2` and `v1` tokens; new/updated rows will receive `v2` tokens.
|
|
249
|
+
|
|
250
|
+
2. **Step 2: Background Re-Indexing**:
|
|
251
|
+
- Run a background migration job iterating over records that still have `v1` blind indexes.
|
|
252
|
+
- For each record, recompute the blind index using `computeWriteBlindIndex` (`v2`) and update the row's `_bidx` column.
|
|
253
|
+
|
|
254
|
+
3. **Step 3: Retire Old Key**:
|
|
255
|
+
- Once all rows have been updated to `v2`, update `v1` to `status: 'retired'`.
|
|
256
|
+
- Remove `v1` key material in the subsequent release.
|
|
257
|
+
|
|
258
|
+
> [!TIP]
|
|
259
|
+
> **Information Leakage Trade-off**: Keeping historical keys in `'search-only'` mode expands SQL queries to test multiple HMAC hashes per search term. To minimize index leakage and maintain optimal query performance, complete Step 2 (background re-indexing) promptly so older keys can be transitioned to `'retired'`.
|
|
260
|
+
|