@lanitlabs/pqc-lnqc714 1.0.2 → 1.1.0

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 CHANGED
@@ -100,20 +100,6 @@ LNQC.getLdpcCodewordBits() // 2048
100
100
  - **Constant-time**: The `subtle` crate guards token comparison against timing side-channels.
101
101
  - **LDPC protection**: Regular column-weight-15 parity-check matrix eliminates single-check failure modes.
102
102
 
103
- ## Development
104
-
105
- ```bash
106
- # Build WASM targets
107
- wasm-pack build --target bundler --out-dir pkg/browser --release
108
- wasm-pack build --target nodejs --out-dir pkg/node --release
109
-
110
- # Test (native)
111
- cargo test --release
112
-
113
- # Publish
114
- npm publish --access public
115
- ```
116
-
117
103
  ## License
118
104
 
119
105
  MIT
package/dist/index.d.ts CHANGED
@@ -17,16 +17,13 @@ export class Ciphertext {
17
17
  }
18
18
 
19
19
  export const LNQC: {
20
- keyGen(): KeyPair;
21
- encapsulate(publicKeyA: Uint8Array, publicKeyT: Uint8Array, message: Uint8Array): Ciphertext;
22
- decapsulate(privateKey: Uint8Array, u: Uint8Array, v: Uint8Array): Uint8Array;
20
+ getVariants(): string[];
21
+ getVariantInfo(variant: string): string;
22
+ keyGen(variant: string): KeyPair;
23
+ encapsulate(variant: string, publicKeyA: Uint8Array, publicKeyT: Uint8Array, message: Uint8Array): Ciphertext;
24
+ decapsulate(variant: string, privateKey: Uint8Array, u: Uint8Array, v: Uint8Array): Uint8Array;
23
25
  constantTimeVerify(a: Uint8Array, b: Uint8Array): boolean;
24
26
  randomBits(len: number): Uint8Array;
25
- getNCols(): number;
26
- getMRows(): number;
27
- getNoiseWeight(): number;
28
- getLdpcDataBits(): number;
29
- getLdpcCodewordBits(): number;
30
27
  };
31
28
 
32
29
  export default LNQC;
package/dist/index.js CHANGED
@@ -11,31 +11,32 @@ if (isNode) {
11
11
  export type { KeyPair, Ciphertext } from '../pkg/browser/pqc_lnqc714';
12
12
 
13
13
  export const LNQC = {
14
- keyGen: (): import('../pkg/browser/pqc_lnqc714').KeyPair => engine.key_gen(),
14
+ getVariants: (): string[] => engine.get_variants(),
15
+
16
+ getVariantInfo: (variant: string): string => engine.get_variant_info(variant),
17
+
18
+ keyGen: (variant: string): import('../pkg/browser/pqc_lnqc714').KeyPair =>
19
+ engine.key_gen(variant),
15
20
 
16
21
  encapsulate: (
22
+ variant: string,
17
23
  publicKeyA: Uint8Array,
18
24
  publicKeyT: Uint8Array,
19
25
  message: Uint8Array,
20
26
  ): import('../pkg/browser/pqc_lnqc714').Ciphertext =>
21
- engine.encapsulate(publicKeyA, publicKeyT, message),
27
+ engine.encapsulate(variant, publicKeyA, publicKeyT, message),
22
28
 
23
29
  decapsulate: (
30
+ variant: string,
24
31
  privateKey: Uint8Array,
25
32
  u: Uint8Array,
26
33
  v: Uint8Array,
27
- ): Uint8Array => engine.decapsulate(privateKey, u, v),
34
+ ): Uint8Array => engine.decapsulate(variant, privateKey, u, v),
28
35
 
29
36
  constantTimeVerify: (a: Uint8Array, b: Uint8Array): boolean =>
30
37
  engine.constant_time_verify(a, b),
31
38
 
32
39
  randomBits: (len: number): Uint8Array => engine.random_bits(len),
33
-
34
- getNCols: (): number => engine.get_n_cols(),
35
- getMRows: (): number => engine.get_m_rows(),
36
- getNoiseWeight: (): number => engine.get_noise_weight(),
37
- getLdpcDataBits: (): number => engine.get_ldpc_data_bits(),
38
- getLdpcCodewordBits: (): number => engine.get_ldpc_codeword_bits(),
39
40
  };
40
41
 
41
42
  export default LNQC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanitlabs/pqc-lnqc714",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/lanitlabs/pqc-lnqc714"
