@lib-q/ring 0.0.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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # lib-q-ring
2
+
3
+ Portable negacyclic ring arithmetic for `R_q = Z_q[X]/(X^256 + 1)` with `q = 8_380_417` (FIPS 204 ML-DSA field). Shared by [**lib-q-ml-dsa**](../lib-q-ml-dsa), [**lib-q-lattice-zkp**](../lib-q-lattice-zkp), and related crates.
4
+
5
+ ## Contents
6
+
7
+ - Montgomery / Barrett reduction and ML-DSA NTT (forward + inverse with Montgomery scaling)
8
+ - Polynomial types `Poly` / `NttPoly`, module vectors and matrices
9
+ - SHAKE128 matrix expansion (ExpandA-style) and FIPS 204 `SampleInBall` (SHAKE256)
10
+
11
+ ## Features
12
+
13
+ - `default`: `alloc`
14
+ - `alloc`: enables `lib-q-sha3/alloc` for XOF buffering helpers
15
+
16
+ ## Security
17
+
18
+ This crate is **research-grade** infrastructure: parameter sets and protocol security are not asserted here.
@@ -0,0 +1,6 @@
1
+ {
2
+ "integrity": {
3
+ "nodejs/lib_q_ring_bg.wasm": "sha384-hXicZ3IKvVYzEMMop8KPYR6V5W2/mlI/k5pWnNBgja7MIv18f3Na57YBlntuvORA",
4
+ "web/lib_q_ring_bg.wasm": "sha384-hXicZ3IKvVYzEMMop8KPYR6V5W2/mlI/k5pWnNBgja7MIv18f3Na57YBlntuvORA"
5
+ }
6
+ }
@@ -0,0 +1,18 @@
1
+ # lib-q-ring
2
+
3
+ Portable negacyclic ring arithmetic for `R_q = Z_q[X]/(X^256 + 1)` with `q = 8_380_417` (FIPS 204 ML-DSA field). Shared by [**lib-q-ml-dsa**](../lib-q-ml-dsa), [**lib-q-lattice-zkp**](../lib-q-lattice-zkp), and related crates.
4
+
5
+ ## Contents
6
+
7
+ - Montgomery / Barrett reduction and ML-DSA NTT (forward + inverse with Montgomery scaling)
8
+ - Polynomial types `Poly` / `NttPoly`, module vectors and matrices
9
+ - SHAKE128 matrix expansion (ExpandA-style) and FIPS 204 `SampleInBall` (SHAKE256)
10
+
11
+ ## Features
12
+
13
+ - `default`: `alloc`
14
+ - `alloc`: enables `lib-q-sha3/alloc` for XOF buffering helpers
15
+
16
+ ## Security
17
+
18
+ This crate is **research-grade** infrastructure: parameter sets and protocol security are not asserted here.
@@ -0,0 +1,12 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Ring dimension `N` (coefficients per polynomial), matching FIPS 204 ML-DSA.
6
+ */
7
+ export function ringCoefficientCount(): number;
8
+
9
+ /**
10
+ * Modulus `q` for \(R_q = Z_q[X]/(X^{256}+1)\).
11
+ */
12
+ export function ringModulusQ(): number;
@@ -0,0 +1,46 @@
1
+ /* @ts-self-types="./lib_q_ring.d.ts" */
2
+
3
+ /**
4
+ * Ring dimension `N` (coefficients per polynomial), matching FIPS 204 ML-DSA.
5
+ * @returns {number}
6
+ */
7
+ function ringCoefficientCount() {
8
+ const ret = wasm.ringCoefficientCount();
9
+ return ret >>> 0;
10
+ }
11
+ exports.ringCoefficientCount = ringCoefficientCount;
12
+
13
+ /**
14
+ * Modulus `q` for \(R_q = Z_q[X]/(X^{256}+1)\).
15
+ * @returns {number}
16
+ */
17
+ function ringModulusQ() {
18
+ const ret = wasm.ringModulusQ();
19
+ return ret >>> 0;
20
+ }
21
+ exports.ringModulusQ = ringModulusQ;
22
+ function __wbg_get_imports() {
23
+ const import0 = {
24
+ __proto__: null,
25
+ __wbindgen_init_externref_table: function() {
26
+ const table = wasm.__wbindgen_externrefs;
27
+ const offset = table.grow(4);
28
+ table.set(0, undefined);
29
+ table.set(offset + 0, undefined);
30
+ table.set(offset + 1, null);
31
+ table.set(offset + 2, true);
32
+ table.set(offset + 3, false);
33
+ },
34
+ };
35
+ return {
36
+ __proto__: null,
37
+ "./lib_q_ring_bg.js": import0,
38
+ };
39
+ }
40
+
41
+ const wasmPath = `${__dirname}/lib_q_ring_bg.wasm`;
42
+ const wasmBytes = require('fs').readFileSync(wasmPath);
43
+ const wasmModule = new WebAssembly.Module(wasmBytes);
44
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
45
+ let wasm = wasmInstance.exports;
46
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,7 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const ringCoefficientCount: () => number;
5
+ export const ringModulusQ: () => number;
6
+ export const __wbindgen_externrefs: WebAssembly.Table;
7
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "lib-q-ring",
3
+ "description": "Shared ring arithmetic (R_q = Z_q[X]/(X^n+1)) for FIPS 204 lattice primitives",
4
+ "version": "0.0.2",
5
+ "license": "Apache-2.0",
6
+ "files": [
7
+ "lib_q_ring_bg.wasm",
8
+ "lib_q_ring.js",
9
+ "lib_q_ring.d.ts"
10
+ ],
11
+ "main": "lib_q_ring.js",
12
+ "types": "lib_q_ring.d.ts",
13
+ "keywords": [
14
+ "cryptography",
15
+ "post-quantum",
16
+ "lattice",
17
+ "ml-dsa",
18
+ "no-std"
19
+ ]
20
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@lib-q/ring",
3
+ "type": "module",
4
+ "description": "ML-DSA ring arithmetic R_q (shared with lattice-zkp)",
5
+ "version": "0.0.2",
6
+ "license": "Apache-2.0",
7
+ "files": [
8
+ "web",
9
+ "nodejs",
10
+ "README.md",
11
+ "integrity-manifest.json"
12
+ ],
13
+ "main": "./nodejs/lib_q_ring.js",
14
+ "types": "./web/lib_q_ring.d.ts",
15
+ "sideEffects": [
16
+ "./snippets/*"
17
+ ],
18
+ "keywords": "[\"cryptography\",\"post-quantum\",\"lattice\",\"ml-dsa\",\"wasm\"]",
19
+ "author": "lib-Q Contributors",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Enkom-Tech/libQ.git"
23
+ },
24
+ "homepage": "https://github.com/Enkom-Tech/libQ#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/Enkom-Tech/libQ/issues"
27
+ },
28
+ "module": "./web/lib_q_ring.js",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./web/lib_q_ring.d.ts",
32
+ "browser": "./web/lib_q_ring.js",
33
+ "node": "./nodejs/lib_q_ring.js",
34
+ "default": "./web/lib_q_ring.js"
35
+ }
36
+ }
37
+ }
package/web/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # lib-q-ring
2
+
3
+ Portable negacyclic ring arithmetic for `R_q = Z_q[X]/(X^256 + 1)` with `q = 8_380_417` (FIPS 204 ML-DSA field). Shared by [**lib-q-ml-dsa**](../lib-q-ml-dsa), [**lib-q-lattice-zkp**](../lib-q-lattice-zkp), and related crates.
4
+
5
+ ## Contents
6
+
7
+ - Montgomery / Barrett reduction and ML-DSA NTT (forward + inverse with Montgomery scaling)
8
+ - Polynomial types `Poly` / `NttPoly`, module vectors and matrices
9
+ - SHAKE128 matrix expansion (ExpandA-style) and FIPS 204 `SampleInBall` (SHAKE256)
10
+
11
+ ## Features
12
+
13
+ - `default`: `alloc`
14
+ - `alloc`: enables `lib-q-sha3/alloc` for XOF buffering helpers
15
+
16
+ ## Security
17
+
18
+ This crate is **research-grade** infrastructure: parameter sets and protocol security are not asserted here.
@@ -0,0 +1,44 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Ring dimension `N` (coefficients per polynomial), matching FIPS 204 ML-DSA.
6
+ */
7
+ export function ringCoefficientCount(): number;
8
+
9
+ /**
10
+ * Modulus `q` for \(R_q = Z_q[X]/(X^{256}+1)\).
11
+ */
12
+ export function ringModulusQ(): number;
13
+
14
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
15
+
16
+ export interface InitOutput {
17
+ readonly memory: WebAssembly.Memory;
18
+ readonly ringCoefficientCount: () => number;
19
+ readonly ringModulusQ: () => number;
20
+ readonly __wbindgen_externrefs: WebAssembly.Table;
21
+ readonly __wbindgen_start: () => void;
22
+ }
23
+
24
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
25
+
26
+ /**
27
+ * Instantiates the given `module`, which can either be bytes or
28
+ * a precompiled `WebAssembly.Module`.
29
+ *
30
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
31
+ *
32
+ * @returns {InitOutput}
33
+ */
34
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
35
+
36
+ /**
37
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
38
+ * for everything else, calls `WebAssembly.instantiate` directly.
39
+ *
40
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
41
+ *
42
+ * @returns {Promise<InitOutput>}
43
+ */
44
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,129 @@
1
+ /* @ts-self-types="./lib_q_ring.d.ts" */
2
+
3
+ /**
4
+ * Ring dimension `N` (coefficients per polynomial), matching FIPS 204 ML-DSA.
5
+ * @returns {number}
6
+ */
7
+ export function ringCoefficientCount() {
8
+ const ret = wasm.ringCoefficientCount();
9
+ return ret >>> 0;
10
+ }
11
+
12
+ /**
13
+ * Modulus `q` for \(R_q = Z_q[X]/(X^{256}+1)\).
14
+ * @returns {number}
15
+ */
16
+ export function ringModulusQ() {
17
+ const ret = wasm.ringModulusQ();
18
+ return ret >>> 0;
19
+ }
20
+ function __wbg_get_imports() {
21
+ const import0 = {
22
+ __proto__: null,
23
+ __wbindgen_init_externref_table: function() {
24
+ const table = wasm.__wbindgen_externrefs;
25
+ const offset = table.grow(4);
26
+ table.set(0, undefined);
27
+ table.set(offset + 0, undefined);
28
+ table.set(offset + 1, null);
29
+ table.set(offset + 2, true);
30
+ table.set(offset + 3, false);
31
+ },
32
+ };
33
+ return {
34
+ __proto__: null,
35
+ "./lib_q_ring_bg.js": import0,
36
+ };
37
+ }
38
+
39
+ let wasmModule, wasmInstance, wasm;
40
+ function __wbg_finalize_init(instance, module) {
41
+ wasmInstance = instance;
42
+ wasm = instance.exports;
43
+ wasmModule = module;
44
+ wasm.__wbindgen_start();
45
+ return wasm;
46
+ }
47
+
48
+ async function __wbg_load(module, imports) {
49
+ if (typeof Response === 'function' && module instanceof Response) {
50
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
51
+ try {
52
+ return await WebAssembly.instantiateStreaming(module, imports);
53
+ } catch (e) {
54
+ const validResponse = module.ok && expectedResponseType(module.type);
55
+
56
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
57
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
58
+
59
+ } else { throw e; }
60
+ }
61
+ }
62
+
63
+ const bytes = await module.arrayBuffer();
64
+ return await WebAssembly.instantiate(bytes, imports);
65
+ } else {
66
+ const instance = await WebAssembly.instantiate(module, imports);
67
+
68
+ if (instance instanceof WebAssembly.Instance) {
69
+ return { instance, module };
70
+ } else {
71
+ return instance;
72
+ }
73
+ }
74
+
75
+ function expectedResponseType(type) {
76
+ switch (type) {
77
+ case 'basic': case 'cors': case 'default': return true;
78
+ }
79
+ return false;
80
+ }
81
+ }
82
+
83
+ function initSync(module) {
84
+ if (wasm !== undefined) return wasm;
85
+
86
+
87
+ if (module !== undefined) {
88
+ if (Object.getPrototypeOf(module) === Object.prototype) {
89
+ ({module} = module)
90
+ } else {
91
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
92
+ }
93
+ }
94
+
95
+ const imports = __wbg_get_imports();
96
+ if (!(module instanceof WebAssembly.Module)) {
97
+ module = new WebAssembly.Module(module);
98
+ }
99
+ const instance = new WebAssembly.Instance(module, imports);
100
+ return __wbg_finalize_init(instance, module);
101
+ }
102
+
103
+ async function __wbg_init(module_or_path) {
104
+ if (wasm !== undefined) return wasm;
105
+
106
+
107
+ if (module_or_path !== undefined) {
108
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
109
+ ({module_or_path} = module_or_path)
110
+ } else {
111
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
112
+ }
113
+ }
114
+
115
+ if (module_or_path === undefined) {
116
+ module_or_path = new URL('lib_q_ring_bg.wasm', import.meta.url);
117
+ }
118
+ const imports = __wbg_get_imports();
119
+
120
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
121
+ module_or_path = fetch(module_or_path);
122
+ }
123
+
124
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
125
+
126
+ return __wbg_finalize_init(instance, module);
127
+ }
128
+
129
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,7 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const ringCoefficientCount: () => number;
5
+ export const ringModulusQ: () => number;
6
+ export const __wbindgen_externrefs: WebAssembly.Table;
7
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "lib-q-ring",
3
+ "type": "module",
4
+ "description": "Shared ring arithmetic (R_q = Z_q[X]/(X^n+1)) for FIPS 204 lattice primitives",
5
+ "version": "0.0.2",
6
+ "license": "Apache-2.0",
7
+ "files": [
8
+ "lib_q_ring_bg.wasm",
9
+ "lib_q_ring.js",
10
+ "lib_q_ring.d.ts"
11
+ ],
12
+ "main": "lib_q_ring.js",
13
+ "types": "lib_q_ring.d.ts",
14
+ "sideEffects": [
15
+ "./snippets/*"
16
+ ],
17
+ "keywords": [
18
+ "cryptography",
19
+ "post-quantum",
20
+ "lattice",
21
+ "ml-dsa",
22
+ "no-std"
23
+ ]
24
+ }