1- import { CryptoProvider } from "../providers/CryptoProvider.js" ;
2-
3- export interface VersionDescriptor {
4- /** 3-bit header field: 0 … 7 */
5- readonly id : number ;
6- readonly cipher : new ( p : CryptoProvider ) => EncryptionAlgorithm ;
7- readonly kdf : KeyDerivation ;
8- readonly saltLengths : Record < 'low' | 'high' , number > ;
9- readonly difficulties : Record < string , unknown > ;
10- readonly defaultChunkSize : number ;
11- }
1+ import type { CryptoProvider } from '../providers/CryptoProvider.js' ;
122
3+ /* ------------------------- Encryption engine ------------------------- */
134export interface EncryptionAlgorithm {
14- encryptChunk ( plain : Uint8Array ) : Promise < Uint8Array > ;
5+ encryptChunk ( plain : Uint8Array ) : Promise < Uint8Array > ;
156 decryptChunk ( cipher : Uint8Array ) : Promise < Uint8Array > ;
167}
178
18- export interface KeyDerivation {
9+ /* ------------------------- Key derivation ---------------------------- */
10+ export interface KeyDerivation < D extends string = string > {
11+ readonly name : string ;
1912 derive (
20- passphrase : Uint8Array | string ,
21- salt : Uint8Array ,
22- difficulty : string ,
23- provider : CryptoProvider
13+ passphrase : Uint8Array | string ,
14+ salt : Uint8Array ,
15+ difficulty : D ,
16+ provider : CryptoProvider ,
2417 ) : Promise < CryptoKey > ;
18+ }
19+
20+ /* ---------------------------------------------------------------------
21+ Generic descriptor of one “format version”.
22+
23+ S = salt-strength keys (e.g. "low" | "high")
24+ D = difficulty presets (e.g. "low" | "middle" | "high")
25+ --------------------------------------------------------------------- */
26+ export interface VersionDescriptor <
27+ S extends string = string ,
28+ D extends string = string ,
29+ > {
30+ readonly id : number ; // 3-bit header field
31+ readonly cipher : new ( p : CryptoProvider ) => EncryptionAlgorithm ;
32+ readonly kdf : KeyDerivation < D > ;
33+
34+ readonly saltLengths : Record < S , number > ; // e.g. { low: 12, high: 16 }
35+ readonly difficulties : Record < D , unknown > ; // free-form KDF presets
36+ readonly defaultChunkSize : number ;
2537}
0 commit comments