@luxfhe/wasm 0.2.1 → 0.2.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 +101 -18
- package/dist/node/index.d.cts +71 -8
- package/dist/node/index.d.ts +71 -8
- package/dist/node/index.js +92 -17
- package/dist/web/index.cjs +91 -9
- package/dist/web/index.d.cts +71 -8
- package/dist/web/index.d.ts +71 -8
- package/dist/web/index.js +82 -8
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -30,29 +30,42 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/node.ts
|
|
31
31
|
var node_exports = {};
|
|
32
32
|
__export(node_exports, {
|
|
33
|
+
CompactCiphertextList: () => CompactCiphertextList,
|
|
34
|
+
CompactCiphertextListBuilder: () => CompactCiphertextListBuilder,
|
|
35
|
+
CompactPkeCrs: () => CompactPkeCrs,
|
|
36
|
+
CompactPkePublicParams: () => CompactPkePublicParams,
|
|
37
|
+
TfheCompactPublicKey: () => TfheCompactPublicKey,
|
|
38
|
+
ZkComputeLoad: () => ZkComputeLoad,
|
|
33
39
|
decrypt: () => decrypt,
|
|
34
|
-
default: () =>
|
|
40
|
+
default: () => initTFHE,
|
|
35
41
|
encrypt: () => encrypt,
|
|
36
42
|
generateKeys: () => generateKeys,
|
|
37
43
|
getLuxFHE: () => getLuxFHE,
|
|
38
|
-
init: () => init
|
|
44
|
+
init: () => init,
|
|
45
|
+
initThreadPool: () => initThreadPool,
|
|
46
|
+
init_panic_hook: () => init_panic_hook
|
|
39
47
|
});
|
|
40
48
|
module.exports = __toCommonJS(node_exports);
|
|
41
49
|
var fs = __toESM(require("fs"), 1);
|
|
42
50
|
var path = __toESM(require("path"), 1);
|
|
43
51
|
var wasmInstance = null;
|
|
44
52
|
var goInstance = null;
|
|
53
|
+
var initPromise = null;
|
|
45
54
|
async function init() {
|
|
46
55
|
if (wasmInstance) return;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
if (initPromise) return initPromise;
|
|
57
|
+
initPromise = (async () => {
|
|
58
|
+
const wasmExecPath = path.join(__dirname, "..", "wasm", "wasm_exec.js");
|
|
59
|
+
require(wasmExecPath);
|
|
60
|
+
const go = new Go();
|
|
61
|
+
goInstance = go;
|
|
62
|
+
const wasmPath = path.join(__dirname, "..", "wasm", "luxfhe.wasm");
|
|
63
|
+
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
64
|
+
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
65
|
+
wasmInstance = await WebAssembly.instantiate(wasmModule, go.importObject);
|
|
66
|
+
go.run(wasmInstance);
|
|
67
|
+
})();
|
|
68
|
+
return initPromise;
|
|
56
69
|
}
|
|
57
70
|
function getLuxFHE() {
|
|
58
71
|
if (!wasmInstance) {
|
|
@@ -75,18 +88,88 @@ async function decrypt(ciphertext, privateKey) {
|
|
|
75
88
|
const fhe = getLuxFHE();
|
|
76
89
|
return fhe.decrypt(ciphertext, privateKey);
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
function init_panic_hook() {
|
|
92
|
+
}
|
|
93
|
+
async function initThreadPool(numThreads) {
|
|
94
|
+
}
|
|
95
|
+
var TfheCompactPublicKey = class _TfheCompactPublicKey {
|
|
96
|
+
key;
|
|
97
|
+
constructor(key) {
|
|
98
|
+
this.key = key || new Uint8Array();
|
|
99
|
+
}
|
|
100
|
+
static deserialize(bytes) {
|
|
101
|
+
return new _TfheCompactPublicKey(bytes);
|
|
102
|
+
}
|
|
103
|
+
serialize() {
|
|
104
|
+
return this.key;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var CompactPkeCrs = class _CompactPkeCrs {
|
|
108
|
+
static from_config(config, maxBits) {
|
|
109
|
+
return new _CompactPkeCrs();
|
|
110
|
+
}
|
|
84
111
|
};
|
|
112
|
+
var CompactPkePublicParams = class _CompactPkePublicParams {
|
|
113
|
+
static new(crs, maxBits) {
|
|
114
|
+
return new _CompactPkePublicParams();
|
|
115
|
+
}
|
|
116
|
+
static deserialize(bytes) {
|
|
117
|
+
return new _CompactPkePublicParams();
|
|
118
|
+
}
|
|
119
|
+
serialize() {
|
|
120
|
+
return new Uint8Array();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var CompactCiphertextList = class _CompactCiphertextList {
|
|
124
|
+
data;
|
|
125
|
+
constructor(data) {
|
|
126
|
+
this.data = data || new Uint8Array();
|
|
127
|
+
}
|
|
128
|
+
static builder(params) {
|
|
129
|
+
return new CompactCiphertextListBuilder();
|
|
130
|
+
}
|
|
131
|
+
static deserialize(bytes) {
|
|
132
|
+
return new _CompactCiphertextList(bytes);
|
|
133
|
+
}
|
|
134
|
+
serialize() {
|
|
135
|
+
return this.data;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var CompactCiphertextListBuilder = class {
|
|
139
|
+
push(value) {
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
build() {
|
|
143
|
+
return new CompactCiphertextList();
|
|
144
|
+
}
|
|
145
|
+
build_with_proof_packed(key, load) {
|
|
146
|
+
return {
|
|
147
|
+
list: new CompactCiphertextList(),
|
|
148
|
+
proof: new Uint8Array()
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var ZkComputeLoad = /* @__PURE__ */ ((ZkComputeLoad2) => {
|
|
153
|
+
ZkComputeLoad2["Proof"] = "Proof";
|
|
154
|
+
ZkComputeLoad2["Verify"] = "Verify";
|
|
155
|
+
return ZkComputeLoad2;
|
|
156
|
+
})(ZkComputeLoad || {});
|
|
157
|
+
async function initTFHE(options) {
|
|
158
|
+
await init();
|
|
159
|
+
}
|
|
85
160
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
161
|
0 && (module.exports = {
|
|
162
|
+
CompactCiphertextList,
|
|
163
|
+
CompactCiphertextListBuilder,
|
|
164
|
+
CompactPkeCrs,
|
|
165
|
+
CompactPkePublicParams,
|
|
166
|
+
TfheCompactPublicKey,
|
|
167
|
+
ZkComputeLoad,
|
|
87
168
|
decrypt,
|
|
88
169
|
encrypt,
|
|
89
170
|
generateKeys,
|
|
90
171
|
getLuxFHE,
|
|
91
|
-
init
|
|
172
|
+
init,
|
|
173
|
+
initThreadPool,
|
|
174
|
+
init_panic_hook
|
|
92
175
|
});
|
package/dist/node/index.d.cts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* LuxFHE WASM Node.js bindings
|
|
3
3
|
*
|
|
4
4
|
* Native Go FHE compiled to WebAssembly for Node.js
|
|
5
|
+
* Includes backward-compatible exports for Zama TFHE interface
|
|
5
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* InitInput type for backward compatibility with Zama TFHE
|
|
9
|
+
*/
|
|
10
|
+
type InitInput = string | URL | ArrayBuffer | WebAssembly.Module;
|
|
6
11
|
/**
|
|
7
12
|
* Initialize the FHE WASM module
|
|
8
13
|
*/
|
|
@@ -28,12 +33,70 @@ declare function encrypt(value: number | bigint, publicKey: Uint8Array): Promise
|
|
|
28
33
|
* Decrypt a ciphertext
|
|
29
34
|
*/
|
|
30
35
|
declare function decrypt(ciphertext: Uint8Array, privateKey: Uint8Array): Promise<bigint>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize panic hook - stub for Zama compatibility
|
|
38
|
+
*/
|
|
39
|
+
declare function init_panic_hook(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize thread pool - stub for Zama compatibility
|
|
42
|
+
*/
|
|
43
|
+
declare function initThreadPool(numThreads?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* TfheCompactPublicKey - stub class for Zama compatibility
|
|
46
|
+
*/
|
|
47
|
+
declare class TfheCompactPublicKey {
|
|
48
|
+
private key;
|
|
49
|
+
constructor(key?: Uint8Array);
|
|
50
|
+
static deserialize(bytes: Uint8Array): TfheCompactPublicKey;
|
|
51
|
+
serialize(): Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* CompactPkeCrs - stub class for Zama compatibility
|
|
55
|
+
*/
|
|
56
|
+
declare class CompactPkeCrs {
|
|
57
|
+
static from_config(config: any, maxBits: number): CompactPkeCrs;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* CompactPkePublicParams - stub class for Zama compatibility
|
|
61
|
+
*/
|
|
62
|
+
declare class CompactPkePublicParams {
|
|
63
|
+
static new(crs: CompactPkeCrs, maxBits: number): CompactPkePublicParams;
|
|
64
|
+
static deserialize(bytes: Uint8Array): CompactPkePublicParams;
|
|
65
|
+
serialize(): Uint8Array;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* CompactCiphertextList - stub class for Zama compatibility
|
|
69
|
+
*/
|
|
70
|
+
declare class CompactCiphertextList {
|
|
71
|
+
private data;
|
|
72
|
+
constructor(data?: Uint8Array);
|
|
73
|
+
static builder(params: CompactPkePublicParams): CompactCiphertextListBuilder;
|
|
74
|
+
static deserialize(bytes: Uint8Array): CompactCiphertextList;
|
|
75
|
+
serialize(): Uint8Array;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* CompactCiphertextListBuilder - stub class for Zama compatibility
|
|
79
|
+
*/
|
|
80
|
+
declare class CompactCiphertextListBuilder {
|
|
81
|
+
push(value: any): CompactCiphertextListBuilder;
|
|
82
|
+
build(): CompactCiphertextList;
|
|
83
|
+
build_with_proof_packed(key: TfheCompactPublicKey, load: ZkComputeLoad): {
|
|
84
|
+
list: CompactCiphertextList;
|
|
85
|
+
proof: Uint8Array;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ZkComputeLoad enum - stub for Zama compatibility
|
|
90
|
+
*/
|
|
91
|
+
declare enum ZkComputeLoad {
|
|
92
|
+
Proof = "Proof",
|
|
93
|
+
Verify = "Verify"
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default export matching Zama TFHE init signature
|
|
97
|
+
*/
|
|
98
|
+
declare function initTFHE(options?: {
|
|
99
|
+
module_or_path?: InitInput;
|
|
100
|
+
}): Promise<void>;
|
|
38
101
|
|
|
39
|
-
export { type LuxFHEKeys, decrypt,
|
|
102
|
+
export { CompactCiphertextList, CompactCiphertextListBuilder, CompactPkeCrs, CompactPkePublicParams, type InitInput, type LuxFHEKeys, TfheCompactPublicKey, ZkComputeLoad, decrypt, initTFHE as default, encrypt, generateKeys, getLuxFHE, init, initThreadPool, init_panic_hook };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* LuxFHE WASM Node.js bindings
|
|
3
3
|
*
|
|
4
4
|
* Native Go FHE compiled to WebAssembly for Node.js
|
|
5
|
+
* Includes backward-compatible exports for Zama TFHE interface
|
|
5
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* InitInput type for backward compatibility with Zama TFHE
|
|
9
|
+
*/
|
|
10
|
+
type InitInput = string | URL | ArrayBuffer | WebAssembly.Module;
|
|
6
11
|
/**
|
|
7
12
|
* Initialize the FHE WASM module
|
|
8
13
|
*/
|
|
@@ -28,12 +33,70 @@ declare function encrypt(value: number | bigint, publicKey: Uint8Array): Promise
|
|
|
28
33
|
* Decrypt a ciphertext
|
|
29
34
|
*/
|
|
30
35
|
declare function decrypt(ciphertext: Uint8Array, privateKey: Uint8Array): Promise<bigint>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize panic hook - stub for Zama compatibility
|
|
38
|
+
*/
|
|
39
|
+
declare function init_panic_hook(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize thread pool - stub for Zama compatibility
|
|
42
|
+
*/
|
|
43
|
+
declare function initThreadPool(numThreads?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* TfheCompactPublicKey - stub class for Zama compatibility
|
|
46
|
+
*/
|
|
47
|
+
declare class TfheCompactPublicKey {
|
|
48
|
+
private key;
|
|
49
|
+
constructor(key?: Uint8Array);
|
|
50
|
+
static deserialize(bytes: Uint8Array): TfheCompactPublicKey;
|
|
51
|
+
serialize(): Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* CompactPkeCrs - stub class for Zama compatibility
|
|
55
|
+
*/
|
|
56
|
+
declare class CompactPkeCrs {
|
|
57
|
+
static from_config(config: any, maxBits: number): CompactPkeCrs;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* CompactPkePublicParams - stub class for Zama compatibility
|
|
61
|
+
*/
|
|
62
|
+
declare class CompactPkePublicParams {
|
|
63
|
+
static new(crs: CompactPkeCrs, maxBits: number): CompactPkePublicParams;
|
|
64
|
+
static deserialize(bytes: Uint8Array): CompactPkePublicParams;
|
|
65
|
+
serialize(): Uint8Array;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* CompactCiphertextList - stub class for Zama compatibility
|
|
69
|
+
*/
|
|
70
|
+
declare class CompactCiphertextList {
|
|
71
|
+
private data;
|
|
72
|
+
constructor(data?: Uint8Array);
|
|
73
|
+
static builder(params: CompactPkePublicParams): CompactCiphertextListBuilder;
|
|
74
|
+
static deserialize(bytes: Uint8Array): CompactCiphertextList;
|
|
75
|
+
serialize(): Uint8Array;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* CompactCiphertextListBuilder - stub class for Zama compatibility
|
|
79
|
+
*/
|
|
80
|
+
declare class CompactCiphertextListBuilder {
|
|
81
|
+
push(value: any): CompactCiphertextListBuilder;
|
|
82
|
+
build(): CompactCiphertextList;
|
|
83
|
+
build_with_proof_packed(key: TfheCompactPublicKey, load: ZkComputeLoad): {
|
|
84
|
+
list: CompactCiphertextList;
|
|
85
|
+
proof: Uint8Array;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ZkComputeLoad enum - stub for Zama compatibility
|
|
90
|
+
*/
|
|
91
|
+
declare enum ZkComputeLoad {
|
|
92
|
+
Proof = "Proof",
|
|
93
|
+
Verify = "Verify"
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default export matching Zama TFHE init signature
|
|
97
|
+
*/
|
|
98
|
+
declare function initTFHE(options?: {
|
|
99
|
+
module_or_path?: InitInput;
|
|
100
|
+
}): Promise<void>;
|
|
38
101
|
|
|
39
|
-
export { type LuxFHEKeys, decrypt,
|
|
102
|
+
export { CompactCiphertextList, CompactCiphertextListBuilder, CompactPkeCrs, CompactPkePublicParams, type InitInput, type LuxFHEKeys, TfheCompactPublicKey, ZkComputeLoad, decrypt, initTFHE as default, encrypt, generateKeys, getLuxFHE, init, initThreadPool, init_panic_hook };
|
package/dist/node/index.js
CHANGED
|
@@ -10,17 +10,22 @@ import * as fs from "fs";
|
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
var wasmInstance = null;
|
|
12
12
|
var goInstance = null;
|
|
13
|
+
var initPromise = null;
|
|
13
14
|
async function init() {
|
|
14
15
|
if (wasmInstance) return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
if (initPromise) return initPromise;
|
|
17
|
+
initPromise = (async () => {
|
|
18
|
+
const wasmExecPath = path.join(__dirname, "..", "wasm", "wasm_exec.js");
|
|
19
|
+
__require(wasmExecPath);
|
|
20
|
+
const go = new Go();
|
|
21
|
+
goInstance = go;
|
|
22
|
+
const wasmPath = path.join(__dirname, "..", "wasm", "luxfhe.wasm");
|
|
23
|
+
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
24
|
+
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
25
|
+
wasmInstance = await WebAssembly.instantiate(wasmModule, go.importObject);
|
|
26
|
+
go.run(wasmInstance);
|
|
27
|
+
})();
|
|
28
|
+
return initPromise;
|
|
24
29
|
}
|
|
25
30
|
function getLuxFHE() {
|
|
26
31
|
if (!wasmInstance) {
|
|
@@ -43,18 +48,88 @@ async function decrypt(ciphertext, privateKey) {
|
|
|
43
48
|
const fhe = getLuxFHE();
|
|
44
49
|
return fhe.decrypt(ciphertext, privateKey);
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
function init_panic_hook() {
|
|
52
|
+
}
|
|
53
|
+
async function initThreadPool(numThreads) {
|
|
54
|
+
}
|
|
55
|
+
var TfheCompactPublicKey = class _TfheCompactPublicKey {
|
|
56
|
+
key;
|
|
57
|
+
constructor(key) {
|
|
58
|
+
this.key = key || new Uint8Array();
|
|
59
|
+
}
|
|
60
|
+
static deserialize(bytes) {
|
|
61
|
+
return new _TfheCompactPublicKey(bytes);
|
|
62
|
+
}
|
|
63
|
+
serialize() {
|
|
64
|
+
return this.key;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var CompactPkeCrs = class _CompactPkeCrs {
|
|
68
|
+
static from_config(config, maxBits) {
|
|
69
|
+
return new _CompactPkeCrs();
|
|
70
|
+
}
|
|
52
71
|
};
|
|
72
|
+
var CompactPkePublicParams = class _CompactPkePublicParams {
|
|
73
|
+
static new(crs, maxBits) {
|
|
74
|
+
return new _CompactPkePublicParams();
|
|
75
|
+
}
|
|
76
|
+
static deserialize(bytes) {
|
|
77
|
+
return new _CompactPkePublicParams();
|
|
78
|
+
}
|
|
79
|
+
serialize() {
|
|
80
|
+
return new Uint8Array();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var CompactCiphertextList = class _CompactCiphertextList {
|
|
84
|
+
data;
|
|
85
|
+
constructor(data) {
|
|
86
|
+
this.data = data || new Uint8Array();
|
|
87
|
+
}
|
|
88
|
+
static builder(params) {
|
|
89
|
+
return new CompactCiphertextListBuilder();
|
|
90
|
+
}
|
|
91
|
+
static deserialize(bytes) {
|
|
92
|
+
return new _CompactCiphertextList(bytes);
|
|
93
|
+
}
|
|
94
|
+
serialize() {
|
|
95
|
+
return this.data;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var CompactCiphertextListBuilder = class {
|
|
99
|
+
push(value) {
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
build() {
|
|
103
|
+
return new CompactCiphertextList();
|
|
104
|
+
}
|
|
105
|
+
build_with_proof_packed(key, load) {
|
|
106
|
+
return {
|
|
107
|
+
list: new CompactCiphertextList(),
|
|
108
|
+
proof: new Uint8Array()
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var ZkComputeLoad = /* @__PURE__ */ ((ZkComputeLoad2) => {
|
|
113
|
+
ZkComputeLoad2["Proof"] = "Proof";
|
|
114
|
+
ZkComputeLoad2["Verify"] = "Verify";
|
|
115
|
+
return ZkComputeLoad2;
|
|
116
|
+
})(ZkComputeLoad || {});
|
|
117
|
+
async function initTFHE(options) {
|
|
118
|
+
await init();
|
|
119
|
+
}
|
|
53
120
|
export {
|
|
121
|
+
CompactCiphertextList,
|
|
122
|
+
CompactCiphertextListBuilder,
|
|
123
|
+
CompactPkeCrs,
|
|
124
|
+
CompactPkePublicParams,
|
|
125
|
+
TfheCompactPublicKey,
|
|
126
|
+
ZkComputeLoad,
|
|
54
127
|
decrypt,
|
|
55
|
-
|
|
128
|
+
initTFHE as default,
|
|
56
129
|
encrypt,
|
|
57
130
|
generateKeys,
|
|
58
131
|
getLuxFHE,
|
|
59
|
-
init
|
|
132
|
+
init,
|
|
133
|
+
initThreadPool,
|
|
134
|
+
init_panic_hook
|
|
60
135
|
};
|
package/dist/web/index.cjs
CHANGED
|
@@ -20,12 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/web.ts
|
|
21
21
|
var web_exports = {};
|
|
22
22
|
__export(web_exports, {
|
|
23
|
+
CompactCiphertextList: () => CompactCiphertextList,
|
|
24
|
+
CompactCiphertextListBuilder: () => CompactCiphertextListBuilder,
|
|
25
|
+
CompactPkeCrs: () => CompactPkeCrs,
|
|
26
|
+
CompactPkePublicParams: () => CompactPkePublicParams,
|
|
27
|
+
TfheCompactPublicKey: () => TfheCompactPublicKey,
|
|
28
|
+
ZkComputeLoad: () => ZkComputeLoad,
|
|
23
29
|
decrypt: () => decrypt,
|
|
24
|
-
default: () =>
|
|
30
|
+
default: () => initTFHE,
|
|
25
31
|
encrypt: () => encrypt,
|
|
26
32
|
generateKeys: () => generateKeys,
|
|
27
33
|
getLuxFHE: () => getLuxFHE,
|
|
28
|
-
init: () => init
|
|
34
|
+
init: () => init,
|
|
35
|
+
initThreadPool: () => initThreadPool,
|
|
36
|
+
init_panic_hook: () => init_panic_hook
|
|
29
37
|
});
|
|
30
38
|
module.exports = __toCommonJS(web_exports);
|
|
31
39
|
var import_meta = {};
|
|
@@ -80,18 +88,92 @@ async function decrypt(ciphertext, privateKey) {
|
|
|
80
88
|
const fhe = getLuxFHE();
|
|
81
89
|
return fhe.decrypt(ciphertext, privateKey);
|
|
82
90
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
function init_panic_hook() {
|
|
92
|
+
}
|
|
93
|
+
async function initThreadPool(numThreads) {
|
|
94
|
+
}
|
|
95
|
+
var TfheCompactPublicKey = class _TfheCompactPublicKey {
|
|
96
|
+
key;
|
|
97
|
+
constructor(key) {
|
|
98
|
+
this.key = key || new Uint8Array();
|
|
99
|
+
}
|
|
100
|
+
static deserialize(bytes) {
|
|
101
|
+
return new _TfheCompactPublicKey(bytes);
|
|
102
|
+
}
|
|
103
|
+
serialize() {
|
|
104
|
+
return this.key;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var CompactPkeCrs = class _CompactPkeCrs {
|
|
108
|
+
static from_config(config, maxBits) {
|
|
109
|
+
return new _CompactPkeCrs();
|
|
110
|
+
}
|
|
89
111
|
};
|
|
112
|
+
var CompactPkePublicParams = class _CompactPkePublicParams {
|
|
113
|
+
static new(crs, maxBits) {
|
|
114
|
+
return new _CompactPkePublicParams();
|
|
115
|
+
}
|
|
116
|
+
static deserialize(bytes) {
|
|
117
|
+
return new _CompactPkePublicParams();
|
|
118
|
+
}
|
|
119
|
+
serialize() {
|
|
120
|
+
return new Uint8Array();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var CompactCiphertextList = class _CompactCiphertextList {
|
|
124
|
+
data;
|
|
125
|
+
constructor(data) {
|
|
126
|
+
this.data = data || new Uint8Array();
|
|
127
|
+
}
|
|
128
|
+
static builder(params) {
|
|
129
|
+
return new CompactCiphertextListBuilder();
|
|
130
|
+
}
|
|
131
|
+
static deserialize(bytes) {
|
|
132
|
+
return new _CompactCiphertextList(bytes);
|
|
133
|
+
}
|
|
134
|
+
serialize() {
|
|
135
|
+
return this.data;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var CompactCiphertextListBuilder = class {
|
|
139
|
+
push(value) {
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
build() {
|
|
143
|
+
return new CompactCiphertextList();
|
|
144
|
+
}
|
|
145
|
+
build_with_proof_packed(key, load) {
|
|
146
|
+
return {
|
|
147
|
+
list: new CompactCiphertextList(),
|
|
148
|
+
proof: new Uint8Array()
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var ZkComputeLoad = /* @__PURE__ */ ((ZkComputeLoad2) => {
|
|
153
|
+
ZkComputeLoad2["Proof"] = "Proof";
|
|
154
|
+
ZkComputeLoad2["Verify"] = "Verify";
|
|
155
|
+
return ZkComputeLoad2;
|
|
156
|
+
})(ZkComputeLoad || {});
|
|
157
|
+
async function initTFHE(options) {
|
|
158
|
+
if (options?.module_or_path && typeof options.module_or_path === "string") {
|
|
159
|
+
await init(options.module_or_path);
|
|
160
|
+
} else {
|
|
161
|
+
await init();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
90
164
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
165
|
0 && (module.exports = {
|
|
166
|
+
CompactCiphertextList,
|
|
167
|
+
CompactCiphertextListBuilder,
|
|
168
|
+
CompactPkeCrs,
|
|
169
|
+
CompactPkePublicParams,
|
|
170
|
+
TfheCompactPublicKey,
|
|
171
|
+
ZkComputeLoad,
|
|
92
172
|
decrypt,
|
|
93
173
|
encrypt,
|
|
94
174
|
generateKeys,
|
|
95
175
|
getLuxFHE,
|
|
96
|
-
init
|
|
176
|
+
init,
|
|
177
|
+
initThreadPool,
|
|
178
|
+
init_panic_hook
|
|
97
179
|
});
|
package/dist/web/index.d.cts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* LuxFHE WASM Web bindings
|
|
3
3
|
*
|
|
4
4
|
* Native Go FHE compiled to WebAssembly for browser
|
|
5
|
+
* Includes backward-compatible exports for Zama TFHE interface
|
|
5
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* InitInput type for backward compatibility with Zama TFHE
|
|
9
|
+
*/
|
|
10
|
+
type InitInput = string | URL | Request | Response | ArrayBuffer | WebAssembly.Module;
|
|
6
11
|
/**
|
|
7
12
|
* Initialize the FHE WASM module
|
|
8
13
|
*/
|
|
@@ -28,12 +33,70 @@ declare function encrypt(value: number | bigint, publicKey: Uint8Array): Promise
|
|
|
28
33
|
* Decrypt a ciphertext
|
|
29
34
|
*/
|
|
30
35
|
declare function decrypt(ciphertext: Uint8Array, privateKey: Uint8Array): Promise<bigint>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize panic hook - stub for Zama compatibility
|
|
38
|
+
*/
|
|
39
|
+
declare function init_panic_hook(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize thread pool - stub for Zama compatibility
|
|
42
|
+
*/
|
|
43
|
+
declare function initThreadPool(numThreads?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* TfheCompactPublicKey - stub class for Zama compatibility
|
|
46
|
+
*/
|
|
47
|
+
declare class TfheCompactPublicKey {
|
|
48
|
+
private key;
|
|
49
|
+
constructor(key?: Uint8Array);
|
|
50
|
+
static deserialize(bytes: Uint8Array): TfheCompactPublicKey;
|
|
51
|
+
serialize(): Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* CompactPkeCrs - stub class for Zama compatibility
|
|
55
|
+
*/
|
|
56
|
+
declare class CompactPkeCrs {
|
|
57
|
+
static from_config(config: any, maxBits: number): CompactPkeCrs;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* CompactPkePublicParams - stub class for Zama compatibility
|
|
61
|
+
*/
|
|
62
|
+
declare class CompactPkePublicParams {
|
|
63
|
+
static new(crs: CompactPkeCrs, maxBits: number): CompactPkePublicParams;
|
|
64
|
+
static deserialize(bytes: Uint8Array): CompactPkePublicParams;
|
|
65
|
+
serialize(): Uint8Array;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* CompactCiphertextList - stub class for Zama compatibility
|
|
69
|
+
*/
|
|
70
|
+
declare class CompactCiphertextList {
|
|
71
|
+
private data;
|
|
72
|
+
constructor(data?: Uint8Array);
|
|
73
|
+
static builder(params: CompactPkePublicParams): CompactCiphertextListBuilder;
|
|
74
|
+
static deserialize(bytes: Uint8Array): CompactCiphertextList;
|
|
75
|
+
serialize(): Uint8Array;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* CompactCiphertextListBuilder - stub class for Zama compatibility
|
|
79
|
+
*/
|
|
80
|
+
declare class CompactCiphertextListBuilder {
|
|
81
|
+
push(value: any): CompactCiphertextListBuilder;
|
|
82
|
+
build(): CompactCiphertextList;
|
|
83
|
+
build_with_proof_packed(key: TfheCompactPublicKey, load: ZkComputeLoad): {
|
|
84
|
+
list: CompactCiphertextList;
|
|
85
|
+
proof: Uint8Array;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ZkComputeLoad enum - stub for Zama compatibility
|
|
90
|
+
*/
|
|
91
|
+
declare enum ZkComputeLoad {
|
|
92
|
+
Proof = "Proof",
|
|
93
|
+
Verify = "Verify"
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default export matching Zama TFHE init signature
|
|
97
|
+
*/
|
|
98
|
+
declare function initTFHE(options?: {
|
|
99
|
+
module_or_path?: InitInput;
|
|
100
|
+
}): Promise<void>;
|
|
38
101
|
|
|
39
|
-
export { type LuxFHEKeys, decrypt,
|
|
102
|
+
export { CompactCiphertextList, CompactCiphertextListBuilder, CompactPkeCrs, CompactPkePublicParams, type InitInput, type LuxFHEKeys, TfheCompactPublicKey, ZkComputeLoad, decrypt, initTFHE as default, encrypt, generateKeys, getLuxFHE, init, initThreadPool, init_panic_hook };
|
package/dist/web/index.d.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* LuxFHE WASM Web bindings
|
|
3
3
|
*
|
|
4
4
|
* Native Go FHE compiled to WebAssembly for browser
|
|
5
|
+
* Includes backward-compatible exports for Zama TFHE interface
|
|
5
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* InitInput type for backward compatibility with Zama TFHE
|
|
9
|
+
*/
|
|
10
|
+
type InitInput = string | URL | Request | Response | ArrayBuffer | WebAssembly.Module;
|
|
6
11
|
/**
|
|
7
12
|
* Initialize the FHE WASM module
|
|
8
13
|
*/
|
|
@@ -28,12 +33,70 @@ declare function encrypt(value: number | bigint, publicKey: Uint8Array): Promise
|
|
|
28
33
|
* Decrypt a ciphertext
|
|
29
34
|
*/
|
|
30
35
|
declare function decrypt(ciphertext: Uint8Array, privateKey: Uint8Array): Promise<bigint>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize panic hook - stub for Zama compatibility
|
|
38
|
+
*/
|
|
39
|
+
declare function init_panic_hook(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize thread pool - stub for Zama compatibility
|
|
42
|
+
*/
|
|
43
|
+
declare function initThreadPool(numThreads?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* TfheCompactPublicKey - stub class for Zama compatibility
|
|
46
|
+
*/
|
|
47
|
+
declare class TfheCompactPublicKey {
|
|
48
|
+
private key;
|
|
49
|
+
constructor(key?: Uint8Array);
|
|
50
|
+
static deserialize(bytes: Uint8Array): TfheCompactPublicKey;
|
|
51
|
+
serialize(): Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* CompactPkeCrs - stub class for Zama compatibility
|
|
55
|
+
*/
|
|
56
|
+
declare class CompactPkeCrs {
|
|
57
|
+
static from_config(config: any, maxBits: number): CompactPkeCrs;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* CompactPkePublicParams - stub class for Zama compatibility
|
|
61
|
+
*/
|
|
62
|
+
declare class CompactPkePublicParams {
|
|
63
|
+
static new(crs: CompactPkeCrs, maxBits: number): CompactPkePublicParams;
|
|
64
|
+
static deserialize(bytes: Uint8Array): CompactPkePublicParams;
|
|
65
|
+
serialize(): Uint8Array;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* CompactCiphertextList - stub class for Zama compatibility
|
|
69
|
+
*/
|
|
70
|
+
declare class CompactCiphertextList {
|
|
71
|
+
private data;
|
|
72
|
+
constructor(data?: Uint8Array);
|
|
73
|
+
static builder(params: CompactPkePublicParams): CompactCiphertextListBuilder;
|
|
74
|
+
static deserialize(bytes: Uint8Array): CompactCiphertextList;
|
|
75
|
+
serialize(): Uint8Array;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* CompactCiphertextListBuilder - stub class for Zama compatibility
|
|
79
|
+
*/
|
|
80
|
+
declare class CompactCiphertextListBuilder {
|
|
81
|
+
push(value: any): CompactCiphertextListBuilder;
|
|
82
|
+
build(): CompactCiphertextList;
|
|
83
|
+
build_with_proof_packed(key: TfheCompactPublicKey, load: ZkComputeLoad): {
|
|
84
|
+
list: CompactCiphertextList;
|
|
85
|
+
proof: Uint8Array;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ZkComputeLoad enum - stub for Zama compatibility
|
|
90
|
+
*/
|
|
91
|
+
declare enum ZkComputeLoad {
|
|
92
|
+
Proof = "Proof",
|
|
93
|
+
Verify = "Verify"
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default export matching Zama TFHE init signature
|
|
97
|
+
*/
|
|
98
|
+
declare function initTFHE(options?: {
|
|
99
|
+
module_or_path?: InitInput;
|
|
100
|
+
}): Promise<void>;
|
|
38
101
|
|
|
39
|
-
export { type LuxFHEKeys, decrypt,
|
|
102
|
+
export { CompactCiphertextList, CompactCiphertextListBuilder, CompactPkeCrs, CompactPkePublicParams, type InitInput, type LuxFHEKeys, TfheCompactPublicKey, ZkComputeLoad, decrypt, initTFHE as default, encrypt, generateKeys, getLuxFHE, init, initThreadPool, init_panic_hook };
|
package/dist/web/index.js
CHANGED
|
@@ -50,18 +50,92 @@ async function decrypt(ciphertext, privateKey) {
|
|
|
50
50
|
const fhe = getLuxFHE();
|
|
51
51
|
return fhe.decrypt(ciphertext, privateKey);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
function init_panic_hook() {
|
|
54
|
+
}
|
|
55
|
+
async function initThreadPool(numThreads) {
|
|
56
|
+
}
|
|
57
|
+
var TfheCompactPublicKey = class _TfheCompactPublicKey {
|
|
58
|
+
key;
|
|
59
|
+
constructor(key) {
|
|
60
|
+
this.key = key || new Uint8Array();
|
|
61
|
+
}
|
|
62
|
+
static deserialize(bytes) {
|
|
63
|
+
return new _TfheCompactPublicKey(bytes);
|
|
64
|
+
}
|
|
65
|
+
serialize() {
|
|
66
|
+
return this.key;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var CompactPkeCrs = class _CompactPkeCrs {
|
|
70
|
+
static from_config(config, maxBits) {
|
|
71
|
+
return new _CompactPkeCrs();
|
|
72
|
+
}
|
|
59
73
|
};
|
|
74
|
+
var CompactPkePublicParams = class _CompactPkePublicParams {
|
|
75
|
+
static new(crs, maxBits) {
|
|
76
|
+
return new _CompactPkePublicParams();
|
|
77
|
+
}
|
|
78
|
+
static deserialize(bytes) {
|
|
79
|
+
return new _CompactPkePublicParams();
|
|
80
|
+
}
|
|
81
|
+
serialize() {
|
|
82
|
+
return new Uint8Array();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var CompactCiphertextList = class _CompactCiphertextList {
|
|
86
|
+
data;
|
|
87
|
+
constructor(data) {
|
|
88
|
+
this.data = data || new Uint8Array();
|
|
89
|
+
}
|
|
90
|
+
static builder(params) {
|
|
91
|
+
return new CompactCiphertextListBuilder();
|
|
92
|
+
}
|
|
93
|
+
static deserialize(bytes) {
|
|
94
|
+
return new _CompactCiphertextList(bytes);
|
|
95
|
+
}
|
|
96
|
+
serialize() {
|
|
97
|
+
return this.data;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var CompactCiphertextListBuilder = class {
|
|
101
|
+
push(value) {
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
build() {
|
|
105
|
+
return new CompactCiphertextList();
|
|
106
|
+
}
|
|
107
|
+
build_with_proof_packed(key, load) {
|
|
108
|
+
return {
|
|
109
|
+
list: new CompactCiphertextList(),
|
|
110
|
+
proof: new Uint8Array()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var ZkComputeLoad = /* @__PURE__ */ ((ZkComputeLoad2) => {
|
|
115
|
+
ZkComputeLoad2["Proof"] = "Proof";
|
|
116
|
+
ZkComputeLoad2["Verify"] = "Verify";
|
|
117
|
+
return ZkComputeLoad2;
|
|
118
|
+
})(ZkComputeLoad || {});
|
|
119
|
+
async function initTFHE(options) {
|
|
120
|
+
if (options?.module_or_path && typeof options.module_or_path === "string") {
|
|
121
|
+
await init(options.module_or_path);
|
|
122
|
+
} else {
|
|
123
|
+
await init();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
60
126
|
export {
|
|
127
|
+
CompactCiphertextList,
|
|
128
|
+
CompactCiphertextListBuilder,
|
|
129
|
+
CompactPkeCrs,
|
|
130
|
+
CompactPkePublicParams,
|
|
131
|
+
TfheCompactPublicKey,
|
|
132
|
+
ZkComputeLoad,
|
|
61
133
|
decrypt,
|
|
62
|
-
|
|
134
|
+
initTFHE as default,
|
|
63
135
|
encrypt,
|
|
64
136
|
generateKeys,
|
|
65
137
|
getLuxFHE,
|
|
66
|
-
init
|
|
138
|
+
init,
|
|
139
|
+
initThreadPool,
|
|
140
|
+
init_panic_hook
|
|
67
141
|
};
|