@luxfhe/wasm 0.1.1 → 0.1.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/dist/node/index.cjs +24 -0
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -0
- package/dist/web/index.cjs +24 -0
- package/dist/web/index.d.cts +1 -0
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +2 -0
- package/package.json +29 -53
- package/README.md +0 -198
- package/dist/index.d.ts +0 -38
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -136
- package/dist/index.js.map +0 -1
- package/dist/init.d.ts +0 -13
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -54
- package/dist/init.js.map +0 -1
- package/dist/types.d.ts +0 -166
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -4
- package/dist/types.js.map +0 -1
- package/pkg/tfhe.wasm +0 -0
- package/pkg/wasm_exec.js +0 -575
package/dist/types.d.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result from TFHE operations.
|
|
3
|
-
* All WASM functions return this structure.
|
|
4
|
-
*/
|
|
5
|
-
export interface TFHEResult<T = unknown> {
|
|
6
|
-
success: boolean;
|
|
7
|
-
data?: T;
|
|
8
|
-
error?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Key pair returned from generateKeys()
|
|
12
|
-
*/
|
|
13
|
-
export interface KeyPair {
|
|
14
|
-
secretKey: string;
|
|
15
|
-
publicKey: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Encrypted bit - base64-encoded ciphertext
|
|
19
|
-
*/
|
|
20
|
-
export type Ciphertext = string;
|
|
21
|
-
/**
|
|
22
|
-
* Encrypted 8-bit unsigned integer - array of 8 ciphertexts (LSB first)
|
|
23
|
-
*/
|
|
24
|
-
export type CiphertextUint8 = [
|
|
25
|
-
Ciphertext,
|
|
26
|
-
Ciphertext,
|
|
27
|
-
Ciphertext,
|
|
28
|
-
Ciphertext,
|
|
29
|
-
Ciphertext,
|
|
30
|
-
Ciphertext,
|
|
31
|
-
Ciphertext,
|
|
32
|
-
Ciphertext
|
|
33
|
-
];
|
|
34
|
-
/**
|
|
35
|
-
* Raw WASM functions exposed globally.
|
|
36
|
-
* These are low-level and return TFHEResult.
|
|
37
|
-
*/
|
|
38
|
-
export interface TFHEWasmRaw {
|
|
39
|
-
tfhe_init(): TFHEResult<string>;
|
|
40
|
-
tfhe_generateKeys(): TFHEResult<KeyPair>;
|
|
41
|
-
tfhe_loadSecretKey(secretKey: string): TFHEResult<string>;
|
|
42
|
-
tfhe_encrypt(value: boolean): TFHEResult<Ciphertext>;
|
|
43
|
-
tfhe_decrypt(ct: Ciphertext): TFHEResult<boolean>;
|
|
44
|
-
tfhe_encryptUint8(value: number): TFHEResult<CiphertextUint8>;
|
|
45
|
-
tfhe_decryptUint8(cts: CiphertextUint8): TFHEResult<number>;
|
|
46
|
-
tfhe_and(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
47
|
-
tfhe_or(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
48
|
-
tfhe_xor(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
49
|
-
tfhe_not(ct: Ciphertext): TFHEResult<Ciphertext>;
|
|
50
|
-
tfhe_nand(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
51
|
-
tfhe_nor(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
52
|
-
tfhe_xnor(ct1: Ciphertext, ct2: Ciphertext): TFHEResult<Ciphertext>;
|
|
53
|
-
tfhe_mux(sel: Ciphertext, ctTrue: Ciphertext, ctFalse: Ciphertext): TFHEResult<Ciphertext>;
|
|
54
|
-
tfhe_compare(a: CiphertextUint8, b: CiphertextUint8): TFHEResult<Ciphertext>;
|
|
55
|
-
tfhe_addUint8(a: CiphertextUint8, b: CiphertextUint8): TFHEResult<CiphertextUint8>;
|
|
56
|
-
tfhe_subUint8(a: CiphertextUint8, b: CiphertextUint8): TFHEResult<CiphertextUint8>;
|
|
57
|
-
tfhe_mulUint8(a: CiphertextUint8, b: CiphertextUint8): TFHEResult<CiphertextUint8>;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* High-level TFHE API with proper error handling.
|
|
61
|
-
*/
|
|
62
|
-
export interface TFHE {
|
|
63
|
-
/**
|
|
64
|
-
* Initialize the TFHE library.
|
|
65
|
-
* Must be called before any other operations.
|
|
66
|
-
*/
|
|
67
|
-
init(): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Generate a new key pair.
|
|
70
|
-
* @returns The generated key pair
|
|
71
|
-
*/
|
|
72
|
-
generateKeys(): Promise<KeyPair>;
|
|
73
|
-
/**
|
|
74
|
-
* Load a secret key from base64.
|
|
75
|
-
* This also regenerates the public key and bootstrap key.
|
|
76
|
-
* @param secretKey Base64-encoded secret key
|
|
77
|
-
*/
|
|
78
|
-
loadSecretKey(secretKey: string): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Encrypt a boolean value.
|
|
81
|
-
* @param value The boolean to encrypt
|
|
82
|
-
* @returns Encrypted ciphertext
|
|
83
|
-
*/
|
|
84
|
-
encrypt(value: boolean): Promise<Ciphertext>;
|
|
85
|
-
/**
|
|
86
|
-
* Decrypt a ciphertext to a boolean.
|
|
87
|
-
* @param ct The ciphertext to decrypt
|
|
88
|
-
* @returns The decrypted boolean
|
|
89
|
-
*/
|
|
90
|
-
decrypt(ct: Ciphertext): Promise<boolean>;
|
|
91
|
-
/**
|
|
92
|
-
* Encrypt an 8-bit unsigned integer.
|
|
93
|
-
* @param value The value to encrypt (0-255)
|
|
94
|
-
* @returns Array of 8 encrypted bits
|
|
95
|
-
*/
|
|
96
|
-
encryptUint8(value: number): Promise<CiphertextUint8>;
|
|
97
|
-
/**
|
|
98
|
-
* Decrypt 8 ciphertexts to an 8-bit unsigned integer.
|
|
99
|
-
* @param cts Array of 8 encrypted bits
|
|
100
|
-
* @returns The decrypted value (0-255)
|
|
101
|
-
*/
|
|
102
|
-
decryptUint8(cts: CiphertextUint8): Promise<number>;
|
|
103
|
-
/**
|
|
104
|
-
* Perform logical AND on two encrypted bits.
|
|
105
|
-
*/
|
|
106
|
-
and(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
107
|
-
/**
|
|
108
|
-
* Perform logical OR on two encrypted bits.
|
|
109
|
-
*/
|
|
110
|
-
or(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
111
|
-
/**
|
|
112
|
-
* Perform logical XOR on two encrypted bits.
|
|
113
|
-
*/
|
|
114
|
-
xor(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
115
|
-
/**
|
|
116
|
-
* Perform logical NOT on an encrypted bit.
|
|
117
|
-
*/
|
|
118
|
-
not(ct: Ciphertext): Promise<Ciphertext>;
|
|
119
|
-
/**
|
|
120
|
-
* Perform logical NAND on two encrypted bits.
|
|
121
|
-
*/
|
|
122
|
-
nand(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
123
|
-
/**
|
|
124
|
-
* Perform logical NOR on two encrypted bits.
|
|
125
|
-
*/
|
|
126
|
-
nor(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
127
|
-
/**
|
|
128
|
-
* Perform logical XNOR on two encrypted bits.
|
|
129
|
-
*/
|
|
130
|
-
xnor(ct1: Ciphertext, ct2: Ciphertext): Promise<Ciphertext>;
|
|
131
|
-
/**
|
|
132
|
-
* Multiplexer: if sel then ctTrue else ctFalse.
|
|
133
|
-
*/
|
|
134
|
-
mux(sel: Ciphertext, ctTrue: Ciphertext, ctFalse: Ciphertext): Promise<Ciphertext>;
|
|
135
|
-
/**
|
|
136
|
-
* Compare two encrypted uint8 values.
|
|
137
|
-
* @returns Encrypted result: true if a < b
|
|
138
|
-
*/
|
|
139
|
-
compare(a: CiphertextUint8, b: CiphertextUint8): Promise<Ciphertext>;
|
|
140
|
-
/**
|
|
141
|
-
* Add two encrypted uint8 values.
|
|
142
|
-
*/
|
|
143
|
-
add(a: CiphertextUint8, b: CiphertextUint8): Promise<CiphertextUint8>;
|
|
144
|
-
/**
|
|
145
|
-
* Subtract two encrypted uint8 values (a - b).
|
|
146
|
-
*/
|
|
147
|
-
sub(a: CiphertextUint8, b: CiphertextUint8): Promise<CiphertextUint8>;
|
|
148
|
-
/**
|
|
149
|
-
* Multiply two encrypted uint8 values.
|
|
150
|
-
* Returns lower 8 bits of result.
|
|
151
|
-
*/
|
|
152
|
-
mul(a: CiphertextUint8, b: CiphertextUint8): Promise<CiphertextUint8>;
|
|
153
|
-
}
|
|
154
|
-
declare global {
|
|
155
|
-
interface Window extends TFHEWasmRaw {
|
|
156
|
-
Go: new () => GoInstance;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Go runtime instance for WASM.
|
|
161
|
-
*/
|
|
162
|
-
export interface GoInstance {
|
|
163
|
-
importObject: WebAssembly.Imports;
|
|
164
|
-
run(instance: WebAssembly.Instance): Promise<void>;
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../js/types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG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H,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACvE;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAO,SAAQ,WAAW;QAClC,EAAE,EAAE,UAAU,UAAU,CAAC;KAC1B;CACF;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC;IAClC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../js/types.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,wCAAwC"}
|
package/pkg/tfhe.wasm
DELETED
|
Binary file
|