@enclave-e3/wasm 0.1.4 → 0.1.6
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 +11 -8
- package/dist/node/e3_wasm.d.ts +73 -2
- package/dist/node/e3_wasm.js +342 -108
- package/dist/node/e3_wasm_bg.wasm +0 -0
- package/dist/node/e3_wasm_bg.wasm.d.ts +9 -4
- package/dist/web/e3_wasm.d.ts +82 -6
- package/dist/web/e3_wasm.js +322 -96
- package/dist/web/e3_wasm_base64.js +1 -1
- package/init.d.ts +3 -3
- package/init_node.cjs +1 -1
- package/init_web.js +12 -12
- package/package.json +14 -7
- package/LICENSE.md +0 -165
package/README.md
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
# Wasm bundle for enclave
|
|
2
2
|
|
|
3
|
-
Here we export wasm funcionality for consumption in typescript to enable use to share code between
|
|
3
|
+
Here we export wasm funcionality for consumption in typescript to enable use to share code between
|
|
4
|
+
Rust and Typescript.
|
|
4
5
|
|
|
5
6
|
## Usage
|
|
6
7
|
|
|
7
|
-
This package exposes an `init` subpackage default function which should be used to universally load
|
|
8
|
+
This package exposes an `init` subpackage default function which should be used to universally load
|
|
9
|
+
the wasm module instead of exporting the default loader.
|
|
8
10
|
|
|
9
|
-
This is because in modern node there is no need for preloading however in the browser we still need
|
|
11
|
+
This is because in modern node there is no need for preloading however in the browser we still need
|
|
12
|
+
to load the wasm bundle.
|
|
10
13
|
|
|
11
14
|
##### ❌ DONT USE THE DEFAULT INIT
|
|
12
15
|
|
|
13
16
|
```ts
|
|
14
17
|
// Bad! Because this uses the raw loader which doesn't exist in node contexts
|
|
15
|
-
import init, { bfvEncryptNumber } from
|
|
18
|
+
import init, { bfvEncryptNumber } from '@enclave-e3/wasm'
|
|
16
19
|
```
|
|
17
20
|
|
|
18
21
|
##### ✅ DO USE THE EXPORTED SUBMODULE
|
|
19
22
|
|
|
20
23
|
```ts
|
|
21
24
|
// Good! Use the universal loader
|
|
22
|
-
import init from
|
|
23
|
-
import { bfvEncryptNumber } from
|
|
25
|
+
import init from '@enclave-e3/wasm/init'
|
|
26
|
+
import { bfvEncryptNumber } from '@enclave-e3/wasm'
|
|
24
27
|
|
|
25
28
|
export async function bfvEncryptNumber(
|
|
26
29
|
data: bigint,
|
|
@@ -29,7 +32,7 @@ export async function bfvEncryptNumber(
|
|
|
29
32
|
plaintext_modulus: bigint,
|
|
30
33
|
moduli: bigint,
|
|
31
34
|
): Promise<Uint8Array> {
|
|
32
|
-
await init()
|
|
33
|
-
return bfv_encrypt_number(data, public_key, degree, plaintext_modulus, moduli)
|
|
35
|
+
await init()
|
|
36
|
+
return bfv_encrypt_number(data, public_key, degree, plaintext_modulus, moduli)
|
|
34
37
|
}
|
|
35
38
|
```
|
package/dist/node/e3_wasm.d.ts
CHANGED
|
@@ -19,7 +19,27 @@
|
|
|
19
19
|
*
|
|
20
20
|
* Panics if the data cannot be encrypted
|
|
21
21
|
*/
|
|
22
|
-
export function bfv_encrypt_number(data: bigint, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli:
|
|
22
|
+
export function bfv_encrypt_number(data: bigint, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli: BigUint64Array): Uint8Array;
|
|
23
|
+
/**
|
|
24
|
+
* A function to encrypt a Vec<u64> value using BFV and default params.
|
|
25
|
+
*
|
|
26
|
+
* # Arguments
|
|
27
|
+
*
|
|
28
|
+
* * `data` - The data to encrypt - must be a Vec<u64>
|
|
29
|
+
* * `public_key` - The public key to be used for encryption
|
|
30
|
+
* * `degree` - Polynomial degree for BFV parameters
|
|
31
|
+
* * `plaintext_modulus` - Plaintext modulus for BFV parameters
|
|
32
|
+
* * `moduli` - Modulus for BFV parameters
|
|
33
|
+
*
|
|
34
|
+
* # Returns
|
|
35
|
+
*
|
|
36
|
+
* Returns a `Result<Vec<u8>, JsValue>` containing the encrypted data and any errors.
|
|
37
|
+
*
|
|
38
|
+
* # Panics
|
|
39
|
+
*
|
|
40
|
+
* Panics if the data cannot be encrypted
|
|
41
|
+
*/
|
|
42
|
+
export function bfv_encrypt_vector(data: BigUint64Array, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli: BigUint64Array): Uint8Array;
|
|
23
43
|
/**
|
|
24
44
|
* A function to encrypt a u64 value using BFV and default params and
|
|
25
45
|
* generate circuit inputs for Greco
|
|
@@ -40,4 +60,55 @@ export function bfv_encrypt_number(data: bigint, public_key: Uint8Array, degree:
|
|
|
40
60
|
*
|
|
41
61
|
* Panics if the data cannot be encrypted
|
|
42
62
|
*/
|
|
43
|
-
export function bfv_verifiable_encrypt_number(data: bigint, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli:
|
|
63
|
+
export function bfv_verifiable_encrypt_number(data: bigint, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli: BigUint64Array): any[];
|
|
64
|
+
/**
|
|
65
|
+
* A function to encrypt a Vec<u64> value using BFV and default params and
|
|
66
|
+
* generate circuit inputs for Greco
|
|
67
|
+
*
|
|
68
|
+
* # Arguments
|
|
69
|
+
*
|
|
70
|
+
* * `data` - The data to encrypt - must be a Vec<u64>
|
|
71
|
+
* * `public_key` - The public key to be used for encryption
|
|
72
|
+
* * `degree` - Polynomial degree for BFV parameters
|
|
73
|
+
* * `plaintext_modulus` - Plaintext modulus for BFV parameters
|
|
74
|
+
* * `moduli` - Modulus for BFV parameters
|
|
75
|
+
*
|
|
76
|
+
* # Returns
|
|
77
|
+
*
|
|
78
|
+
* Returns a `Result<Vec<JsValue>, JsValue>` containing the encrypted data, circuit inputs and any errors.
|
|
79
|
+
*
|
|
80
|
+
* # Panics
|
|
81
|
+
*
|
|
82
|
+
* Panics if the data cannot be encrypted
|
|
83
|
+
*/
|
|
84
|
+
export function bfv_verifiable_encrypt_vector(data: BigUint64Array, public_key: Uint8Array, degree: number, plaintext_modulus: bigint, moduli: BigUint64Array): any[];
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves a BFV parameter set by name.
|
|
87
|
+
*
|
|
88
|
+
* # Parameters
|
|
89
|
+
* * `name` - Parameter set identifier (e.g., "SET_8192_1000_4")
|
|
90
|
+
*
|
|
91
|
+
* # Returns
|
|
92
|
+
* A JavaScript object with the following structure:
|
|
93
|
+
* ```typescript
|
|
94
|
+
* {
|
|
95
|
+
* degree: number; // Polynomial degree (e.g., 8192)
|
|
96
|
+
* plaintext_modulus: number; // Plaintext modulus value (e.g., 1000)
|
|
97
|
+
* moduli: bigint[]; // Array of moduli
|
|
98
|
+
* error1_variance: string | null; // Error variance as string or null
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* # Errors
|
|
103
|
+
* Returns error if the parameter set name is invalid or serialization fails.
|
|
104
|
+
*/
|
|
105
|
+
export function get_bfv_params(name: string): any;
|
|
106
|
+
/**
|
|
107
|
+
* Returns all available BFV parameter set identifiers.
|
|
108
|
+
*
|
|
109
|
+
* # Returns
|
|
110
|
+
* Array of parameter set names that can be passed to `get_bfv_params()`.
|
|
111
|
+
* Includes both production-ready sets (e.g., "SET_8192_1000_4") and
|
|
112
|
+
* insecure sets for testing (prefixed with "INSECURE_").
|
|
113
|
+
*/
|
|
114
|
+
export function get_bfv_params_list(): string[];
|