@moonglade/provenance 0.0.0-stage → 2.6.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/LICENSE +21 -0
- package/NOTICE.md +9 -0
- package/README.md +76 -2
- package/SPEC.md +176 -0
- package/TIMESTAMP.md +21 -0
- package/dist/artifact-cli.d.ts +2 -0
- package/dist/artifact-cli.js +108 -0
- package/dist/artifactEnvelope.d.ts +38 -0
- package/dist/artifactEnvelope.js +61 -0
- package/dist/artifactHook.d.ts +30 -0
- package/dist/artifactHook.js +114 -0
- package/dist/badge.d.ts +83 -0
- package/dist/badge.js +403 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.js +782 -0
- package/dist/mcp.d.ts +87 -0
- package/dist/mcp.js +352 -0
- package/dist/merkle.d.ts +71 -0
- package/dist/merkle.js +176 -0
- package/dist/self-test.d.ts +21 -0
- package/dist/self-test.js +280 -0
- package/dist/timestamp.d.ts +274 -0
- package/dist/timestamp.js +1103 -0
- package/package.json +75 -4
- package/trust/README.md +19 -0
- package/trust/registry.json +12 -0
- package/trust/root-public.asc +10 -0
- package/wasm/mgc_wasm.d.ts +53 -0
- package/wasm/mgc_wasm.js +389 -0
- package/wasm/mgc_wasm_bg.wasm +0 -0
- package/wasm/mgc_wasm_bg.wasm.d.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonglade/provenance",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.6.0",
|
|
4
|
+
"description": "Local-first cryptographic proof for markdown files and agentic AI memory substrates.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"provenance": "dist/artifact-cli.js",
|
|
9
|
+
"provenance-gate": "dist/mcp.js",
|
|
10
|
+
"provenance-artifact": "dist/artifact-cli.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "node clean-build.cjs && tsc",
|
|
14
|
+
"test": "npm run build && node -r ./test-harness.cjs --test src/*.test.js",
|
|
15
|
+
"self-test": "node dist/artifact-cli.js test",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"test:only": "node -r ./test-harness.cjs --test src/*.test.js"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/MoongladeAI/moonglade-provenance-public.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"provenance",
|
|
25
|
+
"ai",
|
|
26
|
+
"agentic",
|
|
27
|
+
"merkle",
|
|
28
|
+
"rfc3161",
|
|
29
|
+
"ed25519",
|
|
30
|
+
"mcp",
|
|
31
|
+
"moonglade"
|
|
32
|
+
],
|
|
33
|
+
"author": "Moonglade AI",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/*.js",
|
|
39
|
+
"dist/*.d.ts",
|
|
40
|
+
"wasm",
|
|
41
|
+
"README.md",
|
|
42
|
+
"SPEC.md",
|
|
43
|
+
"TIMESTAMP.md",
|
|
44
|
+
"LICENSE",
|
|
45
|
+
"NOTICE.md",
|
|
46
|
+
"trust"
|
|
47
|
+
],
|
|
48
|
+
"homepage": "https://github.com/MoongladeAI/moonglade-provenance-public#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/MoongladeAI/moonglade-provenance-public/issues"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "22.20.4",
|
|
54
|
+
"typescript": "5.9.3"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"asn1js": "3.0.10",
|
|
58
|
+
"pkijs": "3.4.1"
|
|
59
|
+
},
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
63
|
+
},
|
|
64
|
+
"exports": {
|
|
65
|
+
".": {
|
|
66
|
+
"types": "./dist/index.d.ts",
|
|
67
|
+
"require": "./dist/index.js",
|
|
68
|
+
"default": "./dist/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./wasm": {
|
|
71
|
+
"types": "./wasm/mgc_wasm.d.ts",
|
|
72
|
+
"require": "./wasm/mgc_wasm.js",
|
|
73
|
+
"default": "./wasm/mgc_wasm.js"
|
|
74
|
+
},
|
|
75
|
+
"./package.json": "./package.json"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/trust/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Release root trust
|
|
2
|
+
|
|
3
|
+
The OpenPGP release root fingerprint is:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
5E7FA9F6C5B0A65BC23A75704FF2C2DE69C0C4A3
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Inspect the public certificate independently:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
gpg --show-keys --with-fingerprint root-public.asc
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Verify the human release manifest or commit with GPG. Before trusting it, compare the full fingerprint with the MoongladeAI organization profile and the identified publication on moongladeai.net. Those external publications must be checked at release time. A key shipped inside the same untrusted download cannot establish its own identity.
|
|
16
|
+
|
|
17
|
+
The registry contains the root role only. Agent reviews have no architect authority. The registry remains an unsigned candidate until the human gate signs it.
|
|
18
|
+
|
|
19
|
+
The artifact API accepts raw Ed25519 SPKI PEM keys, not OpenPGP certificates. Do not pass this certificate to that API or use the release root from an unattended agent. The certificate's user IDs are deliberate public signer identifiers.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
2
|
+
|
|
3
|
+
mDMEapbUuBYJKwYBBAHaRw8BAQdAULJ9to5djqb63TWkuBsylWfKgrujIbevcM5L
|
|
4
|
+
acOhv1C0O01hcmMgT3R0bGV5IChGb3VuZGVyLCBNb29uZ2xhZGUgQUkpIDxtb29u
|
|
5
|
+
Z2xhZGVhaUBnbWFpbC5jb20+iJkEExYKAEEWIQRef6n2xbCmW8I6dXBP8sLeacDE
|
|
6
|
+
owUCapbUuAIbIwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRBP
|
|
7
|
+
8sLeacDEowfNAQC1o+XcHAHwhpc1MMSZClFb/ylagyPo7Y7pdJkgPRWHzAEA3Owi
|
|
8
|
+
zID5JKGznM+xVhNA7LaiHIYMEKx3KgLJbsUeRAc=
|
|
9
|
+
=gFm3
|
|
10
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Claims JSON per draft -03 section 3.3: safe-integer numbers (judged by value) and UTF-16 key order.
|
|
6
|
+
*/
|
|
7
|
+
export function canonicalize_claims_json(json: string): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Canonicalize a JSON string according to RFC-8785 (JCS).
|
|
11
|
+
*/
|
|
12
|
+
export function canonicalize_json(json_str: string): string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Strict provenance-ts text/binary canonicalization, distinct from frozen legacy profiles.
|
|
16
|
+
*/
|
|
17
|
+
export function canonicalize_provenance(filename: string, bytes: Uint8Array): Uint8Array;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the engine version and cryptographic capabilities.
|
|
21
|
+
*/
|
|
22
|
+
export function engine_info(): string;
|
|
23
|
+
|
|
24
|
+
export function provenance_inclusion_proof(artifacts_json: string, target: string): string;
|
|
25
|
+
|
|
26
|
+
export function provenance_merkle_root(artifacts_json: string): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Compute SHA-256 digest over arbitrary binary bytes, returning lowercase hex.
|
|
30
|
+
*/
|
|
31
|
+
export function sha256_digest(bytes: Uint8Array): string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Verify a full Moonglade sidecar attestation against a live payload hash and known signers registry.
|
|
35
|
+
*
|
|
36
|
+
* Returns a JSON string of the complete `Verdict`.
|
|
37
|
+
*/
|
|
38
|
+
export function verify_attestation(current_hash: string, sidecar_json: string, known_signers_json: string): string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Verify a raw Ed25519 signature over a message using hex-encoded public key and signature.
|
|
42
|
+
*/
|
|
43
|
+
export function verify_ed25519_hex(message: Uint8Array, signature_hex: string, public_key_hex: string): boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Verify a Merkle inclusion proof for a leaf against a root digest.
|
|
47
|
+
*
|
|
48
|
+
* Siblings must be passed as an ordered array of 32-byte hex hashes with a direction flag
|
|
49
|
+
* (e.g. `[{"hash": "...", "is_left": true}]`).
|
|
50
|
+
*/
|
|
51
|
+
export function verify_merkle_proof(leaf_hash_hex: string, root_hash_hex: string, proof_siblings_json: string): boolean;
|
|
52
|
+
|
|
53
|
+
export function verify_provenance_merkle_proof(proof_json: string, expected_root: string): boolean;
|
package/wasm/mgc_wasm.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/* @ts-self-types="./mgc_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claims JSON per draft -03 section 3.3: safe-integer numbers (judged by value) and UTF-16 key order.
|
|
5
|
+
* @param {string} json
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
function canonicalize_claims_json(json) {
|
|
9
|
+
let deferred3_0;
|
|
10
|
+
let deferred3_1;
|
|
11
|
+
try {
|
|
12
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ret = wasm.canonicalize_claims_json(ptr0, len0);
|
|
15
|
+
var ptr2 = ret[0];
|
|
16
|
+
var len2 = ret[1];
|
|
17
|
+
if (ret[3]) {
|
|
18
|
+
ptr2 = 0; len2 = 0;
|
|
19
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
20
|
+
}
|
|
21
|
+
deferred3_0 = ptr2;
|
|
22
|
+
deferred3_1 = len2;
|
|
23
|
+
return getStringFromWasm0(ptr2, len2);
|
|
24
|
+
} finally {
|
|
25
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.canonicalize_claims_json = canonicalize_claims_json;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Canonicalize a JSON string according to RFC-8785 (JCS).
|
|
32
|
+
* @param {string} json_str
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
function canonicalize_json(json_str) {
|
|
36
|
+
let deferred3_0;
|
|
37
|
+
let deferred3_1;
|
|
38
|
+
try {
|
|
39
|
+
const ptr0 = passStringToWasm0(json_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
|
+
const len0 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.canonicalize_json(ptr0, len0);
|
|
42
|
+
var ptr2 = ret[0];
|
|
43
|
+
var len2 = ret[1];
|
|
44
|
+
if (ret[3]) {
|
|
45
|
+
ptr2 = 0; len2 = 0;
|
|
46
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
47
|
+
}
|
|
48
|
+
deferred3_0 = ptr2;
|
|
49
|
+
deferred3_1 = len2;
|
|
50
|
+
return getStringFromWasm0(ptr2, len2);
|
|
51
|
+
} finally {
|
|
52
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.canonicalize_json = canonicalize_json;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Strict provenance-ts text/binary canonicalization, distinct from frozen legacy profiles.
|
|
59
|
+
* @param {string} filename
|
|
60
|
+
* @param {Uint8Array} bytes
|
|
61
|
+
* @returns {Uint8Array}
|
|
62
|
+
*/
|
|
63
|
+
function canonicalize_provenance(filename, bytes) {
|
|
64
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
65
|
+
const len0 = WASM_VECTOR_LEN;
|
|
66
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
67
|
+
const len1 = WASM_VECTOR_LEN;
|
|
68
|
+
const ret = wasm.canonicalize_provenance(ptr0, len0, ptr1, len1);
|
|
69
|
+
if (ret[3]) {
|
|
70
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
71
|
+
}
|
|
72
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
73
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
74
|
+
return v3;
|
|
75
|
+
}
|
|
76
|
+
exports.canonicalize_provenance = canonicalize_provenance;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns the engine version and cryptographic capabilities.
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
function engine_info() {
|
|
83
|
+
let deferred1_0;
|
|
84
|
+
let deferred1_1;
|
|
85
|
+
try {
|
|
86
|
+
const ret = wasm.engine_info();
|
|
87
|
+
deferred1_0 = ret[0];
|
|
88
|
+
deferred1_1 = ret[1];
|
|
89
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
90
|
+
} finally {
|
|
91
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.engine_info = engine_info;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} artifacts_json
|
|
98
|
+
* @param {string} target
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
function provenance_inclusion_proof(artifacts_json, target) {
|
|
102
|
+
let deferred4_0;
|
|
103
|
+
let deferred4_1;
|
|
104
|
+
try {
|
|
105
|
+
const ptr0 = passStringToWasm0(artifacts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
108
|
+
const len1 = WASM_VECTOR_LEN;
|
|
109
|
+
const ret = wasm.provenance_inclusion_proof(ptr0, len0, ptr1, len1);
|
|
110
|
+
var ptr3 = ret[0];
|
|
111
|
+
var len3 = ret[1];
|
|
112
|
+
if (ret[3]) {
|
|
113
|
+
ptr3 = 0; len3 = 0;
|
|
114
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
115
|
+
}
|
|
116
|
+
deferred4_0 = ptr3;
|
|
117
|
+
deferred4_1 = len3;
|
|
118
|
+
return getStringFromWasm0(ptr3, len3);
|
|
119
|
+
} finally {
|
|
120
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.provenance_inclusion_proof = provenance_inclusion_proof;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {string} artifacts_json
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
function provenance_merkle_root(artifacts_json) {
|
|
130
|
+
let deferred3_0;
|
|
131
|
+
let deferred3_1;
|
|
132
|
+
try {
|
|
133
|
+
const ptr0 = passStringToWasm0(artifacts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
const ret = wasm.provenance_merkle_root(ptr0, len0);
|
|
136
|
+
var ptr2 = ret[0];
|
|
137
|
+
var len2 = ret[1];
|
|
138
|
+
if (ret[3]) {
|
|
139
|
+
ptr2 = 0; len2 = 0;
|
|
140
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
141
|
+
}
|
|
142
|
+
deferred3_0 = ptr2;
|
|
143
|
+
deferred3_1 = len2;
|
|
144
|
+
return getStringFromWasm0(ptr2, len2);
|
|
145
|
+
} finally {
|
|
146
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.provenance_merkle_root = provenance_merkle_root;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Compute SHA-256 digest over arbitrary binary bytes, returning lowercase hex.
|
|
153
|
+
* @param {Uint8Array} bytes
|
|
154
|
+
* @returns {string}
|
|
155
|
+
*/
|
|
156
|
+
function sha256_digest(bytes) {
|
|
157
|
+
let deferred2_0;
|
|
158
|
+
let deferred2_1;
|
|
159
|
+
try {
|
|
160
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
161
|
+
const len0 = WASM_VECTOR_LEN;
|
|
162
|
+
const ret = wasm.sha256_digest(ptr0, len0);
|
|
163
|
+
deferred2_0 = ret[0];
|
|
164
|
+
deferred2_1 = ret[1];
|
|
165
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
166
|
+
} finally {
|
|
167
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.sha256_digest = sha256_digest;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Verify a full Moonglade sidecar attestation against a live payload hash and known signers registry.
|
|
174
|
+
*
|
|
175
|
+
* Returns a JSON string of the complete `Verdict`.
|
|
176
|
+
* @param {string} current_hash
|
|
177
|
+
* @param {string} sidecar_json
|
|
178
|
+
* @param {string} known_signers_json
|
|
179
|
+
* @returns {string}
|
|
180
|
+
*/
|
|
181
|
+
function verify_attestation(current_hash, sidecar_json, known_signers_json) {
|
|
182
|
+
let deferred5_0;
|
|
183
|
+
let deferred5_1;
|
|
184
|
+
try {
|
|
185
|
+
const ptr0 = passStringToWasm0(current_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
186
|
+
const len0 = WASM_VECTOR_LEN;
|
|
187
|
+
const ptr1 = passStringToWasm0(sidecar_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
188
|
+
const len1 = WASM_VECTOR_LEN;
|
|
189
|
+
const ptr2 = passStringToWasm0(known_signers_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
+
const len2 = WASM_VECTOR_LEN;
|
|
191
|
+
const ret = wasm.verify_attestation(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
192
|
+
var ptr4 = ret[0];
|
|
193
|
+
var len4 = ret[1];
|
|
194
|
+
if (ret[3]) {
|
|
195
|
+
ptr4 = 0; len4 = 0;
|
|
196
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
197
|
+
}
|
|
198
|
+
deferred5_0 = ptr4;
|
|
199
|
+
deferred5_1 = len4;
|
|
200
|
+
return getStringFromWasm0(ptr4, len4);
|
|
201
|
+
} finally {
|
|
202
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.verify_attestation = verify_attestation;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Verify a raw Ed25519 signature over a message using hex-encoded public key and signature.
|
|
209
|
+
* @param {Uint8Array} message
|
|
210
|
+
* @param {string} signature_hex
|
|
211
|
+
* @param {string} public_key_hex
|
|
212
|
+
* @returns {boolean}
|
|
213
|
+
*/
|
|
214
|
+
function verify_ed25519_hex(message, signature_hex, public_key_hex) {
|
|
215
|
+
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
216
|
+
const len0 = WASM_VECTOR_LEN;
|
|
217
|
+
const ptr1 = passStringToWasm0(signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len1 = WASM_VECTOR_LEN;
|
|
219
|
+
const ptr2 = passStringToWasm0(public_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
220
|
+
const len2 = WASM_VECTOR_LEN;
|
|
221
|
+
const ret = wasm.verify_ed25519_hex(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
222
|
+
if (ret[2]) {
|
|
223
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
224
|
+
}
|
|
225
|
+
return ret[0] !== 0;
|
|
226
|
+
}
|
|
227
|
+
exports.verify_ed25519_hex = verify_ed25519_hex;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Verify a Merkle inclusion proof for a leaf against a root digest.
|
|
231
|
+
*
|
|
232
|
+
* Siblings must be passed as an ordered array of 32-byte hex hashes with a direction flag
|
|
233
|
+
* (e.g. `[{"hash": "...", "is_left": true}]`).
|
|
234
|
+
* @param {string} leaf_hash_hex
|
|
235
|
+
* @param {string} root_hash_hex
|
|
236
|
+
* @param {string} proof_siblings_json
|
|
237
|
+
* @returns {boolean}
|
|
238
|
+
*/
|
|
239
|
+
function verify_merkle_proof(leaf_hash_hex, root_hash_hex, proof_siblings_json) {
|
|
240
|
+
const ptr0 = passStringToWasm0(leaf_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
242
|
+
const ptr1 = passStringToWasm0(root_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
243
|
+
const len1 = WASM_VECTOR_LEN;
|
|
244
|
+
const ptr2 = passStringToWasm0(proof_siblings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
245
|
+
const len2 = WASM_VECTOR_LEN;
|
|
246
|
+
const ret = wasm.verify_merkle_proof(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
247
|
+
if (ret[2]) {
|
|
248
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
249
|
+
}
|
|
250
|
+
return ret[0] !== 0;
|
|
251
|
+
}
|
|
252
|
+
exports.verify_merkle_proof = verify_merkle_proof;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @param {string} proof_json
|
|
256
|
+
* @param {string} expected_root
|
|
257
|
+
* @returns {boolean}
|
|
258
|
+
*/
|
|
259
|
+
function verify_provenance_merkle_proof(proof_json, expected_root) {
|
|
260
|
+
const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
261
|
+
const len0 = WASM_VECTOR_LEN;
|
|
262
|
+
const ptr1 = passStringToWasm0(expected_root, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
263
|
+
const len1 = WASM_VECTOR_LEN;
|
|
264
|
+
const ret = wasm.verify_provenance_merkle_proof(ptr0, len0, ptr1, len1);
|
|
265
|
+
if (ret[2]) {
|
|
266
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
267
|
+
}
|
|
268
|
+
return ret[0] !== 0;
|
|
269
|
+
}
|
|
270
|
+
exports.verify_provenance_merkle_proof = verify_provenance_merkle_proof;
|
|
271
|
+
function __wbg_get_imports() {
|
|
272
|
+
const import0 = {
|
|
273
|
+
__proto__: null,
|
|
274
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
275
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
276
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
277
|
+
return ret;
|
|
278
|
+
},
|
|
279
|
+
__wbindgen_init_externref_table: function() {
|
|
280
|
+
const table = wasm.__wbindgen_externrefs;
|
|
281
|
+
const offset = table.grow(4);
|
|
282
|
+
table.set(0, undefined);
|
|
283
|
+
table.set(offset + 0, undefined);
|
|
284
|
+
table.set(offset + 1, null);
|
|
285
|
+
table.set(offset + 2, true);
|
|
286
|
+
table.set(offset + 3, false);
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
return {
|
|
290
|
+
__proto__: null,
|
|
291
|
+
"./mgc_wasm_bg.js": import0,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
296
|
+
ptr = ptr >>> 0;
|
|
297
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function getStringFromWasm0(ptr, len) {
|
|
301
|
+
return decodeText(ptr >>> 0, len);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let cachedUint8ArrayMemory0 = null;
|
|
305
|
+
function getUint8ArrayMemory0() {
|
|
306
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
307
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
308
|
+
}
|
|
309
|
+
return cachedUint8ArrayMemory0;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
313
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
314
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
315
|
+
WASM_VECTOR_LEN = arg.length;
|
|
316
|
+
return ptr;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
320
|
+
if (realloc === undefined) {
|
|
321
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
322
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
323
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
324
|
+
WASM_VECTOR_LEN = buf.length;
|
|
325
|
+
return ptr;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
let len = arg.length;
|
|
329
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
330
|
+
|
|
331
|
+
const mem = getUint8ArrayMemory0();
|
|
332
|
+
|
|
333
|
+
let offset = 0;
|
|
334
|
+
|
|
335
|
+
for (; offset < len; offset++) {
|
|
336
|
+
const code = arg.charCodeAt(offset);
|
|
337
|
+
if (code > 0x7F) break;
|
|
338
|
+
mem[ptr + offset] = code;
|
|
339
|
+
}
|
|
340
|
+
if (offset !== len) {
|
|
341
|
+
if (offset !== 0) {
|
|
342
|
+
arg = arg.slice(offset);
|
|
343
|
+
}
|
|
344
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
345
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
346
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
347
|
+
|
|
348
|
+
offset += ret.written;
|
|
349
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
WASM_VECTOR_LEN = offset;
|
|
353
|
+
return ptr;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function takeFromExternrefTable0(idx) {
|
|
357
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
358
|
+
wasm.__externref_table_dealloc(idx);
|
|
359
|
+
return value;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
363
|
+
cachedTextDecoder.decode();
|
|
364
|
+
function decodeText(ptr, len) {
|
|
365
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const cachedTextEncoder = new TextEncoder();
|
|
369
|
+
|
|
370
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
371
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
372
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
373
|
+
view.set(buf);
|
|
374
|
+
return {
|
|
375
|
+
read: arg.length,
|
|
376
|
+
written: buf.length
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
let WASM_VECTOR_LEN = 0;
|
|
382
|
+
|
|
383
|
+
const path = require('path');
|
|
384
|
+
const wasmPath = path.join(__dirname, 'mgc_wasm_bg.wasm');
|
|
385
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
386
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
387
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
388
|
+
let wasm = wasmInstance.exports;
|
|
389
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const canonicalize_claims_json: (a: number, b: number) => [number, number, number, number];
|
|
5
|
+
export const canonicalize_json: (a: number, b: number) => [number, number, number, number];
|
|
6
|
+
export const canonicalize_provenance: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
7
|
+
export const engine_info: () => [number, number];
|
|
8
|
+
export const provenance_inclusion_proof: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
+
export const provenance_merkle_root: (a: number, b: number) => [number, number, number, number];
|
|
10
|
+
export const sha256_digest: (a: number, b: number) => [number, number];
|
|
11
|
+
export const verify_attestation: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
12
|
+
export const verify_ed25519_hex: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
13
|
+
export const verify_merkle_proof: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
14
|
+
export const verify_provenance_merkle_proof: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
15
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
16
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
17
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
18
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
19
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
20
|
+
export const __wbindgen_start: () => void;
|