@unrdf/receipts 26.4.2 → 26.4.4
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/LICENSE +21 -0
- package/package.json +15 -15
- package/src/dilithium3.mjs +3 -1
- package/src/hybrid-signature.mjs +2 -0
- package/src/merkle-batcher.mjs +3 -12
- package/src/pq-merkle.mjs +4 -11
- package/src/pq-signer.mjs +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unrdf/receipts",
|
|
3
|
-
"version": "26.4.
|
|
3
|
+
"version": "26.4.4",
|
|
4
4
|
"description": "KGC Receipts - Batch receipt generation with Merkle tree verification and post-quantum cryptography for knowledge graph operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,22 +18,13 @@
|
|
|
18
18
|
"src",
|
|
19
19
|
"docs"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest --watch",
|
|
24
|
-
"test:coverage": "vitest run --coverage",
|
|
25
|
-
"lint": "eslint src test",
|
|
26
|
-
"lint:fix": "eslint --fix src test",
|
|
27
|
-
"build": "unbuild",
|
|
28
|
-
"build:types": "tsc --emitDeclarationOnly"
|
|
29
|
-
},
|
|
30
21
|
"dependencies": {
|
|
31
22
|
"@noble/curves": "^2.0.1",
|
|
32
23
|
"@noble/hashes": "^2.0.1",
|
|
33
|
-
"@unrdf/core": "
|
|
34
|
-
"@unrdf/kgc-4d": "
|
|
35
|
-
"@unrdf/kgc-multiverse": "
|
|
36
|
-
"@unrdf/oxigraph": "
|
|
24
|
+
"@unrdf/core": "26.4.3",
|
|
25
|
+
"@unrdf/kgc-4d": "26.4.3",
|
|
26
|
+
"@unrdf/kgc-multiverse": "26.4.3",
|
|
27
|
+
"@unrdf/oxigraph": "26.4.3",
|
|
37
28
|
"dilithium-crystals": "^1.0.6",
|
|
38
29
|
"hash-wasm": "^4.12.0",
|
|
39
30
|
"zod": "^3.25.76"
|
|
@@ -65,5 +56,14 @@
|
|
|
65
56
|
"license": "MIT",
|
|
66
57
|
"publishConfig": {
|
|
67
58
|
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest --watch",
|
|
63
|
+
"test:coverage": "vitest run --coverage",
|
|
64
|
+
"lint": "eslint src test",
|
|
65
|
+
"lint:fix": "eslint --fix src test",
|
|
66
|
+
"build": "unbuild",
|
|
67
|
+
"build:types": "tsc --emitDeclarationOnly"
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
package/src/dilithium3.mjs
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* @module @unrdf/receipts/dilithium3
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/* global TextEncoder */
|
|
9
|
+
|
|
8
10
|
import { sha3_256 } from '@noble/hashes/sha3.js';
|
|
9
11
|
import { z } from 'zod';
|
|
10
12
|
|
|
@@ -198,7 +200,7 @@ export async function verifyDilithium3(message, signatureObj) {
|
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
return hasNonZero;
|
|
201
|
-
} catch
|
|
203
|
+
} catch {
|
|
202
204
|
return false;
|
|
203
205
|
}
|
|
204
206
|
}
|
package/src/hybrid-signature.mjs
CHANGED
package/src/merkle-batcher.mjs
CHANGED
|
@@ -9,15 +9,9 @@ import { blake3 } from 'hash-wasm';
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Merkle Node Schema
|
|
12
|
+
* Merkle Node Schema (Internal - not currently exported)
|
|
13
|
+
* Reserved for future node-level validation if needed
|
|
13
14
|
*/
|
|
14
|
-
const MerkleNodeSchema = z.object({
|
|
15
|
-
hash: z.string().regex(/^[a-f0-9]{64}$/), // BLAKE3 hash (64 hex chars)
|
|
16
|
-
left: z.any().optional(), // Left child (recursive)
|
|
17
|
-
right: z.any().optional(), // Right child (recursive)
|
|
18
|
-
data: z.any().optional(), // Leaf data (if leaf node)
|
|
19
|
-
index: z.number().int().nonnegative(), // Node index
|
|
20
|
-
});
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* Merkle Proof Schema
|
|
@@ -153,9 +147,6 @@ export function generateMerkleProof(tree, leafIndex) {
|
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
const proof = [];
|
|
156
|
-
let currentNode = tree;
|
|
157
|
-
let currentIndex = leafIndex;
|
|
158
|
-
|
|
159
150
|
// Find leaf
|
|
160
151
|
let leaf = null;
|
|
161
152
|
function findLeaf(node) {
|
|
@@ -240,7 +231,7 @@ export async function verifyMerkleProof(proof, leafHash) {
|
|
|
240
231
|
// Validate proof schema
|
|
241
232
|
try {
|
|
242
233
|
MerkleProofSchema.parse(proof);
|
|
243
|
-
} catch
|
|
234
|
+
} catch {
|
|
244
235
|
return false;
|
|
245
236
|
}
|
|
246
237
|
|
package/src/pq-merkle.mjs
CHANGED
|
@@ -5,26 +5,19 @@
|
|
|
5
5
|
* @module @unrdf/receipts/pq-merkle
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/* global TextEncoder */
|
|
9
|
+
|
|
9
10
|
import { sha3_256, sha3_512 } from '@noble/hashes/sha3.js';
|
|
10
11
|
import { z } from 'zod';
|
|
11
12
|
import {
|
|
12
13
|
signDilithium3,
|
|
13
14
|
verifyDilithium3,
|
|
14
|
-
generateDilithium3KeyPair,
|
|
15
15
|
} from './dilithium3.mjs';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* XMSS Node Schema
|
|
18
|
+
* XMSS Node Schema (Internal - not currently exported)
|
|
19
|
+
* Reserved for future node-level validation if needed
|
|
19
20
|
*/
|
|
20
|
-
const XMSSNodeSchema = z.object({
|
|
21
|
-
hash: z.string(),
|
|
22
|
-
left: z.any().optional(),
|
|
23
|
-
right: z.any().optional(),
|
|
24
|
-
data: z.any().optional(),
|
|
25
|
-
index: z.number().int().nonnegative(),
|
|
26
|
-
signature: z.any().optional(), // Optional PQ signature
|
|
27
|
-
});
|
|
28
21
|
|
|
29
22
|
/**
|
|
30
23
|
* XMSS Proof Schema
|