@@ -0,0 +1,105 @@
1
+ # @lanitlabs/pqc-lnqc714
2
+
3
+ **Post-Quantum Key Encapsulation Mechanism (KEM)** — LPN-based key agreement with LDPC error correction.
4
+ Constant-time Rust/WASM engine targeting browsers, Node.js, and Edge runtimes.
5
+
6
+ ```
7
+ npm install @lanitlabs/pqc-lnqc714
8
+ ```
9
+
10
+ ## Overview
11
+
12
+ LNQC-714 is a KEM whose security reduces to the hardness of the fixed-weight **Learning Parity with Noise (LPN)** problem over GF(2). A **Low-Density Parity-Check (LDPC)** code with a Gallager bit-flipping decoder absorbs the sparse LPN noise, achieving 0% decryption failure at the security parameters:
13
+
14
+ | Parameter | Value |
15
+ |---|---|
16
+ | LPN dimension | `n = 512` |
17
+ | LPN samples | `m = 512` |
18
+ | Noise weight | `w = 4` |
19
+ | LDPC codeword | 2048 bits |
20
+ | LDPC data | 256 bits |
21
+ | Decoder | Gallager bit-flipping (50 iters) |
22
+ | Public key | 262 656 bytes |
23
+ | Ciphertext | 1 050 624 bytes |
24
+
25
+ All operations execute in **constant-time binary matrix algebra modulo 2** — no data-dependent branching, no rejection sampling, no modular arithmetic. This provides architectural immunity to cache-timing and power-analysis side-channel attacks.
26
+
27
+ ## API
28
+
29
+ ```ts
30
+ import LNQC from '@lanitlabs/pqc-lnqc714';
31
+
32
+ // ── Key Generation ──────────────────────────────────────────
33
+ const keys = LNQC.keyGen();
34
+ // keys.publicKeyA: Uint8Array (512 × 512 bits, row-major)
35
+ // keys.publicKeyT: Uint8Array (512 bits)
36
+ // keys.privateKey: Uint8Array (512 bits)
37
+
38
+ // ── Encapsulation ───────────────────────────────────────────
39
+ const msg = LNQC.randomBits(256); // 256-bit shared secret
40
+ const ct = LNQC.encapsulate(
41
+ keys.publicKeyA,
42
+ keys.publicKeyT,
43
+ msg,
44
+ );
45
+ // ct.u: Uint8Array (2048 × 512 bits)
46
+ // ct.v: Uint8Array (2048 bits)
47
+ // ct.byteLength: number
48
+
49
+ // ── Decapsulation ───────────────────────────────────────────
50
+ const recovered = LNQC.decapsulate(
51
+ keys.privateKey,
52
+ ct.u,
53
+ ct.v,
54
+ );
55
+ // recovered equals `msg` (LDPC decoder corrects LPN noise)
56
+
57
+ // ── Constant-Time Verification ──────────────────────────────
58
+ const match = LNQC.constantTimeVerify(secretA, secretB);
59
+ // Returns true/false in constant time (subtle::ConstantTimeEq)
60
+ ```
61
+
62
+ ### Parameter getters
63
+
64
+ ```ts
65
+ LNQC.getNCols() // 512
66
+ LNQC.getMRows() // 512
67
+ LNQC.getNoiseWeight() // 4
68
+ LNQC.getLdpcDataBits() // 256
69
+ LNQC.getLdpcCodewordBits() // 2048
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ ```
75
+ ┌──────────────────────────────────────────────────────────┐
76
+ │ JS/TS (consumer) │
77
+ │ import LNQC from '@lanitlabs/pqc-lnqc714' │
78
+ └─────────────────────┬────────────────────────────────────┘
79
+
80
+ ┌─────────────────────▼────────────────────────────────────┐
81
+ │ dist/index.js (dynamic loader) │
82
+ │ Node.js → pkg/node/pqc_lnqc714.js │
83
+ │ Browser → pkg/browser/pqc_lnqc714.js │
84
+ └─────────────────────┬────────────────────────────────────┘
85
+ │ wasm-bindgen
86
+ ┌─────────────────────▼────────────────────────────────────┐
87
+ │ Rust/WASM (src/crypto.rs) │
88
+ │ • Secure RNG via getrandom (os.urandom) │
89
+ │ • Regular LDPC construction (col_weight=15) │
90
+ │ • Gallager bit-flipping decoder │
91
+ │ • Sparse R_indices optimization │
92
+ │ • subtle::ConstantTimeEq for verification │
93
+ └──────────────────────────────────────────────────────────┘
94
+ ```
95
+
96
+ ## Security
97
+
98
+ - **LPN hardness**: No known sub-exponential quantum algorithm.
99
+ - **CSPRNG**: All keys, noise vectors, and ephemeral randomness use `getrandom` (OS entropy / `crypto.getRandomValues`). **No** insecure PRNG (PCG, xorshift) is used for security-critical data.
100
+ - **Constant-time**: The `subtle` crate guards token comparison against timing side-channels.
101
+ - **LDPC protection**: Regular column-weight-15 parity-check matrix eliminates single-check failure modes.
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,105 @@
1
+ # @lanitlabs/pqc-lnqc714
2
+
3
+ **Post-Quantum Key Encapsulation Mechanism (KEM)** — LPN-based key agreement with LDPC error correction.
4
+ Constant-time Rust/WASM engine targeting browsers, Node.js, and Edge runtimes.
5
+
6
+ ```
7
+ npm install @lanitlabs/pqc-lnqc714
8
+ ```
9
+
10
+ ## Overview
11
+
12
+ LNQC-714 is a KEM whose security reduces to the hardness of the fixed-weight **Learning Parity with Noise (LPN)** problem over GF(2). A **Low-Density Parity-Check (LDPC)** code with a Gallager bit-flipping decoder absorbs the sparse LPN noise, achieving 0% decryption failure at the security parameters:
13
+
14
+ | Parameter | Value |
15
+ |---|---|
16
+ | LPN dimension | `n = 512` |
17
+ | LPN samples | `m = 512` |
18
+ | Noise weight | `w = 4` |
19
+ | LDPC codeword | 2048 bits |
20
+ | LDPC data | 256 bits |
21
+ | Decoder | Gallager bit-flipping (50 iters) |
22
+ | Public key | 262 656 bytes |
23
+ | Ciphertext | 1 050 624 bytes |
24
+
25
+ All operations execute in **constant-time binary matrix algebra modulo 2** — no data-dependent branching, no rejection sampling, no modular arithmetic. This provides architectural immunity to cache-timing and power-analysis side-channel attacks.
26
+
27
+ ## API
28
+
29
+ ```ts
30
+ import LNQC from '@lanitlabs/pqc-lnqc714';
31
+
32
+ // ── Key Generation ──────────────────────────────────────────
33
+ const keys = LNQC.keyGen();
34
+ // keys.publicKeyA: Uint8Array (512 × 512 bits, row-major)
35
+ // keys.publicKeyT: Uint8Array (512 bits)
36
+ // keys.privateKey: Uint8Array (512 bits)
37
+
38
+ // ── Encapsulation ───────────────────────────────────────────
39
+ const msg = LNQC.randomBits(256); // 256-bit shared secret
40
+ const ct = LNQC.encapsulate(
41
+ keys.publicKeyA,
42
+ keys.publicKeyT,
43
+ msg,
44
+ );
45
+ // ct.u: Uint8Array (2048 × 512 bits)
46
+ // ct.v: Uint8Array (2048 bits)
47
+ // ct.byteLength: number
48
+
49
+ // ── Decapsulation ───────────────────────────────────────────
50
+ const recovered = LNQC.decapsulate(
51
+ keys.privateKey,
52
+ ct.u,
53
+ ct.v,
54
+ );
55
+ // recovered equals `msg` (LDPC decoder corrects LPN noise)
56
+
57
+ // ── Constant-Time Verification ──────────────────────────────
58
+ const match = LNQC.constantTimeVerify(secretA, secretB);
59
+ // Returns true/false in constant time (subtle::ConstantTimeEq)
60
+ ```
61
+
62
+ ### Parameter getters
63
+
64
+ ```ts
65
+ LNQC.getNCols() // 512
66
+ LNQC.getMRows() // 512
67
+ LNQC.getNoiseWeight() // 4
68
+ LNQC.getLdpcDataBits() // 256
69
+ LNQC.getLdpcCodewordBits() // 2048
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ ```
75
+ ┌──────────────────────────────────────────────────────────┐
76
+ │ JS/TS (consumer) │
77
+ │ import LNQC from '@lanitlabs/pqc-lnqc714' │
78
+ └─────────────────────┬────────────────────────────────────┘
79
+
80
+ ┌─────────────────────▼────────────────────────────────────┐
81
+ │ dist/index.js (dynamic loader) │
82
+ │ Node.js → pkg/node/pqc_lnqc714.js │
83
+ │ Browser → pkg/browser/pqc_lnqc714.js │
84
+ └─────────────────────┬────────────────────────────────────┘
85
+ │ wasm-bindgen
86
+ ┌─────────────────────▼────────────────────────────────────┐
87
+ │ Rust/WASM (src/crypto.rs) │
88
+ │ • Secure RNG via getrandom (os.urandom) │
89
+ │ • Regular LDPC construction (col_weight=15) │
90
+ │ • Gallager bit-flipping decoder │
91
+ │ • Sparse R_indices optimization │
92
+ │ • subtle::ConstantTimeEq for verification │
93
+ └──────────────────────────────────────────────────────────┘
94
+ ```
95
+
96
+ ## Security
97
+
98
+ - **LPN hardness**: No known sub-exponential quantum algorithm.
99
+ - **CSPRNG**: All keys, noise vectors, and ephemeral randomness use `getrandom` (OS entropy / `crypto.getRandomValues`). **No** insecure PRNG (PCG, xorshift) is used for security-critical data.
100
+ - **Constant-time**: The `subtle` crate guards token comparison against timing side-channels.
101
+ - **LDPC protection**: Regular column-weight-15 parity-check matrix eliminates single-check failure modes.
102
+
103
+ ## License
104
+
105
+ MIT
@@ -1,68 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- export class Ciphertext {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- /**
9
- * Total ciphertext size in bytes (U + V).
10
- */
11
- readonly byte_length: number;
12
- readonly u: Uint8Array;
13
- readonly v: Uint8Array;
14
- }
15
-
16
- export class KeyPair {
17
- private constructor();
18
- free(): void;
19
- [Symbol.dispose](): void;
20
- readonly private_key: Uint8Array;
21
- readonly public_key_a: Uint8Array;
22
- readonly public_key_t: Uint8Array;
23
- }
24
-
25
- /**
26
- * Constant-time comparison of two byte slices.
27
- * Returns `true` if they are identical, `false` otherwise.
28
- * Execution time does NOT depend on the position of the first mismatch.
29
- */
30
- export function constant_time_verify(a: Uint8Array, b: Uint8Array): boolean;
31
-
32
- /**
33
- * Decapsulate a Ciphertext (U, V) using the private key `s`.
34
- * Returns the recovered LDPC_DATA_BITS message.
35
- */
36
- export function decapsulate(private_key_s: Uint8Array, u: Uint8Array, v: Uint8Array): Uint8Array;
37
-
38
- /**
39
- * Encapsulate a `message` (LDPC_DATA_BITS bits) under a public key.
40
- * `public_key_a` and `public_key_t` must be the outputs from `key_gen()`.
41
- * Returns a Ciphertext containing (U, V).
42
- */
43
- export function encapsulate(public_key_a: Uint8Array, public_key_t: Uint8Array, message: Uint8Array): Ciphertext;
44
-
45
- export function get_ldpc_codeword_bits(): number;
46
-
47
- export function get_ldpc_data_bits(): number;
48
-
49
- export function get_m_rows(): number;
50
-
51
- export function get_n_cols(): number;
52
-
53
- export function get_noise_weight(): number;
54
-
55
- /**
56
- * Generate a fresh LNQC-714 key pair.
57
- * Returns a KeyPair with:
58
- * - public_key_a: M_ROWS × N_COLS binary matrix (flat, row-major)
59
- * - public_key_t: M_ROWS-bit noisy public key
60
- * - private_key: N_COLS-bit secret vector
61
- */
62
- export function key_gen(): KeyPair;
63
-
64
- /**
65
- * Generate `len` cryptographically secure random bits.
66
- * Returns a flat Vec<u8> where each element is 0 or 1.
67
- */
68
- export function random_bits(len: number): Uint8Array;
@@ -1,9 +0,0 @@
1
- /* @ts-self-types="./pqc_lnqc714.d.ts" */
2
- import * as wasm from "./pqc_lnqc714_bg.wasm";
3
- import { __wbg_set_wasm } from "./pqc_lnqc714_bg.js";
4
-
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- Ciphertext, KeyPair, constant_time_verify, decapsulate, encapsulate, get_ldpc_codeword_bits, get_ldpc_data_bits, get_m_rows, get_n_cols, get_noise_weight, key_gen, random_bits
9
- } from "./pqc_lnqc714_bg.js";
@@ -1,391 +0,0 @@
1
- export class Ciphertext {
2
- static __wrap(ptr) {
3
- const obj = Object.create(Ciphertext.prototype);
4
- obj.__wbg_ptr = ptr;
5
- CiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
6
- return obj;
7
- }
8
- __destroy_into_raw() {
9
- const ptr = this.__wbg_ptr;
10
- this.__wbg_ptr = 0;
11
- CiphertextFinalization.unregister(this);
12
- return ptr;
13
- }
14
- free() {
15
- const ptr = this.__destroy_into_raw();
16
- wasm.__wbg_ciphertext_free(ptr, 0);
17
- }
18
- /**
19
- * Total ciphertext size in bytes (U + V).
20
- * @returns {number}
21
- */
22
- get byte_length() {
23
- const ret = wasm.ciphertext_byte_length(this.__wbg_ptr);
24
- return ret >>> 0;
25
- }
26
- /**
27
- * @returns {Uint8Array}
28
- */
29
- get u() {
30
- const ret = wasm.ciphertext_u(this.__wbg_ptr);
31
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
32
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
33
- return v1;
34
- }
35
- /**
36
- * @returns {Uint8Array}
37
- */
38
- get v() {
39
- const ret = wasm.ciphertext_v(this.__wbg_ptr);
40
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
41
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
42
- return v1;
43
- }
44
- }
45
- if (Symbol.dispose) Ciphertext.prototype[Symbol.dispose] = Ciphertext.prototype.free;
46
-
47
- export class KeyPair {
48
- static __wrap(ptr) {
49
- const obj = Object.create(KeyPair.prototype);
50
- obj.__wbg_ptr = ptr;
51
- KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
52
- return obj;
53
- }
54
- __destroy_into_raw() {
55
- const ptr = this.__wbg_ptr;
56
- this.__wbg_ptr = 0;
57
- KeyPairFinalization.unregister(this);
58
- return ptr;
59
- }
60
- free() {
61
- const ptr = this.__destroy_into_raw();
62
- wasm.__wbg_keypair_free(ptr, 0);
63
- }
64
- /**
65
- * @returns {Uint8Array}
66
- */
67
- get private_key() {
68
- const ret = wasm.keypair_private_key(this.__wbg_ptr);
69
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
70
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
71
- return v1;
72
- }
73
- /**
74
- * @returns {Uint8Array}
75
- */
76
- get public_key_a() {
77
- const ret = wasm.keypair_public_key_a(this.__wbg_ptr);
78
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
79
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
80
- return v1;
81
- }
82
- /**
83
- * @returns {Uint8Array}
84
- */
85
- get public_key_t() {
86
- const ret = wasm.keypair_public_key_t(this.__wbg_ptr);
87
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
88
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
89
- return v1;
90
- }
91
- }
92
- if (Symbol.dispose) KeyPair.prototype[Symbol.dispose] = KeyPair.prototype.free;
93
-
94
- /**
95
- * Constant-time comparison of two byte slices.
96
- * Returns `true` if they are identical, `false` otherwise.
97
- * Execution time does NOT depend on the position of the first mismatch.
98
- * @param {Uint8Array} a
99
- * @param {Uint8Array} b
100
- * @returns {boolean}
101
- */
102
- export function constant_time_verify(a, b) {
103
- const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
104
- const len0 = WASM_VECTOR_LEN;
105
- const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
106
- const len1 = WASM_VECTOR_LEN;
107
- const ret = wasm.constant_time_verify(ptr0, len0, ptr1, len1);
108
- return ret !== 0;
109
- }
110
-
111
- /**
112
- * Decapsulate a Ciphertext (U, V) using the private key `s`.
113
- * Returns the recovered LDPC_DATA_BITS message.
114
- * @param {Uint8Array} private_key_s
115
- * @param {Uint8Array} u
116
- * @param {Uint8Array} v
117
- * @returns {Uint8Array}
118
- */
119
- export function decapsulate(private_key_s, u, v) {
120
- const ptr0 = passArray8ToWasm0(private_key_s, wasm.__wbindgen_malloc);
121
- const len0 = WASM_VECTOR_LEN;
122
- const ptr1 = passArray8ToWasm0(u, wasm.__wbindgen_malloc);
123
- const len1 = WASM_VECTOR_LEN;
124
- const ptr2 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
125
- const len2 = WASM_VECTOR_LEN;
126
- const ret = wasm.decapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
127
- var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
128
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
129
- return v4;
130
- }
131
-
132
- /**
133
- * Encapsulate a `message` (LDPC_DATA_BITS bits) under a public key.
134
- * `public_key_a` and `public_key_t` must be the outputs from `key_gen()`.
135
- * Returns a Ciphertext containing (U, V).
136
- * @param {Uint8Array} public_key_a
137
- * @param {Uint8Array} public_key_t
138
- * @param {Uint8Array} message
139
- * @returns {Ciphertext}
140
- */
141
- export function encapsulate(public_key_a, public_key_t, message) {
142
- const ptr0 = passArray8ToWasm0(public_key_a, wasm.__wbindgen_malloc);
143
- const len0 = WASM_VECTOR_LEN;
144
- const ptr1 = passArray8ToWasm0(public_key_t, wasm.__wbindgen_malloc);
145
- const len1 = WASM_VECTOR_LEN;
146
- const ptr2 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
147
- const len2 = WASM_VECTOR_LEN;
148
- const ret = wasm.encapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
149
- return Ciphertext.__wrap(ret);
150
- }
151
-
152
- /**
153
- * @returns {number}
154
- */
155
- export function get_ldpc_codeword_bits() {
156
- const ret = wasm.get_ldpc_codeword_bits();
157
- return ret >>> 0;
158
- }
159
-
160
- /**
161
- * @returns {number}
162
- */
163
- export function get_ldpc_data_bits() {
164
- const ret = wasm.get_ldpc_data_bits();
165
- return ret >>> 0;
166
- }
167
-
168
- /**
169
- * @returns {number}
170
- */
171
- export function get_m_rows() {
172
- const ret = wasm.get_m_rows();
173
- return ret >>> 0;
174
- }
175
-
176
- /**
177
- * @returns {number}
178
- */
179
- export function get_n_cols() {
180
- const ret = wasm.get_n_cols();
181
- return ret >>> 0;
182
- }
183
-
184
- /**
185
- * @returns {number}
186
- */
187
- export function get_noise_weight() {
188
- const ret = wasm.get_noise_weight();
189
- return ret >>> 0;
190
- }
191
-
192
- /**
193
- * Generate a fresh LNQC-714 key pair.
194
- * Returns a KeyPair with:
195
- * - public_key_a: M_ROWS × N_COLS binary matrix (flat, row-major)
196
- * - public_key_t: M_ROWS-bit noisy public key
197
- * - private_key: N_COLS-bit secret vector
198
- * @returns {KeyPair}
199
- */
200
- export function key_gen() {
201
- const ret = wasm.key_gen();
202
- return KeyPair.__wrap(ret);
203
- }
204
-
205
- /**
206
- * Generate `len` cryptographically secure random bits.
207
- * Returns a flat Vec<u8> where each element is 0 or 1.
208
- * @param {number} len
209
- * @returns {Uint8Array}
210
- */
211
- export function random_bits(len) {
212
- const ret = wasm.random_bits(len);
213
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
214
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
215
- return v1;
216
- }
217
- export function __wbg___wbindgen_is_function_754e9f305ff6029e(arg0) {
218
- const ret = typeof(arg0) === 'function';
219
- return ret;
220
- }
221
- export function __wbg___wbindgen_is_object_56732c2bc353f41d(arg0) {
222
- const val = arg0;
223
- const ret = typeof(val) === 'object' && val !== null;
224
- return ret;
225
- }
226
- export function __wbg___wbindgen_is_string_c236cabd84a4d769(arg0) {
227
- const ret = typeof(arg0) === 'string';
228
- return ret;
229
- }
230
- export function __wbg___wbindgen_is_undefined_67b456be8673d3d7(arg0) {
231
- const ret = arg0 === undefined;
232
- return ret;
233
- }
234
- export function __wbg___wbindgen_throw_1506f2235d1bdba0(arg0, arg1) {
235
- throw new Error(getStringFromWasm0(arg0, arg1));
236
- }
237
- export function __wbg_call_9c758de292015997() { return handleError(function (arg0, arg1, arg2) {
238
- const ret = arg0.call(arg1, arg2);
239
- return ret;
240
- }, arguments); }
241
- export function __wbg_crypto_38df2bab126b63dc(arg0) {
242
- const ret = arg0.crypto;
243
- return ret;
244
- }
245
- export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
246
- arg0.getRandomValues(arg1);
247
- }, arguments); }
248
- export function __wbg_length_4a591ecaa01354d9(arg0) {
249
- const ret = arg0.length;
250
- return ret;
251
- }
252
- export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
253
- const ret = arg0.msCrypto;
254
- return ret;
255
- }
256
- export function __wbg_new_with_length_36a4998e27b014c5(arg0) {
257
- const ret = new Uint8Array(arg0 >>> 0);
258
- return ret;
259
- }
260
- export function __wbg_node_84ea875411254db1(arg0) {
261
- const ret = arg0.node;
262
- return ret;
263
- }
264
- export function __wbg_process_44c7a14e11e9f69e(arg0) {
265
- const ret = arg0.process;
266
- return ret;
267
- }
268
- export function __wbg_prototypesetcall_3249fc62a0fafa30(arg0, arg1, arg2) {
269
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
270
- }
271
- export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) {
272
- arg0.randomFillSync(arg1);
273
- }, arguments); }
274
- export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () {
275
- const ret = module.require;
276
- return ret;
277
- }, arguments); }
278
- export function __wbg_static_accessor_GLOBAL_9d53f2689e622ca1() {
279
- const ret = typeof global === 'undefined' ? null : global;
280
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
281
- }
282
- export function __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a() {
283
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
284
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
285
- }
286
- export function __wbg_static_accessor_SELF_4c59f6c7ea29a144() {
287
- const ret = typeof self === 'undefined' ? null : self;
288
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
289
- }
290
- export function __wbg_static_accessor_WINDOW_e70ae9f2eb052253() {
291
- const ret = typeof window === 'undefined' ? null : window;
292
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
293
- }
294
- export function __wbg_subarray_4aa221f6a4f5ab22(arg0, arg1, arg2) {
295
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
296
- return ret;
297
- }
298
- export function __wbg_versions_276b2795b1c6a219(arg0) {
299
- const ret = arg0.versions;
300
- return ret;
301
- }
302
- export function __wbindgen_cast_0000000000000001(arg0, arg1) {
303
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
304
- const ret = getArrayU8FromWasm0(arg0, arg1);
305
- return ret;
306
- }
307
- export function __wbindgen_cast_0000000000000002(arg0, arg1) {
308
- // Cast intrinsic for `Ref(String) -> Externref`.
309
- const ret = getStringFromWasm0(arg0, arg1);
310
- return ret;
311
- }
312
- export function __wbindgen_init_externref_table() {
313
- const table = wasm.__wbindgen_externrefs;
314
- const offset = table.grow(4);
315
- table.set(0, undefined);
316
- table.set(offset + 0, undefined);
317
- table.set(offset + 1, null);
318
- table.set(offset + 2, true);
319
- table.set(offset + 3, false);
320
- }
321
- const CiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
322
- ? { register: () => {}, unregister: () => {} }
323
- : new FinalizationRegistry(ptr => wasm.__wbg_ciphertext_free(ptr, 1));
324
- const KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
325
- ? { register: () => {}, unregister: () => {} }
326
- : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr, 1));
327
-
328
- function addToExternrefTable0(obj) {
329
- const idx = wasm.__externref_table_alloc();
330
- wasm.__wbindgen_externrefs.set(idx, obj);
331
- return idx;
332
- }
333
-
334
- function getArrayU8FromWasm0(ptr, len) {
335
- ptr = ptr >>> 0;
336
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
337
- }
338
-
339
- function getStringFromWasm0(ptr, len) {
340
- return decodeText(ptr >>> 0, len);
341
- }
342
-
343
- let cachedUint8ArrayMemory0 = null;
344
- function getUint8ArrayMemory0() {
345
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
346
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
347
- }
348
- return cachedUint8ArrayMemory0;
349
- }
350
-
351
- function handleError(f, args) {
352
- try {
353
- return f.apply(this, args);
354
- } catch (e) {
355
- const idx = addToExternrefTable0(e);
356
- wasm.__wbindgen_exn_store(idx);
357
- }
358
- }
359
-
360
- function isLikeNone(x) {
361
- return x === undefined || x === null;
362
- }
363
-
364
- function passArray8ToWasm0(arg, malloc) {
365
- const ptr = malloc(arg.length * 1, 1) >>> 0;
366
- getUint8ArrayMemory0().set(arg, ptr / 1);
367
- WASM_VECTOR_LEN = arg.length;
368
- return ptr;
369
- }
370
-
371
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
372
- cachedTextDecoder.decode();
373
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
374
- let numBytesDecoded = 0;
375
- function decodeText(ptr, len) {
376
- numBytesDecoded += len;
377
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
378
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
379
- cachedTextDecoder.decode();
380
- numBytesDecoded = len;
381
- }
382
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
383
- }
384
-
385
- let WASM_VECTOR_LEN = 0;
386
-
387
-
388
- let wasm;
389
- export function __wbg_set_wasm(val) {
390
- wasm = val;
391
- }
Binary file
@@ -1,27 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export const __wbg_ciphertext_free: (a: number, b: number) => void;
5
- export const __wbg_keypair_free: (a: number, b: number) => void;
6
- export const ciphertext_byte_length: (a: number) => number;
7
- export const ciphertext_u: (a: number) => [number, number];
8
- export const ciphertext_v: (a: number) => [number, number];
9
- export const constant_time_verify: (a: number, b: number, c: number, d: number) => number;
10
- export const decapsulate: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
11
- export const encapsulate: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
12
- export const get_ldpc_codeword_bits: () => number;
13
- export const get_ldpc_data_bits: () => number;
14
- export const get_m_rows: () => number;
15
- export const get_noise_weight: () => number;
16
- export const key_gen: () => number;
17
- export const keypair_private_key: (a: number) => [number, number];
18
- export const keypair_public_key_a: (a: number) => [number, number];
19
- export const keypair_public_key_t: (a: number) => [number, number];
20
- export const random_bits: (a: number) => [number, number];
21
- export const get_n_cols: () => number;
22
- export const __wbindgen_exn_store: (a: number) => void;
23
- export const __externref_table_alloc: () => number;
24
- export const __wbindgen_externrefs: WebAssembly.Table;
25
- export const __wbindgen_free: (a: number, b: number, c: number) => void;
26
- export const __wbindgen_malloc: (a: number, b: number) => number;
27
- export const __wbindgen_start: () => void;
@@ -1,68 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- export class Ciphertext {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- /**
9
- * Total ciphertext size in bytes (U + V).
10
- */
11
- readonly byte_length: number;
12
- readonly u: Uint8Array;
13
- readonly v: Uint8Array;
14
- }
15
-
16
- export class KeyPair {
17
- private constructor();
18
- free(): void;
19
- [Symbol.dispose](): void;
20
- readonly private_key: Uint8Array;
21
- readonly public_key_a: Uint8Array;
22
- readonly public_key_t: Uint8Array;
23
- }
24
-
25
- /**
26
- * Constant-time comparison of two byte slices.
27
- * Returns `true` if they are identical, `false` otherwise.
28
- * Execution time does NOT depend on the position of the first mismatch.
29
- */
30
- export function constant_time_verify(a: Uint8Array, b: Uint8Array): boolean;
31
-
32
- /**
33
- * Decapsulate a Ciphertext (U, V) using the private key `s`.
34
- * Returns the recovered LDPC_DATA_BITS message.
35
- */
36
- export function decapsulate(private_key_s: Uint8Array, u: Uint8Array, v: Uint8Array): Uint8Array;
37
-
38
- /**
39
- * Encapsulate a `message` (LDPC_DATA_BITS bits) under a public key.
40
- * `public_key_a` and `public_key_t` must be the outputs from `key_gen()`.
41
- * Returns a Ciphertext containing (U, V).
42
- */
43
- export function encapsulate(public_key_a: Uint8Array, public_key_t: Uint8Array, message: Uint8Array): Ciphertext;
44
-
45
- export function get_ldpc_codeword_bits(): number;
46
-
47
- export function get_ldpc_data_bits(): number;
48
-
49
- export function get_m_rows(): number;
50
-
51
- export function get_n_cols(): number;
52
-
53
- export function get_noise_weight(): number;
54
-
55
- /**
56
- * Generate a fresh LNQC-714 key pair.
57
- * Returns a KeyPair with:
58
- * - public_key_a: M_ROWS × N_COLS binary matrix (flat, row-major)
59
- * - public_key_t: M_ROWS-bit noisy public key
60
- * - private_key: N_COLS-bit secret vector
61
- */
62
- export function key_gen(): KeyPair;
63
-
64
- /**
65
- * Generate `len` cryptographically secure random bits.
66
- * Returns a flat Vec<u8> where each element is 0 or 1.
67
- */
68
- export function random_bits(len: number): Uint8Array;
@@ -1,408 +0,0 @@
1
- /* @ts-self-types="./pqc_lnqc714.d.ts" */
2
-
3
- class Ciphertext {
4
- static __wrap(ptr) {
5
- const obj = Object.create(Ciphertext.prototype);
6
- obj.__wbg_ptr = ptr;
7
- CiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
8
- return obj;
9
- }
10
- __destroy_into_raw() {
11
- const ptr = this.__wbg_ptr;
12
- this.__wbg_ptr = 0;
13
- CiphertextFinalization.unregister(this);
14
- return ptr;
15
- }
16
- free() {
17
- const ptr = this.__destroy_into_raw();
18
- wasm.__wbg_ciphertext_free(ptr, 0);
19
- }
20
- /**
21
- * Total ciphertext size in bytes (U + V).
22
- * @returns {number}
23
- */
24
- get byte_length() {
25
- const ret = wasm.ciphertext_byte_length(this.__wbg_ptr);
26
- return ret >>> 0;
27
- }
28
- /**
29
- * @returns {Uint8Array}
30
- */
31
- get u() {
32
- const ret = wasm.ciphertext_u(this.__wbg_ptr);
33
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
34
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
35
- return v1;
36
- }
37
- /**
38
- * @returns {Uint8Array}
39
- */
40
- get v() {
41
- const ret = wasm.ciphertext_v(this.__wbg_ptr);
42
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
43
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
44
- return v1;
45
- }
46
- }
47
- if (Symbol.dispose) Ciphertext.prototype[Symbol.dispose] = Ciphertext.prototype.free;
48
- exports.Ciphertext = Ciphertext;
49
-
50
- class KeyPair {
51
- static __wrap(ptr) {
52
- const obj = Object.create(KeyPair.prototype);
53
- obj.__wbg_ptr = ptr;
54
- KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
55
- return obj;
56
- }
57
- __destroy_into_raw() {
58
- const ptr = this.__wbg_ptr;
59
- this.__wbg_ptr = 0;
60
- KeyPairFinalization.unregister(this);
61
- return ptr;
62
- }
63
- free() {
64
- const ptr = this.__destroy_into_raw();
65
- wasm.__wbg_keypair_free(ptr, 0);
66
- }
67
- /**
68
- * @returns {Uint8Array}
69
- */
70
- get private_key() {
71
- const ret = wasm.keypair_private_key(this.__wbg_ptr);
72
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
73
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
74
- return v1;
75
- }
76
- /**
77
- * @returns {Uint8Array}
78
- */
79
- get public_key_a() {
80
- const ret = wasm.keypair_public_key_a(this.__wbg_ptr);
81
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
82
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
83
- return v1;
84
- }
85
- /**
86
- * @returns {Uint8Array}
87
- */
88
- get public_key_t() {
89
- const ret = wasm.keypair_public_key_t(this.__wbg_ptr);
90
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
91
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
92
- return v1;
93
- }
94
- }
95
- if (Symbol.dispose) KeyPair.prototype[Symbol.dispose] = KeyPair.prototype.free;
96
- exports.KeyPair = KeyPair;
97
-
98
- /**
99
- * Constant-time comparison of two byte slices.
100
- * Returns `true` if they are identical, `false` otherwise.
101
- * Execution time does NOT depend on the position of the first mismatch.
102
- * @param {Uint8Array} a
103
- * @param {Uint8Array} b
104
- * @returns {boolean}
105
- */
106
- function constant_time_verify(a, b) {
107
- const ptr0 = passArray8ToWasm0(a, wasm.__wbindgen_malloc);
108
- const len0 = WASM_VECTOR_LEN;
109
- const ptr1 = passArray8ToWasm0(b, wasm.__wbindgen_malloc);
110
- const len1 = WASM_VECTOR_LEN;
111
- const ret = wasm.constant_time_verify(ptr0, len0, ptr1, len1);
112
- return ret !== 0;
113
- }
114
- exports.constant_time_verify = constant_time_verify;
115
-
116
- /**
117
- * Decapsulate a Ciphertext (U, V) using the private key `s`.
118
- * Returns the recovered LDPC_DATA_BITS message.
119
- * @param {Uint8Array} private_key_s
120
- * @param {Uint8Array} u
121
- * @param {Uint8Array} v
122
- * @returns {Uint8Array}
123
- */
124
- function decapsulate(private_key_s, u, v) {
125
- const ptr0 = passArray8ToWasm0(private_key_s, wasm.__wbindgen_malloc);
126
- const len0 = WASM_VECTOR_LEN;
127
- const ptr1 = passArray8ToWasm0(u, wasm.__wbindgen_malloc);
128
- const len1 = WASM_VECTOR_LEN;
129
- const ptr2 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
130
- const len2 = WASM_VECTOR_LEN;
131
- const ret = wasm.decapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
132
- var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
133
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
134
- return v4;
135
- }
136
- exports.decapsulate = decapsulate;
137
-
138
- /**
139
- * Encapsulate a `message` (LDPC_DATA_BITS bits) under a public key.
140
- * `public_key_a` and `public_key_t` must be the outputs from `key_gen()`.
141
- * Returns a Ciphertext containing (U, V).
142
- * @param {Uint8Array} public_key_a
143
- * @param {Uint8Array} public_key_t
144
- * @param {Uint8Array} message
145
- * @returns {Ciphertext}
146
- */
147
- function encapsulate(public_key_a, public_key_t, message) {
148
- const ptr0 = passArray8ToWasm0(public_key_a, wasm.__wbindgen_malloc);
149
- const len0 = WASM_VECTOR_LEN;
150
- const ptr1 = passArray8ToWasm0(public_key_t, wasm.__wbindgen_malloc);
151
- const len1 = WASM_VECTOR_LEN;
152
- const ptr2 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
153
- const len2 = WASM_VECTOR_LEN;
154
- const ret = wasm.encapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
155
- return Ciphertext.__wrap(ret);
156
- }
157
- exports.encapsulate = encapsulate;
158
-
159
- /**
160
- * @returns {number}
161
- */
162
- function get_ldpc_codeword_bits() {
163
- const ret = wasm.get_ldpc_codeword_bits();
164
- return ret >>> 0;
165
- }
166
- exports.get_ldpc_codeword_bits = get_ldpc_codeword_bits;
167
-
168
- /**
169
- * @returns {number}
170
- */
171
- function get_ldpc_data_bits() {
172
- const ret = wasm.get_ldpc_data_bits();
173
- return ret >>> 0;
174
- }
175
- exports.get_ldpc_data_bits = get_ldpc_data_bits;
176
-
177
- /**
178
- * @returns {number}
179
- */
180
- function get_m_rows() {
181
- const ret = wasm.get_m_rows();
182
- return ret >>> 0;
183
- }
184
- exports.get_m_rows = get_m_rows;
185
-
186
- /**
187
- * @returns {number}
188
- */
189
- function get_n_cols() {
190
- const ret = wasm.get_n_cols();
191
- return ret >>> 0;
192
- }
193
- exports.get_n_cols = get_n_cols;
194
-
195
- /**
196
- * @returns {number}
197
- */
198
- function get_noise_weight() {
199
- const ret = wasm.get_noise_weight();
200
- return ret >>> 0;
201
- }
202
- exports.get_noise_weight = get_noise_weight;
203
-
204
- /**
205
- * Generate a fresh LNQC-714 key pair.
206
- * Returns a KeyPair with:
207
- * - public_key_a: M_ROWS × N_COLS binary matrix (flat, row-major)
208
- * - public_key_t: M_ROWS-bit noisy public key
209
- * - private_key: N_COLS-bit secret vector
210
- * @returns {KeyPair}
211
- */
212
- function key_gen() {
213
- const ret = wasm.key_gen();
214
- return KeyPair.__wrap(ret);
215
- }
216
- exports.key_gen = key_gen;
217
-
218
- /**
219
- * Generate `len` cryptographically secure random bits.
220
- * Returns a flat Vec<u8> where each element is 0 or 1.
221
- * @param {number} len
222
- * @returns {Uint8Array}
223
- */
224
- function random_bits(len) {
225
- const ret = wasm.random_bits(len);
226
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
227
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
228
- return v1;
229
- }
230
- exports.random_bits = random_bits;
231
- function __wbg_get_imports() {
232
- const import0 = {
233
- __proto__: null,
234
- __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
235
- const ret = typeof(arg0) === 'function';
236
- return ret;
237
- },
238
- __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
239
- const val = arg0;
240
- const ret = typeof(val) === 'object' && val !== null;
241
- return ret;
242
- },
243
- __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
244
- const ret = typeof(arg0) === 'string';
245
- return ret;
246
- },
247
- __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
248
- const ret = arg0 === undefined;
249
- return ret;
250
- },
251
- __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
252
- throw new Error(getStringFromWasm0(arg0, arg1));
253
- },
254
- __wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
255
- const ret = arg0.call(arg1, arg2);
256
- return ret;
257
- }, arguments); },
258
- __wbg_crypto_38df2bab126b63dc: function(arg0) {
259
- const ret = arg0.crypto;
260
- return ret;
261
- },
262
- __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
263
- arg0.getRandomValues(arg1);
264
- }, arguments); },
265
- __wbg_length_4a591ecaa01354d9: function(arg0) {
266
- const ret = arg0.length;
267
- return ret;
268
- },
269
- __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
270
- const ret = arg0.msCrypto;
271
- return ret;
272
- },
273
- __wbg_new_with_length_36a4998e27b014c5: function(arg0) {
274
- const ret = new Uint8Array(arg0 >>> 0);
275
- return ret;
276
- },
277
- __wbg_node_84ea875411254db1: function(arg0) {
278
- const ret = arg0.node;
279
- return ret;
280
- },
281
- __wbg_process_44c7a14e11e9f69e: function(arg0) {
282
- const ret = arg0.process;
283
- return ret;
284
- },
285
- __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
286
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
287
- },
288
- __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
289
- arg0.randomFillSync(arg1);
290
- }, arguments); },
291
- __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
292
- const ret = module.require;
293
- return ret;
294
- }, arguments); },
295
- __wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
296
- const ret = typeof global === 'undefined' ? null : global;
297
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
298
- },
299
- __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
300
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
301
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
302
- },
303
- __wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
304
- const ret = typeof self === 'undefined' ? null : self;
305
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
306
- },
307
- __wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
308
- const ret = typeof window === 'undefined' ? null : window;
309
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
310
- },
311
- __wbg_subarray_4aa221f6a4f5ab22: function(arg0, arg1, arg2) {
312
- const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
313
- return ret;
314
- },
315
- __wbg_versions_276b2795b1c6a219: function(arg0) {
316
- const ret = arg0.versions;
317
- return ret;
318
- },
319
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
320
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
321
- const ret = getArrayU8FromWasm0(arg0, arg1);
322
- return ret;
323
- },
324
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
325
- // Cast intrinsic for `Ref(String) -> Externref`.
326
- const ret = getStringFromWasm0(arg0, arg1);
327
- return ret;
328
- },
329
- __wbindgen_init_externref_table: function() {
330
- const table = wasm.__wbindgen_externrefs;
331
- const offset = table.grow(4);
332
- table.set(0, undefined);
333
- table.set(offset + 0, undefined);
334
- table.set(offset + 1, null);
335
- table.set(offset + 2, true);
336
- table.set(offset + 3, false);
337
- },
338
- };
339
- return {
340
- __proto__: null,
341
- "./pqc_lnqc714_bg.js": import0,
342
- };
343
- }
344
-
345
- const CiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
346
- ? { register: () => {}, unregister: () => {} }
347
- : new FinalizationRegistry(ptr => wasm.__wbg_ciphertext_free(ptr, 1));
348
- const KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
349
- ? { register: () => {}, unregister: () => {} }
350
- : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr, 1));
351
-
352
- function addToExternrefTable0(obj) {
353
- const idx = wasm.__externref_table_alloc();
354
- wasm.__wbindgen_externrefs.set(idx, obj);
355
- return idx;
356
- }
357
-
358
- function getArrayU8FromWasm0(ptr, len) {
359
- ptr = ptr >>> 0;
360
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
361
- }
362
-
363
- function getStringFromWasm0(ptr, len) {
364
- return decodeText(ptr >>> 0, len);
365
- }
366
-
367
- let cachedUint8ArrayMemory0 = null;
368
- function getUint8ArrayMemory0() {
369
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
370
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
371
- }
372
- return cachedUint8ArrayMemory0;
373
- }
374
-
375
- function handleError(f, args) {
376
- try {
377
- return f.apply(this, args);
378
- } catch (e) {
379
- const idx = addToExternrefTable0(e);
380
- wasm.__wbindgen_exn_store(idx);
381
- }
382
- }
383
-
384
- function isLikeNone(x) {
385
- return x === undefined || x === null;
386
- }
387
-
388
- function passArray8ToWasm0(arg, malloc) {
389
- const ptr = malloc(arg.length * 1, 1) >>> 0;
390
- getUint8ArrayMemory0().set(arg, ptr / 1);
391
- WASM_VECTOR_LEN = arg.length;
392
- return ptr;
393
- }
394
-
395
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
396
- cachedTextDecoder.decode();
397
- function decodeText(ptr, len) {
398
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
399
- }
400
-
401
- let WASM_VECTOR_LEN = 0;
402
-
403
- const wasmPath = `${__dirname}/pqc_lnqc714_bg.wasm`;
404
- const wasmBytes = require('fs').readFileSync(wasmPath);
405
- const wasmModule = new WebAssembly.Module(wasmBytes);
406
- let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
407
- let wasm = wasmInstance.exports;
408
- wasm.__wbindgen_start();
Binary file
@@ -1,27 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export const __wbg_ciphertext_free: (a: number, b: number) => void;
5
- export const __wbg_keypair_free: (a: number, b: number) => void;
6
- export const ciphertext_byte_length: (a: number) => number;
7
- export const ciphertext_u: (a: number) => [number, number];
8
- export const ciphertext_v: (a: number) => [number, number];
9
- export const constant_time_verify: (a: number, b: number, c: number, d: number) => number;
10
- export const decapsulate: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
11
- export const encapsulate: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
12
- export const get_ldpc_codeword_bits: () => number;
13
- export const get_ldpc_data_bits: () => number;
14
- export const get_m_rows: () => number;
15
- export const get_noise_weight: () => number;
16
- export const key_gen: () => number;
17
- export const keypair_private_key: (a: number) => [number, number];
18
- export const keypair_public_key_a: (a: number) => [number, number];
19
- export const keypair_public_key_t: (a: number) => [number, number];
20
- export const random_bits: (a: number) => [number, number];
21
- export const get_n_cols: () => number;
22
- export const __wbindgen_exn_store: (a: number) => void;
23
- export const __externref_table_alloc: () => number;
24
- export const __wbindgen_externrefs: WebAssembly.Table;
25
- export const __wbindgen_free: (a: number, b: number, c: number) => void;
26
- export const __wbindgen_malloc: (a: number, b: number) => number;
27
- export const __wbindgen_start: () => void;