@primust/artifact-core 1.0.0 → 1.3.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 +93 -0
- package/dist/canonical.d.ts +11 -0
- package/dist/canonical.d.ts.map +1 -1
- package/dist/canonical.js +92 -0
- package/dist/canonical.js.map +1 -1
- package/dist/commitment.d.ts +56 -8
- package/dist/commitment.d.ts.map +1 -1
- package/dist/commitment.js +71 -26
- package/dist/commitment.js.map +1 -1
- package/dist/commitment.test.js +14 -3
- package/dist/commitment.test.js.map +1 -1
- package/dist/hierarchical_leaf.d.ts +72 -0
- package/dist/hierarchical_leaf.d.ts.map +1 -0
- package/dist/hierarchical_leaf.js +144 -0
- package/dist/hierarchical_leaf.js.map +1 -0
- package/dist/hierarchical_leaf.test.d.ts +15 -0
- package/dist/hierarchical_leaf.test.d.ts.map +1 -0
- package/dist/hierarchical_leaf.test.js +145 -0
- package/dist/hierarchical_leaf.test.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/metadata_source.d.ts +4 -0
- package/dist/metadata_source.d.ts.map +1 -0
- package/dist/metadata_source.js +54 -0
- package/dist/metadata_source.js.map +1 -0
- package/dist/metadata_source.test.d.ts +2 -0
- package/dist/metadata_source.test.d.ts.map +1 -0
- package/dist/metadata_source.test.js +29 -0
- package/dist/metadata_source.test.js.map +1 -0
- package/dist/reversibility_taxonomy.d.ts +23 -0
- package/dist/reversibility_taxonomy.d.ts.map +1 -0
- package/dist/reversibility_taxonomy.js +208 -0
- package/dist/reversibility_taxonomy.js.map +1 -0
- package/dist/reversibility_taxonomy.test.d.ts +2 -0
- package/dist/reversibility_taxonomy.test.d.ts.map +1 -0
- package/dist/reversibility_taxonomy.test.js +146 -0
- package/dist/reversibility_taxonomy.test.js.map +1 -0
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +30 -6
- package/dist/signing.js.map +1 -1
- package/dist/trust_edge_mapping.d.ts +12 -0
- package/dist/trust_edge_mapping.d.ts.map +1 -0
- package/dist/trust_edge_mapping.js +88 -0
- package/dist/trust_edge_mapping.js.map +1 -0
- package/dist/trust_edge_mapping.test.d.ts +2 -0
- package/dist/trust_edge_mapping.test.d.ts.map +1 -0
- package/dist/trust_edge_mapping.test.js +86 -0
- package/dist/trust_edge_mapping.test.js.map +1 -0
- package/dist/types/artifact.d.ts +65 -4
- package/dist/types/artifact.d.ts.map +1 -1
- package/dist/types/proof_artifact.d.ts +52 -0
- package/dist/types/proof_artifact.d.ts.map +1 -0
- package/dist/types/proof_artifact.js +12 -0
- package/dist/types/proof_artifact.js.map +1 -0
- package/dist/validate-artifact.d.ts.map +1 -1
- package/dist/validate-artifact.js +88 -10
- package/dist/validate-artifact.js.map +1 -1
- package/dist/validate-artifact.test.js +16 -2
- package/dist/validate-artifact.test.js.map +1 -1
- package/package.json +13 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity.
|
|
18
|
+
|
|
19
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
20
|
+
exercising permissions granted by this License.
|
|
21
|
+
|
|
22
|
+
"Source" form shall mean the preferred form for making modifications.
|
|
23
|
+
|
|
24
|
+
"Object" form shall mean any form resulting from mechanical
|
|
25
|
+
transformation or translation of a Source form.
|
|
26
|
+
|
|
27
|
+
"Work" shall mean the work of authorship made available under
|
|
28
|
+
the License.
|
|
29
|
+
|
|
30
|
+
"Contribution" shall mean any work of authorship submitted to the
|
|
31
|
+
Licensor for inclusion in the Work.
|
|
32
|
+
|
|
33
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
34
|
+
whom a Contribution has been received by the Licensor.
|
|
35
|
+
|
|
36
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
37
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
38
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
39
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
40
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
41
|
+
Work and such Derivative Works in Source or Object form.
|
|
42
|
+
|
|
43
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
44
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
45
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
46
|
+
patent license to make, have made, use, offer to sell, sell,
|
|
47
|
+
import, and otherwise transfer the Work.
|
|
48
|
+
|
|
49
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
50
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
51
|
+
modifications, and in Source or Object form, provided that You
|
|
52
|
+
meet the following conditions:
|
|
53
|
+
|
|
54
|
+
(a) You must give any other recipients of the Work or
|
|
55
|
+
Derivative Works a copy of this License; and
|
|
56
|
+
|
|
57
|
+
(b) You must cause any modified files to carry prominent notices
|
|
58
|
+
stating that You changed the files; and
|
|
59
|
+
|
|
60
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
61
|
+
that You distribute, all copyright, patent, trademark, and
|
|
62
|
+
attribution notices from the Source form of the Work; and
|
|
63
|
+
|
|
64
|
+
(d) If the Work includes a "NOTICE" text file, You must include
|
|
65
|
+
a readable copy of the attribution notices contained within
|
|
66
|
+
such NOTICE file.
|
|
67
|
+
|
|
68
|
+
5. Submission of Contributions.
|
|
69
|
+
|
|
70
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
71
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
72
|
+
|
|
73
|
+
7. Disclaimer of Warranty. The Work is provided on an "AS IS" BASIS,
|
|
74
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
75
|
+
|
|
76
|
+
8. Limitation of Liability. In no event shall any Contributor be
|
|
77
|
+
liable to You for damages.
|
|
78
|
+
|
|
79
|
+
9. Accepting Warranty or Additional Liability.
|
|
80
|
+
|
|
81
|
+
Copyright 2026 Primust Inc.
|
|
82
|
+
|
|
83
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
84
|
+
you may not use this file except in compliance with the License.
|
|
85
|
+
You may obtain a copy of the License at
|
|
86
|
+
|
|
87
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
88
|
+
|
|
89
|
+
Unless required by applicable law or agreed to in writing, software
|
|
90
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
91
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
92
|
+
See the License for the specific language governing permissions and
|
|
93
|
+
limitations under the License.
|
package/dist/canonical.d.ts
CHANGED
|
@@ -21,4 +21,15 @@
|
|
|
21
21
|
* @throws TypeError if the value contains non-JSON-native types
|
|
22
22
|
*/
|
|
23
23
|
export declare function canonical(value: unknown): string;
|
|
24
|
+
/**
|
|
25
|
+
* Pre-2026-04-19 canonical form — matches the old Python canonicalizer
|
|
26
|
+
* which rendered floats via Python's json.dumps (i.e. Python's repr for
|
|
27
|
+
* floats). Differs from ECMA-262 on integer-valued floats, negative
|
|
28
|
+
* zero, scientific-notation threshold (Python ≥1e16 vs ECMA ≥1e21),
|
|
29
|
+
* and zero-padded exponents (Python "1e-05" vs ECMA "1e-5").
|
|
30
|
+
*
|
|
31
|
+
* Kept ONLY so the TS verifier can validate legacy signatures signed by
|
|
32
|
+
* the old Python server. NEVER use for new signing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function canonicalLegacy(value: unknown): string;
|
|
24
35
|
//# sourceMappingURL=canonical.d.ts.map
|
package/dist/canonical.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD"}
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAiFD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
|
package/dist/canonical.js
CHANGED
|
@@ -80,4 +80,96 @@ function serializeArray(arr) {
|
|
|
80
80
|
}
|
|
81
81
|
return `[${elements.join(',')}]`;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Pre-2026-04-19 canonical form — matches the old Python canonicalizer
|
|
85
|
+
* which rendered floats via Python's json.dumps (i.e. Python's repr for
|
|
86
|
+
* floats). Differs from ECMA-262 on integer-valued floats, negative
|
|
87
|
+
* zero, scientific-notation threshold (Python ≥1e16 vs ECMA ≥1e21),
|
|
88
|
+
* and zero-padded exponents (Python "1e-05" vs ECMA "1e-5").
|
|
89
|
+
*
|
|
90
|
+
* Kept ONLY so the TS verifier can validate legacy signatures signed by
|
|
91
|
+
* the old Python server. NEVER use for new signing.
|
|
92
|
+
*/
|
|
93
|
+
export function canonicalLegacy(value) {
|
|
94
|
+
return serializeValueLegacy(value);
|
|
95
|
+
}
|
|
96
|
+
function serializeValueLegacy(value) {
|
|
97
|
+
if (value === null)
|
|
98
|
+
return 'null';
|
|
99
|
+
switch (typeof value) {
|
|
100
|
+
case 'string':
|
|
101
|
+
return JSON.stringify(value);
|
|
102
|
+
case 'number':
|
|
103
|
+
if (!Number.isFinite(value)) {
|
|
104
|
+
throw new TypeError(`canonical_legacy: cannot serialize ${value} (NaN/Infinity are not valid JSON)`);
|
|
105
|
+
}
|
|
106
|
+
return pythonFloatRepr(value);
|
|
107
|
+
case 'boolean':
|
|
108
|
+
return value ? 'true' : 'false';
|
|
109
|
+
case 'object':
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
return ('[' +
|
|
112
|
+
value.map((item) => serializeValueLegacy(item)).join(',') +
|
|
113
|
+
']');
|
|
114
|
+
}
|
|
115
|
+
if (value instanceof Date) {
|
|
116
|
+
throw new TypeError('canonical_legacy: Date objects must be ISO strings');
|
|
117
|
+
}
|
|
118
|
+
if (value instanceof Uint8Array ||
|
|
119
|
+
(typeof Buffer !== 'undefined' && Buffer.isBuffer(value))) {
|
|
120
|
+
throw new TypeError('canonical_legacy: byte arrays must be base64url');
|
|
121
|
+
}
|
|
122
|
+
return serializeObjectLegacy(value);
|
|
123
|
+
case 'undefined':
|
|
124
|
+
throw new TypeError('canonical_legacy: undefined is not valid JSON');
|
|
125
|
+
default:
|
|
126
|
+
throw new TypeError(`canonical_legacy: unsupported type ${typeof value}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function serializeObjectLegacy(obj) {
|
|
130
|
+
const keys = Object.keys(obj).sort();
|
|
131
|
+
const pairs = [];
|
|
132
|
+
for (const key of keys) {
|
|
133
|
+
const val = obj[key];
|
|
134
|
+
if (val === undefined)
|
|
135
|
+
continue;
|
|
136
|
+
pairs.push(`${JSON.stringify(key)}:${serializeValueLegacy(val)}`);
|
|
137
|
+
}
|
|
138
|
+
return `{${pairs.join(',')}}`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Render a number matching Python's `json.dumps(n)` output for floats
|
|
142
|
+
* (json.dumps uses Python's float repr). Integers round-trip as-is.
|
|
143
|
+
*
|
|
144
|
+
* Python float repr rules (CPython ≥3.1):
|
|
145
|
+
* - Integers ending in .0: "1.0", "100.0"
|
|
146
|
+
* - Negative zero: "-0.0"
|
|
147
|
+
* - Scientific threshold: |n| ≥ 1e16 or < 1e-4 → scientific "e+NN"/"e-NN"
|
|
148
|
+
* with ZERO-PADDED 2-digit exponents
|
|
149
|
+
* - Otherwise: plain decimal
|
|
150
|
+
*/
|
|
151
|
+
function pythonFloatRepr(n) {
|
|
152
|
+
if (Number.isInteger(n) && !Object.is(n, -0)) {
|
|
153
|
+
// Python writes 1 → "1" (int), 1.0 → "1.0" (float). JS can't tell
|
|
154
|
+
// them apart post-parse, so assume numbers reaching legacy-float
|
|
155
|
+
// rendering are floats. Integer-valued floats get ".0".
|
|
156
|
+
if (Math.abs(n) < 1e16) {
|
|
157
|
+
return `${n.toFixed(1)}`;
|
|
158
|
+
}
|
|
159
|
+
// |n| >= 1e16 uses scientific even for integer-valued floats
|
|
160
|
+
return pythonScientific(n);
|
|
161
|
+
}
|
|
162
|
+
if (Object.is(n, -0))
|
|
163
|
+
return '-0.0';
|
|
164
|
+
if (Math.abs(n) >= 1e16 || (n !== 0 && Math.abs(n) < 1e-4)) {
|
|
165
|
+
return pythonScientific(n);
|
|
166
|
+
}
|
|
167
|
+
return n.toString();
|
|
168
|
+
}
|
|
169
|
+
/** Render to Python-style scientific: "1e+20", "1.23e-10", with
|
|
170
|
+
* zero-padded single-digit exponents ("1e-05" not "1e-5"). */
|
|
171
|
+
function pythonScientific(n) {
|
|
172
|
+
const s = n.toExponential();
|
|
173
|
+
return s.replace(/e([+-])(\d)$/, 'e$10$2');
|
|
174
|
+
}
|
|
83
175
|
//# sourceMappingURL=canonical.js.map
|
package/dist/canonical.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtB,CAAC;AAED;+DAC+D;AAC/D,SAAS,gBAAgB,CAAC,CAAS;IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/commitment.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Primust Artifact Core — Commitment Layer (P6-A)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Poseidon2 (default, ZK-friendly) and SHA-256 (opt-in via PRIMUST_COMMITMENT_ALGORITHM=sha256) commitments.
|
|
5
5
|
* Poseidon2 uses a pure implementation — opt-in only until an audited reference
|
|
6
6
|
* (e.g. Barretenberg) is validated.
|
|
7
7
|
*
|
|
@@ -11,16 +11,52 @@
|
|
|
11
11
|
import type { CommitmentAlgorithm, ProofLevel } from './types/artifact.js';
|
|
12
12
|
/** ZK proof generation is always non-blocking. Non-negotiable. */
|
|
13
13
|
export declare const ZK_IS_BLOCKING: false;
|
|
14
|
+
/**
|
|
15
|
+
* BN254 scalar field modulus.
|
|
16
|
+
* All Poseidon2 field arithmetic operates modulo this prime.
|
|
17
|
+
*
|
|
18
|
+
* Exported so downstream packages (e.g. runtime-core blinding generation)
|
|
19
|
+
* can reduce 32-byte randomness into a valid BN254 field element without
|
|
20
|
+
* duplicating the constant.
|
|
21
|
+
*/
|
|
22
|
+
export declare const BN254_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
14
23
|
export interface CommitmentResult {
|
|
15
24
|
hash: string;
|
|
16
25
|
algorithm: CommitmentAlgorithm;
|
|
17
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert bytes to BN254 field elements.
|
|
29
|
+
* Each chunk of 31 bytes is interpreted as a big-endian unsigned integer
|
|
30
|
+
* to stay within the BN254 scalar field modulus.
|
|
31
|
+
*
|
|
32
|
+
* Underscore prefix marks this as an INTERNAL primitive shared with
|
|
33
|
+
* `hierarchical_leaf.ts`. Not exported from `index.ts` — not part of
|
|
34
|
+
* the public API surface. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
35
|
+
*/
|
|
36
|
+
export declare function _bytesToFieldElements(input: Uint8Array): bigint[];
|
|
37
|
+
/**
|
|
38
|
+
* Poseidon2 sponge over a sequence of field elements.
|
|
39
|
+
* Absorbs pairs (left, right) in order; right=0n at odd tail.
|
|
40
|
+
* state' = poseidon2Hash([state + left, right]).
|
|
41
|
+
*
|
|
42
|
+
* Internal primitive shared with `hierarchical_leaf.ts`. Not exported
|
|
43
|
+
* from `index.ts`. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
44
|
+
*/
|
|
45
|
+
export declare function _poseidon2Sponge(elements: bigint[]): bigint;
|
|
46
|
+
/**
|
|
47
|
+
* Parse a commitment hash string to extract the raw bigint value.
|
|
48
|
+
* Accepts both 'poseidon2:hex' and 'sha256:hex' formats.
|
|
49
|
+
*
|
|
50
|
+
* Internal primitive shared with `hierarchical_leaf.ts`. Not exported
|
|
51
|
+
* from `index.ts`. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
52
|
+
*/
|
|
53
|
+
export declare function _parseHashToField(hash: string): bigint;
|
|
18
54
|
/**
|
|
19
55
|
* Compute a commitment hash over input bytes.
|
|
20
56
|
*
|
|
21
57
|
* @param input - Raw content bytes (NEVER transmitted — only the hash leaves the environment)
|
|
22
|
-
* @param algorithm - '
|
|
23
|
-
* PRIMUST_COMMITMENT_ALGORITHM env var or defaults to '
|
|
58
|
+
* @param algorithm - 'poseidon2' (default) or 'sha256'. If not specified, uses
|
|
59
|
+
* PRIMUST_COMMITMENT_ALGORITHM env var or defaults to 'poseidon2'.
|
|
24
60
|
*/
|
|
25
61
|
export declare function commit(input: Uint8Array, algorithm?: CommitmentAlgorithm): CommitmentResult;
|
|
26
62
|
/**
|
|
@@ -36,17 +72,29 @@ export declare function commitOutput(output: Uint8Array): CommitmentResult;
|
|
|
36
72
|
*/
|
|
37
73
|
export declare function buildCommitmentRoot(hashes: string[], algorithm?: CommitmentAlgorithm): string | null;
|
|
38
74
|
/** Stage types that map to proof levels. */
|
|
39
|
-
type StageType = 'deterministic_rule' | 'ml_model' | 'zkml_model' | 'statistical_test' | 'custom_code' | 'witnessed'
|
|
75
|
+
type StageType = 'deterministic_rule' | 'policy_engine' | 'decision_path_model' | 'boundary_rule' | 'jurisdiction_boundary' | 'upstream_vpec_verify' | 'bound_committed_inference' | 'open_source_ml' | 'graph_node' | 'custom_check' | 'process_only' | 'human_approval' | 'acknowledged' | 'llm_api' | 'hardware_attested' | 'ml_model' | 'zkml_model' | 'statistical_test' | 'custom_code' | 'witnessed';
|
|
40
76
|
/**
|
|
41
77
|
* Select the proof level for a given stage type.
|
|
42
78
|
*
|
|
43
79
|
* Mapping:
|
|
44
80
|
* deterministic_rule → mathematical
|
|
81
|
+
* policy_engine → mathematical
|
|
82
|
+
* decision_path_model → mathematical
|
|
83
|
+
* boundary_rule → mathematical
|
|
84
|
+
* jurisdiction_boundary → mathematical
|
|
85
|
+
* upstream_vpec_verify → mathematical
|
|
45
86
|
* zkml_model → verifiable_inference
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
87
|
+
* bound_committed_inference → operator_bound
|
|
88
|
+
* open_source_ml → execution
|
|
89
|
+
* graph_node → execution
|
|
90
|
+
* custom_check → execution
|
|
91
|
+
* hardware_attested → execution
|
|
92
|
+
* process_only → attestation
|
|
93
|
+
* human_approval → witnessed
|
|
94
|
+
* acknowledged → witnessed
|
|
95
|
+
*
|
|
96
|
+
* Deprecated aliases retained for compatibility:
|
|
97
|
+
* ml_model, statistical_test, custom_code, witnessed
|
|
50
98
|
*
|
|
51
99
|
* Note: attestation is the weakest level and only applies from explicit manifest
|
|
52
100
|
* declaration, not from stage type mapping.
|
package/dist/commitment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitment.d.ts","sourceRoot":"","sources":["../src/commitment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI3E,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAG,KAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"commitment.d.ts","sourceRoot":"","sources":["../src/commitment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI3E,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAG,KAAc,CAAC;AAE7C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iFAAiF,CAAC;AAI5G,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAID;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,CAgBjE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ3D;AA8BD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKtD;AAID;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,mBAAmB,GAC9B,gBAAgB,CAMlB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAMjE;AA4BD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CASpG;AAuCD,4CAA4C;AAC5C,KAAK,SAAS,GACV,oBAAoB,GACpB,eAAe,GACf,qBAAqB,GACrB,eAAe,GACf,uBAAuB,GACvB,sBAAsB,GACtB,2BAA2B,GAC3B,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,mBAAmB,GAEnB,UAAU,GACV,YAAY,GACZ,kBAAkB,GAClB,aAAa,GACb,WAAW,CAAC;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,CA6BjE"}
|
package/dist/commitment.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Primust Artifact Core — Commitment Layer (P6-A)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Poseidon2 (default, ZK-friendly) and SHA-256 (opt-in via PRIMUST_COMMITMENT_ALGORITHM=sha256) commitments.
|
|
5
5
|
* Poseidon2 uses a pure implementation — opt-in only until an audited reference
|
|
6
6
|
* (e.g. Barretenberg) is validated.
|
|
7
7
|
*
|
|
@@ -16,15 +16,23 @@ export const ZK_IS_BLOCKING = false;
|
|
|
16
16
|
/**
|
|
17
17
|
* BN254 scalar field modulus.
|
|
18
18
|
* All Poseidon2 field arithmetic operates modulo this prime.
|
|
19
|
+
*
|
|
20
|
+
* Exported so downstream packages (e.g. runtime-core blinding generation)
|
|
21
|
+
* can reduce 32-byte randomness into a valid BN254 field element without
|
|
22
|
+
* duplicating the constant.
|
|
19
23
|
*/
|
|
20
|
-
const BN254_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
24
|
+
export const BN254_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
21
25
|
// ── Helpers ──
|
|
22
26
|
/**
|
|
23
27
|
* Convert bytes to BN254 field elements.
|
|
24
28
|
* Each chunk of 31 bytes is interpreted as a big-endian unsigned integer
|
|
25
29
|
* to stay within the BN254 scalar field modulus.
|
|
30
|
+
*
|
|
31
|
+
* Underscore prefix marks this as an INTERNAL primitive shared with
|
|
32
|
+
* `hierarchical_leaf.ts`. Not exported from `index.ts` — not part of
|
|
33
|
+
* the public API surface. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
26
34
|
*/
|
|
27
|
-
function
|
|
35
|
+
export function _bytesToFieldElements(input) {
|
|
28
36
|
if (input.length === 0)
|
|
29
37
|
return [0n];
|
|
30
38
|
const elements = [];
|
|
@@ -40,19 +48,29 @@ function bytesToFieldElements(input) {
|
|
|
40
48
|
return elements;
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
43
|
-
* Poseidon2
|
|
44
|
-
*
|
|
45
|
-
*
|
|
51
|
+
* Poseidon2 sponge over a sequence of field elements.
|
|
52
|
+
* Absorbs pairs (left, right) in order; right=0n at odd tail.
|
|
53
|
+
* state' = poseidon2Hash([state + left, right]).
|
|
54
|
+
*
|
|
55
|
+
* Internal primitive shared with `hierarchical_leaf.ts`. Not exported
|
|
56
|
+
* from `index.ts`. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
46
57
|
*/
|
|
47
|
-
function
|
|
48
|
-
const elements = bytesToFieldElements(input);
|
|
49
|
-
// Sponge: absorb pairs of field elements
|
|
58
|
+
export function _poseidon2Sponge(elements) {
|
|
50
59
|
let state = 0n;
|
|
51
60
|
for (let i = 0; i < elements.length; i += 2) {
|
|
52
61
|
const left = elements[i];
|
|
53
62
|
const right = i + 1 < elements.length ? elements[i + 1] : 0n;
|
|
54
63
|
state = poseidon2Hash([state + left, right]);
|
|
55
64
|
}
|
|
65
|
+
return state;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Poseidon2 hash over arbitrary bytes.
|
|
69
|
+
* Converts to field elements, then applies Poseidon2 sponge-style:
|
|
70
|
+
* absorb pairs of elements, squeeze final hash.
|
|
71
|
+
*/
|
|
72
|
+
function poseidon2(input) {
|
|
73
|
+
const state = _poseidon2Sponge(_bytesToFieldElements(input));
|
|
56
74
|
return 'poseidon2:' + state.toString(16).padStart(64, '0');
|
|
57
75
|
}
|
|
58
76
|
/**
|
|
@@ -74,8 +92,11 @@ function poseidon2Pair(left, right) {
|
|
|
74
92
|
/**
|
|
75
93
|
* Parse a commitment hash string to extract the raw bigint value.
|
|
76
94
|
* Accepts both 'poseidon2:hex' and 'sha256:hex' formats.
|
|
95
|
+
*
|
|
96
|
+
* Internal primitive shared with `hierarchical_leaf.ts`. Not exported
|
|
97
|
+
* from `index.ts`. See L13_STEP3_HIERARCHICAL_ZK_LEAF_DESIGN.md §3.6.
|
|
77
98
|
*/
|
|
78
|
-
function
|
|
99
|
+
export function _parseHashToField(hash) {
|
|
79
100
|
const colonIdx = hash.indexOf(':');
|
|
80
101
|
if (colonIdx === -1)
|
|
81
102
|
throw new Error(`Invalid hash format: ${hash}`);
|
|
@@ -87,8 +108,8 @@ function parseHashToField(hash) {
|
|
|
87
108
|
* Compute a commitment hash over input bytes.
|
|
88
109
|
*
|
|
89
110
|
* @param input - Raw content bytes (NEVER transmitted — only the hash leaves the environment)
|
|
90
|
-
* @param algorithm - '
|
|
91
|
-
* PRIMUST_COMMITMENT_ALGORITHM env var or defaults to '
|
|
111
|
+
* @param algorithm - 'poseidon2' (default) or 'sha256'. If not specified, uses
|
|
112
|
+
* PRIMUST_COMMITMENT_ALGORITHM env var or defaults to 'poseidon2'.
|
|
92
113
|
*/
|
|
93
114
|
export function commit(input, algorithm) {
|
|
94
115
|
const alg = algorithm ?? resolveAlgorithm();
|
|
@@ -109,14 +130,14 @@ export function commitOutput(output) {
|
|
|
109
130
|
}
|
|
110
131
|
/**
|
|
111
132
|
* Resolve the commitment algorithm.
|
|
112
|
-
* Default is "
|
|
113
|
-
*
|
|
133
|
+
* Default is "poseidon2" (ZK-friendly, matches Noir circuit).
|
|
134
|
+
* Override with PRIMUST_COMMITMENT_ALGORITHM=sha256 if needed.
|
|
114
135
|
*/
|
|
115
136
|
function resolveAlgorithm() {
|
|
116
|
-
if (typeof process !== 'undefined' && process.env?.PRIMUST_COMMITMENT_ALGORITHM === '
|
|
117
|
-
return '
|
|
137
|
+
if (typeof process !== 'undefined' && process.env?.PRIMUST_COMMITMENT_ALGORITHM === 'sha256') {
|
|
138
|
+
return 'sha256';
|
|
118
139
|
}
|
|
119
|
-
return '
|
|
140
|
+
return 'poseidon2';
|
|
120
141
|
}
|
|
121
142
|
/**
|
|
122
143
|
* Parse a commitment hash string to raw bytes.
|
|
@@ -151,7 +172,7 @@ export function buildCommitmentRoot(hashes, algorithm) {
|
|
|
151
172
|
return buildSha256MerkleRoot(hashes);
|
|
152
173
|
}
|
|
153
174
|
function buildPoseidon2MerkleRoot(hashes) {
|
|
154
|
-
let layer = hashes.map(
|
|
175
|
+
let layer = hashes.map(_parseHashToField);
|
|
155
176
|
while (layer.length > 1) {
|
|
156
177
|
const next = [];
|
|
157
178
|
for (let i = 0; i < layer.length; i += 2) {
|
|
@@ -184,11 +205,23 @@ function buildSha256MerkleRoot(hashes) {
|
|
|
184
205
|
*
|
|
185
206
|
* Mapping:
|
|
186
207
|
* deterministic_rule → mathematical
|
|
208
|
+
* policy_engine → mathematical
|
|
209
|
+
* decision_path_model → mathematical
|
|
210
|
+
* boundary_rule → mathematical
|
|
211
|
+
* jurisdiction_boundary → mathematical
|
|
212
|
+
* upstream_vpec_verify → mathematical
|
|
187
213
|
* zkml_model → verifiable_inference
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
214
|
+
* bound_committed_inference → operator_bound
|
|
215
|
+
* open_source_ml → execution
|
|
216
|
+
* graph_node → execution
|
|
217
|
+
* custom_check → execution
|
|
218
|
+
* hardware_attested → execution
|
|
219
|
+
* process_only → attestation
|
|
220
|
+
* human_approval → witnessed
|
|
221
|
+
* acknowledged → witnessed
|
|
222
|
+
*
|
|
223
|
+
* Deprecated aliases retained for compatibility:
|
|
224
|
+
* ml_model, statistical_test, custom_code, witnessed
|
|
192
225
|
*
|
|
193
226
|
* Note: attestation is the weakest level and only applies from explicit manifest
|
|
194
227
|
* declaration, not from stage type mapping.
|
|
@@ -196,19 +229,31 @@ function buildSha256MerkleRoot(hashes) {
|
|
|
196
229
|
export function selectProofLevel(stageType) {
|
|
197
230
|
switch (stageType) {
|
|
198
231
|
case 'deterministic_rule':
|
|
232
|
+
case 'policy_engine':
|
|
233
|
+
case 'decision_path_model':
|
|
234
|
+
case 'boundary_rule':
|
|
235
|
+
case 'jurisdiction_boundary':
|
|
236
|
+
case 'upstream_vpec_verify':
|
|
199
237
|
return 'mathematical';
|
|
200
238
|
case 'zkml_model':
|
|
201
239
|
return 'verifiable_inference';
|
|
240
|
+
case 'bound_committed_inference':
|
|
241
|
+
return 'operator_bound';
|
|
242
|
+
case 'open_source_ml':
|
|
243
|
+
case 'graph_node':
|
|
244
|
+
case 'custom_check':
|
|
245
|
+
case 'hardware_attested':
|
|
202
246
|
case 'ml_model':
|
|
203
|
-
return 'execution';
|
|
204
247
|
case 'statistical_test':
|
|
205
|
-
return 'execution';
|
|
206
248
|
case 'custom_code':
|
|
207
249
|
return 'execution';
|
|
250
|
+
case 'process_only':
|
|
251
|
+
case 'llm_api':
|
|
252
|
+
return 'attestation';
|
|
253
|
+
case 'human_approval':
|
|
254
|
+
case 'acknowledged':
|
|
208
255
|
case 'witnessed':
|
|
209
256
|
return 'witnessed';
|
|
210
|
-
case 'policy_engine':
|
|
211
|
-
return 'mathematical';
|
|
212
257
|
}
|
|
213
258
|
}
|
|
214
259
|
//# sourceMappingURL=commitment.js.map
|
package/dist/commitment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitment.js","sourceRoot":"","sources":["../src/commitment.ts"],"names":[],"mappings":"AA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B,KAAK,gBAAgB,CAAC;QACtB,KAAK,YAAY,CAAC;QAClB,KAAK,cAAc,CAAC;QACpB,KAAK,mBAAmB,CAAC;QACzB,KAAK,UAAU,CAAC;QAChB,KAAK,kBAAkB,CAAC;QACxB,KAAK,aAAa;YAChB,OAAO,WAAW,CAAC;QACrB,KAAK,cAAc,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QACvB,KAAK,gBAAgB,CAAC;QACtB,KAAK,cAAc,CAAC;QACpB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/commitment.test.js
CHANGED
|
@@ -64,11 +64,11 @@ describe('commitment', () => {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
it('MUST PASS: commitOutput uses default algorithm (
|
|
67
|
+
it('MUST PASS: commitOutput uses default algorithm (poseidon2)', () => {
|
|
68
68
|
const output = new TextEncoder().encode('some output content');
|
|
69
69
|
const result = commitOutput(output);
|
|
70
|
-
expect(result.algorithm).toBe('
|
|
71
|
-
expect(result.hash).toMatch(/^
|
|
70
|
+
expect(result.algorithm).toBe('poseidon2');
|
|
71
|
+
expect(result.hash).toMatch(/^poseidon2:/);
|
|
72
72
|
});
|
|
73
73
|
it('MUST PASS: buildCommitmentRoot(empty array) returns null', () => {
|
|
74
74
|
expect(buildCommitmentRoot([])).toBeNull();
|
|
@@ -95,17 +95,27 @@ describe('commitment', () => {
|
|
|
95
95
|
it('MUST PASS: all 5 proof levels present in proof level selection logic', () => {
|
|
96
96
|
const stageTypes = [
|
|
97
97
|
'deterministic_rule',
|
|
98
|
+
'policy_engine',
|
|
99
|
+
'decision_path_model',
|
|
98
100
|
'ml_model',
|
|
99
101
|
'zkml_model',
|
|
102
|
+
'bound_committed_inference',
|
|
100
103
|
'statistical_test',
|
|
101
104
|
'custom_code',
|
|
105
|
+
'custom_check',
|
|
106
|
+
'hardware_attested',
|
|
107
|
+
'process_only',
|
|
108
|
+
'human_approval',
|
|
109
|
+
'acknowledged',
|
|
102
110
|
'witnessed',
|
|
103
111
|
];
|
|
104
112
|
const proofLevels = new Set(stageTypes.map(selectProofLevel));
|
|
105
113
|
expect(proofLevels).toContain('mathematical');
|
|
106
114
|
expect(proofLevels).toContain('verifiable_inference');
|
|
115
|
+
expect(proofLevels).toContain('operator_bound');
|
|
107
116
|
expect(proofLevels).toContain('execution');
|
|
108
117
|
expect(proofLevels).toContain('witnessed');
|
|
118
|
+
expect(proofLevels).toContain('attestation');
|
|
109
119
|
});
|
|
110
120
|
it('MUST PASS: verifiable_inference proof level triggers only for zkml_model stage type', () => {
|
|
111
121
|
expect(selectProofLevel('zkml_model')).toBe('verifiable_inference');
|
|
@@ -113,6 +123,7 @@ describe('commitment', () => {
|
|
|
113
123
|
const others = [
|
|
114
124
|
'deterministic_rule',
|
|
115
125
|
'ml_model',
|
|
126
|
+
'bound_committed_inference',
|
|
116
127
|
'statistical_test',
|
|
117
128
|
'custom_code',
|
|
118
129
|
'witnessed',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitment.test.js","sourceRoot":"","sources":["../src/commitment.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,gBAAgB;AAEhB,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,C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