@maatara/core-pqc-wasm 0.4.5 → 0.5.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 ADDED
@@ -0,0 +1,201 @@
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. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2025] [Ma'atara Contributors]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,103 +1,124 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function preimage_governance(policy_json: string): string;
4
- export function aes_gcm_unwrap(key_b64u: string, iv_b64u: string, ct_b64u: string, aad_b64u: string): string;
5
- export function jcs_canonicalize(json: string): string;
6
- export function preimage_anchor(user_id: string, root_hex: string, epoch: string, chains_json: string): string;
7
- export function hkdf_sha256(secret_b64u: string, info_b64u: string, salt_b64u: string | null | undefined, len: number): string;
3
+ /**
4
+ * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256)
5
+ * Returns hex-encoded calldata ready for transaction
6
+ */
7
+ export function generate_evm_anchor_calldata(root_hex: string, epoch: bigint): string;
8
+ export function verify_attestations(msg_b64u: string, attestations_json: string, allowed_public_keys_json?: string | null): string;
9
+ /**
10
+ * SHA3-384 hash of raw bytes, returns 96-char hex string
11
+ */
12
+ export function sha3_384_hash(data: Uint8Array): string;
8
13
  /**
9
14
  * ML-DSA-65 key generation (FIPS 204 compliant)
10
15
  * Security: Keys are generated using platform CSPRNG
11
16
  */
12
17
  export function dilithium_keygen(): string;
13
18
  /**
14
- * ML-DSA-65 signing (FIPS 204 compliant)
15
- * Security: Input validation prevents DoS; constant-time operations
19
+ * SHA3-384 hash truncated to 32 bytes (64-char hex)
20
+ * For EVM compatibility (bytes32) while maintaining PQC compliance
16
21
  */
17
- export function dilithium_sign(message_b64u: string, secret_b64u: string): string;
22
+ export function sha3_384_hash_truncated_32(data: Uint8Array): string;
18
23
  /**
19
- * Get SSSP algorithm configuration for graph verification
20
- * nodes: expected number of nodes in the graph
24
+ * Create a Merkle accumulator leaf with an explicit hash algorithm
25
+ * hash_alg: "sha256" or "sha3-384"
21
26
  */
22
- export function sssp_config(nodes: number): string;
23
- export function aes_gcm_wrap(key_b64u: string, dek_b64u: string, aad_b64u: string): string;
24
- export function preimage_asset_transfer(header_json: string): string;
25
- export function validate_royalty(receiver: string, bps: number): string;
27
+ export function create_accumulator_leaf_with_alg(user_id: string, chain_id: string, block_hash: string, block_index: bigint, hash_alg: string): string;
26
28
  /**
27
- * Compute shortest path verification info for provenance chains
28
- * This returns the algorithm parameters for JS-side graph operations
29
+ * ML-DSA-65 verification (FIPS 204 compliant)
30
+ * Security: Input validation prevents DoS; constant-time comparison
29
31
  */
30
- export function provenance_path_config(chain_length: number, branches: number): string;
32
+ export function dilithium_verify(message_b64u: string, signature_b64u: string, public_b64u: string): string;
33
+ export function aes_gcm_unwrap(key_b64u: string, iv_b64u: string, ct_b64u: string, aad_b64u: string): string;
34
+ export function preimage_asset_transfer(header_json: string): string;
31
35
  /**
32
36
  * Truncate a SHA3-384 hash (48 bytes) to bytes32 (32 bytes) for EVM
33
37
  * Uses first 32 bytes, preserving collision resistance
34
38
  */
35
39
  export function truncate_to_bytes32(hash_hex: string): string;
36
- export function kyber_decaps(secret_b64u: string, kem_ct_b64u: string): string;
40
+ export function preimage_asset_mint(header_json: string, asset_json: string): string;
37
41
  /**
38
42
  * Decode a Bitcoin OP_RETURN payload
39
43
  */
40
44
  export function decode_bitcoin_anchor_payload(payload_hex: string): string;
41
45
  /**
42
- * Get supported anchor chains and their configurations
46
+ * SHA3-384 hash of raw bytes, returns 64-char base64url string
43
47
  */
44
- export function anchor_chains_info(): string;
48
+ export function sha3_384_hash_b64u(data: Uint8Array): string;
49
+ export function kyber_decaps(secret_b64u: string, kem_ct_b64u: string): string;
50
+ export function jcs_canonicalize(json: string): string;
45
51
  /**
46
- * Create a Merkle accumulator leaf with an explicit hash algorithm
47
- * hash_alg: "sha256" or "sha3-384"
52
+ * Get supported anchor chains and their configurations
48
53
  */
49
- export function create_accumulator_leaf_with_alg(user_id: string, chain_id: string, block_hash: string, block_index: bigint, hash_alg: string): string;
54
+ export function anchor_chains_info(): string;
55
+ export function hkdf_sha256(secret_b64u: string, info_b64u: string, salt_b64u: string | null | undefined, len: number): string;
50
56
  /**
51
- * Get anchor configuration and gas estimates
57
+ * Check if a nonce has been seen (for replay prevention)
58
+ * Returns info about the nonce cache algorithm
52
59
  */
53
- export function anchor_config_info(): string;
60
+ export function nonce_cache_info(): string;
61
+ export function preimage_anchor(user_id: string, root_hex: string, epoch: string, chains_json: string): string;
62
+ export function kyber_encaps(public_b64u: string): string;
63
+ export function kyber_keygen(): string;
54
64
  /**
55
- * Generate Bitcoin OP_RETURN payload for anchoring
56
- * Returns hex-encoded payload (45 bytes)
65
+ * SHA3-384 hash of a UTF-8 string, returns 64-char base64url string
57
66
  */
58
- export function generate_bitcoin_anchor_payload(root_hex: string, epoch: bigint): string;
67
+ export function sha3_384_hash_string_b64u(data: string): string;
68
+ export function start(): void;
59
69
  /**
60
70
  * Compute Merkle root from an array of leaf hashes
61
71
  * Input: JSON array of hex hash strings
62
72
  * Returns: { root: string, leaf_count: number }
63
73
  */
64
74
  export function compute_merkle_root(leaves_json: string, hash_alg: string): string;
65
- export function preimage_asset_mint(header_json: string, asset_json: string): string;
66
75
  /**
67
- * Create a nonce cache for replay attack prevention
68
- * capacity: maximum number of nonces to track
69
- * ttl_ms: time-to-live in milliseconds before nonces expire
76
+ * Get elastic hash table configuration for key caching
70
77
  */
71
- export function create_nonce_cache(capacity: number, ttl_ms: bigint): string;
78
+ export function elastic_hash_config(capacity: number, load_factor: number): string;
79
+ /**
80
+ * Generate Bitcoin OP_RETURN payload for anchoring
81
+ * Returns hex-encoded payload (45 bytes)
82
+ */
83
+ export function generate_bitcoin_anchor_payload(root_hex: string, epoch: bigint): string;
72
84
  /**
73
85
  * Create a Merkle accumulator leaf for a chain state
74
86
  * Returns JSON with the leaf hash and canonical data
75
87
  * Default hash algorithm is SHA3-384 (PQC)
76
88
  */
77
89
  export function create_accumulator_leaf(user_id: string, chain_id: string, block_hash: string, block_index: bigint): string;
78
- export function start(): void;
90
+ export function aes_gcm_wrap(key_b64u: string, dek_b64u: string, aad_b64u: string): string;
79
91
  /**
80
- * Check if a nonce has been seen (for replay prevention)
81
- * Returns info about the nonce cache algorithm
92
+ * Get SSSP algorithm configuration for graph verification
93
+ * nodes: expected number of nodes in the graph
82
94
  */
83
- export function nonce_cache_info(): string;
95
+ export function sssp_config(nodes: number): string;
84
96
  /**
85
- * ML-DSA-65 verification (FIPS 204 compliant)
86
- * Security: Input validation prevents DoS; constant-time comparison
97
+ * Compute shortest path verification info for provenance chains
98
+ * This returns the algorithm parameters for JS-side graph operations
87
99
  */
88
- export function dilithium_verify(message_b64u: string, signature_b64u: string, public_b64u: string): string;
100
+ export function provenance_path_config(chain_length: number, branches: number): string;
101
+ export function validate_royalty(receiver: string, bps: number): string;
89
102
  /**
90
- * Get elastic hash table configuration for key caching
103
+ * Create a nonce cache for replay attack prevention
104
+ * capacity: maximum number of nonces to track
105
+ * ttl_ms: time-to-live in milliseconds before nonces expire
91
106
  */
92
- export function elastic_hash_config(capacity: number, load_factor: number): string;
93
- export function kyber_keygen(): string;
94
- export function verify_attestations(msg_b64u: string, attestations_json: string, allowed_public_keys_json?: string | null): string;
107
+ export function create_nonce_cache(capacity: number, ttl_ms: bigint): string;
95
108
  /**
96
- * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256)
97
- * Returns hex-encoded calldata ready for transaction
109
+ * Get anchor configuration and gas estimates
98
110
  */
99
- export function generate_evm_anchor_calldata(root_hex: string, epoch: bigint): string;
100
- export function kyber_encaps(public_b64u: string): string;
111
+ export function anchor_config_info(): string;
112
+ export function preimage_governance(policy_json: string): string;
113
+ /**
114
+ * ML-DSA-65 signing (FIPS 204 compliant)
115
+ * Security: Input validation prevents DoS; constant-time operations
116
+ */
117
+ export function dilithium_sign(message_b64u: string, secret_b64u: string): string;
118
+ /**
119
+ * SHA3-384 hash of a UTF-8 string, returns 96-char hex string
120
+ */
121
+ export function sha3_384_hash_string(data: string): string;
101
122
 
102
123
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
103
124
 
@@ -128,6 +149,11 @@ export interface InitOutput {
128
149
  readonly preimage_asset_mint: (a: number, b: number, c: number, d: number) => [number, number];
129
150
  readonly preimage_asset_transfer: (a: number, b: number) => [number, number];
130
151
  readonly provenance_path_config: (a: number, b: number) => [number, number];
152
+ readonly sha3_384_hash: (a: number, b: number) => [number, number];
153
+ readonly sha3_384_hash_b64u: (a: number, b: number) => [number, number];
154
+ readonly sha3_384_hash_string: (a: number, b: number) => [number, number];
155
+ readonly sha3_384_hash_string_b64u: (a: number, b: number) => [number, number];
156
+ readonly sha3_384_hash_truncated_32: (a: number, b: number) => [number, number];
131
157
  readonly sssp_config: (a: number) => [number, number];
132
158
  readonly start: () => void;
133
159
  readonly truncate_to_bytes32: (a: number, b: number) => [number, number];
package/core_pqc_wasm.js CHANGED
@@ -105,16 +105,19 @@ function passStringToWasm0(arg, malloc, realloc) {
105
105
  return ptr;
106
106
  }
107
107
  /**
108
- * @param {string} policy_json
108
+ * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256)
109
+ * Returns hex-encoded calldata ready for transaction
110
+ * @param {string} root_hex
111
+ * @param {bigint} epoch
109
112
  * @returns {string}
110
113
  */
111
- export function preimage_governance(policy_json) {
114
+ export function generate_evm_anchor_calldata(root_hex, epoch) {
112
115
  let deferred2_0;
113
116
  let deferred2_1;
114
117
  try {
115
- const ptr0 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
118
+ const ptr0 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
116
119
  const len0 = WASM_VECTOR_LEN;
117
- const ret = wasm.preimage_governance(ptr0, len0);
120
+ const ret = wasm.generate_evm_anchor_calldata(ptr0, len0, epoch);
118
121
  deferred2_0 = ret[0];
119
122
  deferred2_1 = ret[1];
120
123
  return getStringFromWasm0(ret[0], ret[1]);
@@ -124,44 +127,48 @@ export function preimage_governance(policy_json) {
124
127
  }
125
128
 
126
129
  /**
127
- * @param {string} key_b64u
128
- * @param {string} iv_b64u
129
- * @param {string} ct_b64u
130
- * @param {string} aad_b64u
130
+ * @param {string} msg_b64u
131
+ * @param {string} attestations_json
132
+ * @param {string | null} [allowed_public_keys_json]
131
133
  * @returns {string}
132
134
  */
133
- export function aes_gcm_unwrap(key_b64u, iv_b64u, ct_b64u, aad_b64u) {
134
- let deferred5_0;
135
- let deferred5_1;
135
+ export function verify_attestations(msg_b64u, attestations_json, allowed_public_keys_json) {
136
+ let deferred4_0;
137
+ let deferred4_1;
136
138
  try {
137
- const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
+ const ptr0 = passStringToWasm0(msg_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
140
  const len0 = WASM_VECTOR_LEN;
139
- const ptr1 = passStringToWasm0(iv_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
141
+ const ptr1 = passStringToWasm0(attestations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
140
142
  const len1 = WASM_VECTOR_LEN;
141
- const ptr2 = passStringToWasm0(ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
142
- const len2 = WASM_VECTOR_LEN;
143
- const ptr3 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
144
- const len3 = WASM_VECTOR_LEN;
145
- const ret = wasm.aes_gcm_unwrap(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
146
- deferred5_0 = ret[0];
147
- deferred5_1 = ret[1];
143
+ var ptr2 = isLikeNone(allowed_public_keys_json) ? 0 : passStringToWasm0(allowed_public_keys_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
144
+ var len2 = WASM_VECTOR_LEN;
145
+ const ret = wasm.verify_attestations(ptr0, len0, ptr1, len1, ptr2, len2);
146
+ deferred4_0 = ret[0];
147
+ deferred4_1 = ret[1];
148
148
  return getStringFromWasm0(ret[0], ret[1]);
149
149
  } finally {
150
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
150
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
151
151
  }
152
152
  }
153
153
 
154
+ function passArray8ToWasm0(arg, malloc) {
155
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
156
+ getUint8ArrayMemory0().set(arg, ptr / 1);
157
+ WASM_VECTOR_LEN = arg.length;
158
+ return ptr;
159
+ }
154
160
  /**
155
- * @param {string} json
161
+ * SHA3-384 hash of raw bytes, returns 96-char hex string
162
+ * @param {Uint8Array} data
156
163
  * @returns {string}
157
164
  */
158
- export function jcs_canonicalize(json) {
165
+ export function sha3_384_hash(data) {
159
166
  let deferred2_0;
160
167
  let deferred2_1;
161
168
  try {
162
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
163
170
  const len0 = WASM_VECTOR_LEN;
164
- const ret = wasm.jcs_canonicalize(ptr0, len0);
171
+ const ret = wasm.sha3_384_hash(ptr0, len0);
165
172
  deferred2_0 = ret[0];
166
173
  deferred2_1 = ret[1];
167
174
  return getStringFromWasm0(ret[0], ret[1]);
@@ -171,142 +178,127 @@ export function jcs_canonicalize(json) {
171
178
  }
172
179
 
173
180
  /**
174
- * @param {string} user_id
175
- * @param {string} root_hex
176
- * @param {string} epoch
177
- * @param {string} chains_json
181
+ * ML-DSA-65 key generation (FIPS 204 compliant)
182
+ * Security: Keys are generated using platform CSPRNG
178
183
  * @returns {string}
179
184
  */
180
- export function preimage_anchor(user_id, root_hex, epoch, chains_json) {
181
- let deferred5_0;
182
- let deferred5_1;
185
+ export function dilithium_keygen() {
186
+ let deferred1_0;
187
+ let deferred1_1;
183
188
  try {
184
- const ptr0 = passStringToWasm0(user_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
- const len0 = WASM_VECTOR_LEN;
186
- const ptr1 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
187
- const len1 = WASM_VECTOR_LEN;
188
- const ptr2 = passStringToWasm0(epoch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
- const len2 = WASM_VECTOR_LEN;
190
- const ptr3 = passStringToWasm0(chains_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
- const len3 = WASM_VECTOR_LEN;
192
- const ret = wasm.preimage_anchor(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
193
- deferred5_0 = ret[0];
194
- deferred5_1 = ret[1];
189
+ const ret = wasm.dilithium_keygen();
190
+ deferred1_0 = ret[0];
191
+ deferred1_1 = ret[1];
195
192
  return getStringFromWasm0(ret[0], ret[1]);
196
193
  } finally {
197
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
194
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
198
195
  }
199
196
  }
200
197
 
201
198
  /**
202
- * @param {string} secret_b64u
203
- * @param {string} info_b64u
204
- * @param {string | null | undefined} salt_b64u
205
- * @param {number} len
199
+ * SHA3-384 hash truncated to 32 bytes (64-char hex)
200
+ * For EVM compatibility (bytes32) while maintaining PQC compliance
201
+ * @param {Uint8Array} data
206
202
  * @returns {string}
207
203
  */
208
- export function hkdf_sha256(secret_b64u, info_b64u, salt_b64u, len) {
209
- let deferred4_0;
210
- let deferred4_1;
204
+ export function sha3_384_hash_truncated_32(data) {
205
+ let deferred2_0;
206
+ let deferred2_1;
211
207
  try {
212
- const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
213
209
  const len0 = WASM_VECTOR_LEN;
214
- const ptr1 = passStringToWasm0(info_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
- const len1 = WASM_VECTOR_LEN;
216
- var ptr2 = isLikeNone(salt_b64u) ? 0 : passStringToWasm0(salt_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
217
- var len2 = WASM_VECTOR_LEN;
218
- const ret = wasm.hkdf_sha256(ptr0, len0, ptr1, len1, ptr2, len2, len);
219
- deferred4_0 = ret[0];
220
- deferred4_1 = ret[1];
210
+ const ret = wasm.sha3_384_hash_truncated_32(ptr0, len0);
211
+ deferred2_0 = ret[0];
212
+ deferred2_1 = ret[1];
221
213
  return getStringFromWasm0(ret[0], ret[1]);
222
214
  } finally {
223
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
215
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
224
216
  }
225
217
  }
226
218
 
227
219
  /**
228
- * ML-DSA-65 key generation (FIPS 204 compliant)
229
- * Security: Keys are generated using platform CSPRNG
220
+ * Create a Merkle accumulator leaf with an explicit hash algorithm
221
+ * hash_alg: "sha256" or "sha3-384"
222
+ * @param {string} user_id
223
+ * @param {string} chain_id
224
+ * @param {string} block_hash
225
+ * @param {bigint} block_index
226
+ * @param {string} hash_alg
230
227
  * @returns {string}
231
228
  */
232
- export function dilithium_keygen() {
233
- let deferred1_0;
234
- let deferred1_1;
229
+ export function create_accumulator_leaf_with_alg(user_id, chain_id, block_hash, block_index, hash_alg) {
230
+ let deferred5_0;
231
+ let deferred5_1;
235
232
  try {
236
- const ret = wasm.dilithium_keygen();
237
- deferred1_0 = ret[0];
238
- deferred1_1 = ret[1];
233
+ const ptr0 = passStringToWasm0(user_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
234
+ const len0 = WASM_VECTOR_LEN;
235
+ const ptr1 = passStringToWasm0(chain_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
236
+ const len1 = WASM_VECTOR_LEN;
237
+ const ptr2 = passStringToWasm0(block_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
238
+ const len2 = WASM_VECTOR_LEN;
239
+ const ptr3 = passStringToWasm0(hash_alg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len3 = WASM_VECTOR_LEN;
241
+ const ret = wasm.create_accumulator_leaf_with_alg(ptr0, len0, ptr1, len1, ptr2, len2, block_index, ptr3, len3);
242
+ deferred5_0 = ret[0];
243
+ deferred5_1 = ret[1];
239
244
  return getStringFromWasm0(ret[0], ret[1]);
240
245
  } finally {
241
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
246
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
242
247
  }
243
248
  }
244
249
 
245
250
  /**
246
- * ML-DSA-65 signing (FIPS 204 compliant)
247
- * Security: Input validation prevents DoS; constant-time operations
251
+ * ML-DSA-65 verification (FIPS 204 compliant)
252
+ * Security: Input validation prevents DoS; constant-time comparison
248
253
  * @param {string} message_b64u
249
- * @param {string} secret_b64u
254
+ * @param {string} signature_b64u
255
+ * @param {string} public_b64u
250
256
  * @returns {string}
251
257
  */
252
- export function dilithium_sign(message_b64u, secret_b64u) {
253
- let deferred3_0;
254
- let deferred3_1;
258
+ export function dilithium_verify(message_b64u, signature_b64u, public_b64u) {
259
+ let deferred4_0;
260
+ let deferred4_1;
255
261
  try {
256
262
  const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
263
  const len0 = WASM_VECTOR_LEN;
258
- const ptr1 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
+ const ptr1 = passStringToWasm0(signature_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
259
265
  const len1 = WASM_VECTOR_LEN;
260
- const ret = wasm.dilithium_sign(ptr0, len0, ptr1, len1);
261
- deferred3_0 = ret[0];
262
- deferred3_1 = ret[1];
263
- return getStringFromWasm0(ret[0], ret[1]);
264
- } finally {
265
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
266
- }
267
- }
268
-
269
- /**
270
- * Get SSSP algorithm configuration for graph verification
271
- * nodes: expected number of nodes in the graph
272
- * @param {number} nodes
273
- * @returns {string}
274
- */
275
- export function sssp_config(nodes) {
276
- let deferred1_0;
277
- let deferred1_1;
278
- try {
279
- const ret = wasm.sssp_config(nodes);
280
- deferred1_0 = ret[0];
281
- deferred1_1 = ret[1];
266
+ const ptr2 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
267
+ const len2 = WASM_VECTOR_LEN;
268
+ const ret = wasm.dilithium_verify(ptr0, len0, ptr1, len1, ptr2, len2);
269
+ deferred4_0 = ret[0];
270
+ deferred4_1 = ret[1];
282
271
  return getStringFromWasm0(ret[0], ret[1]);
283
272
  } finally {
284
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
273
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
285
274
  }
286
275
  }
287
276
 
288
277
  /**
289
278
  * @param {string} key_b64u
290
- * @param {string} dek_b64u
279
+ * @param {string} iv_b64u
280
+ * @param {string} ct_b64u
291
281
  * @param {string} aad_b64u
292
282
  * @returns {string}
293
283
  */
294
- export function aes_gcm_wrap(key_b64u, dek_b64u, aad_b64u) {
295
- let deferred4_0;
296
- let deferred4_1;
284
+ export function aes_gcm_unwrap(key_b64u, iv_b64u, ct_b64u, aad_b64u) {
285
+ let deferred5_0;
286
+ let deferred5_1;
297
287
  try {
298
288
  const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
289
  const len0 = WASM_VECTOR_LEN;
300
- const ptr1 = passStringToWasm0(dek_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
290
+ const ptr1 = passStringToWasm0(iv_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
301
291
  const len1 = WASM_VECTOR_LEN;
302
- const ptr2 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const ptr2 = passStringToWasm0(ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
303
293
  const len2 = WASM_VECTOR_LEN;
304
- const ret = wasm.aes_gcm_wrap(ptr0, len0, ptr1, len1, ptr2, len2);
305
- deferred4_0 = ret[0];
306
- deferred4_1 = ret[1];
294
+ const ptr3 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
295
+ const len3 = WASM_VECTOR_LEN;
296
+ const ret = wasm.aes_gcm_unwrap(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
297
+ deferred5_0 = ret[0];
298
+ deferred5_1 = ret[1];
307
299
  return getStringFromWasm0(ret[0], ret[1]);
308
300
  } finally {
309
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
301
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
310
302
  }
311
303
  }
312
304
 
@@ -330,17 +322,18 @@ export function preimage_asset_transfer(header_json) {
330
322
  }
331
323
 
332
324
  /**
333
- * @param {string} receiver
334
- * @param {number} bps
325
+ * Truncate a SHA3-384 hash (48 bytes) to bytes32 (32 bytes) for EVM
326
+ * Uses first 32 bytes, preserving collision resistance
327
+ * @param {string} hash_hex
335
328
  * @returns {string}
336
329
  */
337
- export function validate_royalty(receiver, bps) {
330
+ export function truncate_to_bytes32(hash_hex) {
338
331
  let deferred2_0;
339
332
  let deferred2_1;
340
333
  try {
341
- const ptr0 = passStringToWasm0(receiver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const ptr0 = passStringToWasm0(hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
342
335
  const len0 = WASM_VECTOR_LEN;
343
- const ret = wasm.validate_royalty(ptr0, len0, bps);
336
+ const ret = wasm.truncate_to_bytes32(ptr0, len0);
344
337
  deferred2_0 = ret[0];
345
338
  deferred2_1 = ret[1];
346
339
  return getStringFromWasm0(ret[0], ret[1]);
@@ -350,38 +343,59 @@ export function validate_royalty(receiver, bps) {
350
343
  }
351
344
 
352
345
  /**
353
- * Compute shortest path verification info for provenance chains
354
- * This returns the algorithm parameters for JS-side graph operations
355
- * @param {number} chain_length
356
- * @param {number} branches
346
+ * @param {string} header_json
347
+ * @param {string} asset_json
357
348
  * @returns {string}
358
349
  */
359
- export function provenance_path_config(chain_length, branches) {
360
- let deferred1_0;
361
- let deferred1_1;
350
+ export function preimage_asset_mint(header_json, asset_json) {
351
+ let deferred3_0;
352
+ let deferred3_1;
362
353
  try {
363
- const ret = wasm.provenance_path_config(chain_length, branches);
364
- deferred1_0 = ret[0];
365
- deferred1_1 = ret[1];
354
+ const ptr0 = passStringToWasm0(header_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
+ const len0 = WASM_VECTOR_LEN;
356
+ const ptr1 = passStringToWasm0(asset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
357
+ const len1 = WASM_VECTOR_LEN;
358
+ const ret = wasm.preimage_asset_mint(ptr0, len0, ptr1, len1);
359
+ deferred3_0 = ret[0];
360
+ deferred3_1 = ret[1];
366
361
  return getStringFromWasm0(ret[0], ret[1]);
367
362
  } finally {
368
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
363
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
369
364
  }
370
365
  }
371
366
 
372
367
  /**
373
- * Truncate a SHA3-384 hash (48 bytes) to bytes32 (32 bytes) for EVM
374
- * Uses first 32 bytes, preserving collision resistance
375
- * @param {string} hash_hex
368
+ * Decode a Bitcoin OP_RETURN payload
369
+ * @param {string} payload_hex
376
370
  * @returns {string}
377
371
  */
378
- export function truncate_to_bytes32(hash_hex) {
372
+ export function decode_bitcoin_anchor_payload(payload_hex) {
379
373
  let deferred2_0;
380
374
  let deferred2_1;
381
375
  try {
382
- const ptr0 = passStringToWasm0(hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
+ const ptr0 = passStringToWasm0(payload_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
383
377
  const len0 = WASM_VECTOR_LEN;
384
- const ret = wasm.truncate_to_bytes32(ptr0, len0);
378
+ const ret = wasm.decode_bitcoin_anchor_payload(ptr0, len0);
379
+ deferred2_0 = ret[0];
380
+ deferred2_1 = ret[1];
381
+ return getStringFromWasm0(ret[0], ret[1]);
382
+ } finally {
383
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
384
+ }
385
+ }
386
+
387
+ /**
388
+ * SHA3-384 hash of raw bytes, returns 64-char base64url string
389
+ * @param {Uint8Array} data
390
+ * @returns {string}
391
+ */
392
+ export function sha3_384_hash_b64u(data) {
393
+ let deferred2_0;
394
+ let deferred2_1;
395
+ try {
396
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
397
+ const len0 = WASM_VECTOR_LEN;
398
+ const ret = wasm.sha3_384_hash_b64u(ptr0, len0);
385
399
  deferred2_0 = ret[0];
386
400
  deferred2_1 = ret[1];
387
401
  return getStringFromWasm0(ret[0], ret[1]);
@@ -413,17 +427,16 @@ export function kyber_decaps(secret_b64u, kem_ct_b64u) {
413
427
  }
414
428
 
415
429
  /**
416
- * Decode a Bitcoin OP_RETURN payload
417
- * @param {string} payload_hex
430
+ * @param {string} json
418
431
  * @returns {string}
419
432
  */
420
- export function decode_bitcoin_anchor_payload(payload_hex) {
433
+ export function jcs_canonicalize(json) {
421
434
  let deferred2_0;
422
435
  let deferred2_1;
423
436
  try {
424
- const ptr0 = passStringToWasm0(payload_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
437
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
425
438
  const len0 = WASM_VECTOR_LEN;
426
- const ret = wasm.decode_bitcoin_anchor_payload(ptr0, len0);
439
+ const ret = wasm.jcs_canonicalize(ptr0, len0);
427
440
  deferred2_0 = ret[0];
428
441
  deferred2_1 = ret[1];
429
442
  return getStringFromWasm0(ret[0], ret[1]);
@@ -436,11 +449,55 @@ export function decode_bitcoin_anchor_payload(payload_hex) {
436
449
  * Get supported anchor chains and their configurations
437
450
  * @returns {string}
438
451
  */
439
- export function anchor_chains_info() {
452
+ export function anchor_chains_info() {
453
+ let deferred1_0;
454
+ let deferred1_1;
455
+ try {
456
+ const ret = wasm.anchor_chains_info();
457
+ deferred1_0 = ret[0];
458
+ deferred1_1 = ret[1];
459
+ return getStringFromWasm0(ret[0], ret[1]);
460
+ } finally {
461
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
462
+ }
463
+ }
464
+
465
+ /**
466
+ * @param {string} secret_b64u
467
+ * @param {string} info_b64u
468
+ * @param {string | null | undefined} salt_b64u
469
+ * @param {number} len
470
+ * @returns {string}
471
+ */
472
+ export function hkdf_sha256(secret_b64u, info_b64u, salt_b64u, len) {
473
+ let deferred4_0;
474
+ let deferred4_1;
475
+ try {
476
+ const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
477
+ const len0 = WASM_VECTOR_LEN;
478
+ const ptr1 = passStringToWasm0(info_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
479
+ const len1 = WASM_VECTOR_LEN;
480
+ var ptr2 = isLikeNone(salt_b64u) ? 0 : passStringToWasm0(salt_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
481
+ var len2 = WASM_VECTOR_LEN;
482
+ const ret = wasm.hkdf_sha256(ptr0, len0, ptr1, len1, ptr2, len2, len);
483
+ deferred4_0 = ret[0];
484
+ deferred4_1 = ret[1];
485
+ return getStringFromWasm0(ret[0], ret[1]);
486
+ } finally {
487
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
488
+ }
489
+ }
490
+
491
+ /**
492
+ * Check if a nonce has been seen (for replay prevention)
493
+ * Returns info about the nonce cache algorithm
494
+ * @returns {string}
495
+ */
496
+ export function nonce_cache_info() {
440
497
  let deferred1_0;
441
498
  let deferred1_1;
442
499
  try {
443
- const ret = wasm.anchor_chains_info();
500
+ const ret = wasm.nonce_cache_info();
444
501
  deferred1_0 = ret[0];
445
502
  deferred1_1 = ret[1];
446
503
  return getStringFromWasm0(ret[0], ret[1]);
@@ -450,28 +507,25 @@ export function anchor_chains_info() {
450
507
  }
451
508
 
452
509
  /**
453
- * Create a Merkle accumulator leaf with an explicit hash algorithm
454
- * hash_alg: "sha256" or "sha3-384"
455
510
  * @param {string} user_id
456
- * @param {string} chain_id
457
- * @param {string} block_hash
458
- * @param {bigint} block_index
459
- * @param {string} hash_alg
511
+ * @param {string} root_hex
512
+ * @param {string} epoch
513
+ * @param {string} chains_json
460
514
  * @returns {string}
461
515
  */
462
- export function create_accumulator_leaf_with_alg(user_id, chain_id, block_hash, block_index, hash_alg) {
516
+ export function preimage_anchor(user_id, root_hex, epoch, chains_json) {
463
517
  let deferred5_0;
464
518
  let deferred5_1;
465
519
  try {
466
520
  const ptr0 = passStringToWasm0(user_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
467
521
  const len0 = WASM_VECTOR_LEN;
468
- const ptr1 = passStringToWasm0(chain_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
522
+ const ptr1 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
469
523
  const len1 = WASM_VECTOR_LEN;
470
- const ptr2 = passStringToWasm0(block_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
524
+ const ptr2 = passStringToWasm0(epoch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
471
525
  const len2 = WASM_VECTOR_LEN;
472
- const ptr3 = passStringToWasm0(hash_alg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
526
+ const ptr3 = passStringToWasm0(chains_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
473
527
  const len3 = WASM_VECTOR_LEN;
474
- const ret = wasm.create_accumulator_leaf_with_alg(ptr0, len0, ptr1, len1, ptr2, len2, block_index, ptr3, len3);
528
+ const ret = wasm.preimage_anchor(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
475
529
  deferred5_0 = ret[0];
476
530
  deferred5_1 = ret[1];
477
531
  return getStringFromWasm0(ret[0], ret[1]);
@@ -481,14 +535,32 @@ export function create_accumulator_leaf_with_alg(user_id, chain_id, block_hash,
481
535
  }
482
536
 
483
537
  /**
484
- * Get anchor configuration and gas estimates
538
+ * @param {string} public_b64u
485
539
  * @returns {string}
486
540
  */
487
- export function anchor_config_info() {
541
+ export function kyber_encaps(public_b64u) {
542
+ let deferred2_0;
543
+ let deferred2_1;
544
+ try {
545
+ const ptr0 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
546
+ const len0 = WASM_VECTOR_LEN;
547
+ const ret = wasm.kyber_encaps(ptr0, len0);
548
+ deferred2_0 = ret[0];
549
+ deferred2_1 = ret[1];
550
+ return getStringFromWasm0(ret[0], ret[1]);
551
+ } finally {
552
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
553
+ }
554
+ }
555
+
556
+ /**
557
+ * @returns {string}
558
+ */
559
+ export function kyber_keygen() {
488
560
  let deferred1_0;
489
561
  let deferred1_1;
490
562
  try {
491
- const ret = wasm.anchor_config_info();
563
+ const ret = wasm.kyber_keygen();
492
564
  deferred1_0 = ret[0];
493
565
  deferred1_1 = ret[1];
494
566
  return getStringFromWasm0(ret[0], ret[1]);
@@ -498,19 +570,17 @@ export function anchor_config_info() {
498
570
  }
499
571
 
500
572
  /**
501
- * Generate Bitcoin OP_RETURN payload for anchoring
502
- * Returns hex-encoded payload (45 bytes)
503
- * @param {string} root_hex
504
- * @param {bigint} epoch
573
+ * SHA3-384 hash of a UTF-8 string, returns 64-char base64url string
574
+ * @param {string} data
505
575
  * @returns {string}
506
576
  */
507
- export function generate_bitcoin_anchor_payload(root_hex, epoch) {
577
+ export function sha3_384_hash_string_b64u(data) {
508
578
  let deferred2_0;
509
579
  let deferred2_1;
510
580
  try {
511
- const ptr0 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
581
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
512
582
  const len0 = WASM_VECTOR_LEN;
513
- const ret = wasm.generate_bitcoin_anchor_payload(ptr0, len0, epoch);
583
+ const ret = wasm.sha3_384_hash_string_b64u(ptr0, len0);
514
584
  deferred2_0 = ret[0];
515
585
  deferred2_1 = ret[1];
516
586
  return getStringFromWasm0(ret[0], ret[1]);
@@ -519,6 +589,10 @@ export function generate_bitcoin_anchor_payload(root_hex, epoch) {
519
589
  }
520
590
  }
521
591
 
592
+ export function start() {
593
+ wasm.start();
594
+ }
595
+
522
596
  /**
523
597
  * Compute Merkle root from an array of leaf hashes
524
598
  * Input: JSON array of hex hash strings
@@ -545,45 +619,43 @@ export function compute_merkle_root(leaves_json, hash_alg) {
545
619
  }
546
620
 
547
621
  /**
548
- * @param {string} header_json
549
- * @param {string} asset_json
622
+ * Get elastic hash table configuration for key caching
623
+ * @param {number} capacity
624
+ * @param {number} load_factor
550
625
  * @returns {string}
551
626
  */
552
- export function preimage_asset_mint(header_json, asset_json) {
553
- let deferred3_0;
554
- let deferred3_1;
627
+ export function elastic_hash_config(capacity, load_factor) {
628
+ let deferred1_0;
629
+ let deferred1_1;
555
630
  try {
556
- const ptr0 = passStringToWasm0(header_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
557
- const len0 = WASM_VECTOR_LEN;
558
- const ptr1 = passStringToWasm0(asset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
559
- const len1 = WASM_VECTOR_LEN;
560
- const ret = wasm.preimage_asset_mint(ptr0, len0, ptr1, len1);
561
- deferred3_0 = ret[0];
562
- deferred3_1 = ret[1];
631
+ const ret = wasm.elastic_hash_config(capacity, load_factor);
632
+ deferred1_0 = ret[0];
633
+ deferred1_1 = ret[1];
563
634
  return getStringFromWasm0(ret[0], ret[1]);
564
635
  } finally {
565
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
636
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
566
637
  }
567
638
  }
568
639
 
569
640
  /**
570
- * Create a nonce cache for replay attack prevention
571
- * capacity: maximum number of nonces to track
572
- * ttl_ms: time-to-live in milliseconds before nonces expire
573
- * @param {number} capacity
574
- * @param {bigint} ttl_ms
641
+ * Generate Bitcoin OP_RETURN payload for anchoring
642
+ * Returns hex-encoded payload (45 bytes)
643
+ * @param {string} root_hex
644
+ * @param {bigint} epoch
575
645
  * @returns {string}
576
646
  */
577
- export function create_nonce_cache(capacity, ttl_ms) {
578
- let deferred1_0;
579
- let deferred1_1;
647
+ export function generate_bitcoin_anchor_payload(root_hex, epoch) {
648
+ let deferred2_0;
649
+ let deferred2_1;
580
650
  try {
581
- const ret = wasm.create_nonce_cache(capacity, ttl_ms);
582
- deferred1_0 = ret[0];
583
- deferred1_1 = ret[1];
651
+ const ptr0 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
652
+ const len0 = WASM_VECTOR_LEN;
653
+ const ret = wasm.generate_bitcoin_anchor_payload(ptr0, len0, epoch);
654
+ deferred2_0 = ret[0];
655
+ deferred2_1 = ret[1];
584
656
  return getStringFromWasm0(ret[0], ret[1]);
585
657
  } finally {
586
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
658
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
587
659
  }
588
660
  }
589
661
 
@@ -616,20 +688,42 @@ export function create_accumulator_leaf(user_id, chain_id, block_hash, block_ind
616
688
  }
617
689
  }
618
690
 
619
- export function start() {
620
- wasm.start();
691
+ /**
692
+ * @param {string} key_b64u
693
+ * @param {string} dek_b64u
694
+ * @param {string} aad_b64u
695
+ * @returns {string}
696
+ */
697
+ export function aes_gcm_wrap(key_b64u, dek_b64u, aad_b64u) {
698
+ let deferred4_0;
699
+ let deferred4_1;
700
+ try {
701
+ const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
702
+ const len0 = WASM_VECTOR_LEN;
703
+ const ptr1 = passStringToWasm0(dek_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
704
+ const len1 = WASM_VECTOR_LEN;
705
+ const ptr2 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
706
+ const len2 = WASM_VECTOR_LEN;
707
+ const ret = wasm.aes_gcm_wrap(ptr0, len0, ptr1, len1, ptr2, len2);
708
+ deferred4_0 = ret[0];
709
+ deferred4_1 = ret[1];
710
+ return getStringFromWasm0(ret[0], ret[1]);
711
+ } finally {
712
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
713
+ }
621
714
  }
622
715
 
623
716
  /**
624
- * Check if a nonce has been seen (for replay prevention)
625
- * Returns info about the nonce cache algorithm
717
+ * Get SSSP algorithm configuration for graph verification
718
+ * nodes: expected number of nodes in the graph
719
+ * @param {number} nodes
626
720
  * @returns {string}
627
721
  */
628
- export function nonce_cache_info() {
722
+ export function sssp_config(nodes) {
629
723
  let deferred1_0;
630
724
  let deferred1_1;
631
725
  try {
632
- const ret = wasm.nonce_cache_info();
726
+ const ret = wasm.sssp_config(nodes);
633
727
  deferred1_0 = ret[0];
634
728
  deferred1_1 = ret[1];
635
729
  return getStringFromWasm0(ret[0], ret[1]);
@@ -639,43 +733,58 @@ export function nonce_cache_info() {
639
733
  }
640
734
 
641
735
  /**
642
- * ML-DSA-65 verification (FIPS 204 compliant)
643
- * Security: Input validation prevents DoS; constant-time comparison
644
- * @param {string} message_b64u
645
- * @param {string} signature_b64u
646
- * @param {string} public_b64u
736
+ * Compute shortest path verification info for provenance chains
737
+ * This returns the algorithm parameters for JS-side graph operations
738
+ * @param {number} chain_length
739
+ * @param {number} branches
647
740
  * @returns {string}
648
741
  */
649
- export function dilithium_verify(message_b64u, signature_b64u, public_b64u) {
650
- let deferred4_0;
651
- let deferred4_1;
742
+ export function provenance_path_config(chain_length, branches) {
743
+ let deferred1_0;
744
+ let deferred1_1;
652
745
  try {
653
- const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
746
+ const ret = wasm.provenance_path_config(chain_length, branches);
747
+ deferred1_0 = ret[0];
748
+ deferred1_1 = ret[1];
749
+ return getStringFromWasm0(ret[0], ret[1]);
750
+ } finally {
751
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
752
+ }
753
+ }
754
+
755
+ /**
756
+ * @param {string} receiver
757
+ * @param {number} bps
758
+ * @returns {string}
759
+ */
760
+ export function validate_royalty(receiver, bps) {
761
+ let deferred2_0;
762
+ let deferred2_1;
763
+ try {
764
+ const ptr0 = passStringToWasm0(receiver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
654
765
  const len0 = WASM_VECTOR_LEN;
655
- const ptr1 = passStringToWasm0(signature_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
656
- const len1 = WASM_VECTOR_LEN;
657
- const ptr2 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
658
- const len2 = WASM_VECTOR_LEN;
659
- const ret = wasm.dilithium_verify(ptr0, len0, ptr1, len1, ptr2, len2);
660
- deferred4_0 = ret[0];
661
- deferred4_1 = ret[1];
766
+ const ret = wasm.validate_royalty(ptr0, len0, bps);
767
+ deferred2_0 = ret[0];
768
+ deferred2_1 = ret[1];
662
769
  return getStringFromWasm0(ret[0], ret[1]);
663
770
  } finally {
664
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
771
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
665
772
  }
666
773
  }
667
774
 
668
775
  /**
669
- * Get elastic hash table configuration for key caching
776
+ * Create a nonce cache for replay attack prevention
777
+ * capacity: maximum number of nonces to track
778
+ * ttl_ms: time-to-live in milliseconds before nonces expire
670
779
  * @param {number} capacity
671
- * @param {number} load_factor
780
+ * @param {bigint} ttl_ms
672
781
  * @returns {string}
673
782
  */
674
- export function elastic_hash_config(capacity, load_factor) {
783
+ export function create_nonce_cache(capacity, ttl_ms) {
675
784
  let deferred1_0;
676
785
  let deferred1_1;
677
786
  try {
678
- const ret = wasm.elastic_hash_config(capacity, load_factor);
787
+ const ret = wasm.create_nonce_cache(capacity, ttl_ms);
679
788
  deferred1_0 = ret[0];
680
789
  deferred1_1 = ret[1];
681
790
  return getStringFromWasm0(ret[0], ret[1]);
@@ -685,13 +794,14 @@ export function elastic_hash_config(capacity, load_factor) {
685
794
  }
686
795
 
687
796
  /**
797
+ * Get anchor configuration and gas estimates
688
798
  * @returns {string}
689
799
  */
690
- export function kyber_keygen() {
800
+ export function anchor_config_info() {
691
801
  let deferred1_0;
692
802
  let deferred1_1;
693
803
  try {
694
- const ret = wasm.kyber_keygen();
804
+ const ret = wasm.anchor_config_info();
695
805
  deferred1_0 = ret[0];
696
806
  deferred1_1 = ret[1];
697
807
  return getStringFromWasm0(ret[0], ret[1]);
@@ -701,63 +811,60 @@ export function kyber_keygen() {
701
811
  }
702
812
 
703
813
  /**
704
- * @param {string} msg_b64u
705
- * @param {string} attestations_json
706
- * @param {string | null} [allowed_public_keys_json]
814
+ * @param {string} policy_json
707
815
  * @returns {string}
708
816
  */
709
- export function verify_attestations(msg_b64u, attestations_json, allowed_public_keys_json) {
710
- let deferred4_0;
711
- let deferred4_1;
817
+ export function preimage_governance(policy_json) {
818
+ let deferred2_0;
819
+ let deferred2_1;
712
820
  try {
713
- const ptr0 = passStringToWasm0(msg_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
821
+ const ptr0 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
714
822
  const len0 = WASM_VECTOR_LEN;
715
- const ptr1 = passStringToWasm0(attestations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
716
- const len1 = WASM_VECTOR_LEN;
717
- var ptr2 = isLikeNone(allowed_public_keys_json) ? 0 : passStringToWasm0(allowed_public_keys_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
718
- var len2 = WASM_VECTOR_LEN;
719
- const ret = wasm.verify_attestations(ptr0, len0, ptr1, len1, ptr2, len2);
720
- deferred4_0 = ret[0];
721
- deferred4_1 = ret[1];
823
+ const ret = wasm.preimage_governance(ptr0, len0);
824
+ deferred2_0 = ret[0];
825
+ deferred2_1 = ret[1];
722
826
  return getStringFromWasm0(ret[0], ret[1]);
723
827
  } finally {
724
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
828
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
725
829
  }
726
830
  }
727
831
 
728
832
  /**
729
- * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256)
730
- * Returns hex-encoded calldata ready for transaction
731
- * @param {string} root_hex
732
- * @param {bigint} epoch
833
+ * ML-DSA-65 signing (FIPS 204 compliant)
834
+ * Security: Input validation prevents DoS; constant-time operations
835
+ * @param {string} message_b64u
836
+ * @param {string} secret_b64u
733
837
  * @returns {string}
734
838
  */
735
- export function generate_evm_anchor_calldata(root_hex, epoch) {
736
- let deferred2_0;
737
- let deferred2_1;
839
+ export function dilithium_sign(message_b64u, secret_b64u) {
840
+ let deferred3_0;
841
+ let deferred3_1;
738
842
  try {
739
- const ptr0 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
843
+ const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
740
844
  const len0 = WASM_VECTOR_LEN;
741
- const ret = wasm.generate_evm_anchor_calldata(ptr0, len0, epoch);
742
- deferred2_0 = ret[0];
743
- deferred2_1 = ret[1];
845
+ const ptr1 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
846
+ const len1 = WASM_VECTOR_LEN;
847
+ const ret = wasm.dilithium_sign(ptr0, len0, ptr1, len1);
848
+ deferred3_0 = ret[0];
849
+ deferred3_1 = ret[1];
744
850
  return getStringFromWasm0(ret[0], ret[1]);
745
851
  } finally {
746
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
852
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
747
853
  }
748
854
  }
749
855
 
750
856
  /**
751
- * @param {string} public_b64u
857
+ * SHA3-384 hash of a UTF-8 string, returns 96-char hex string
858
+ * @param {string} data
752
859
  * @returns {string}
753
860
  */
754
- export function kyber_encaps(public_b64u) {
861
+ export function sha3_384_hash_string(data) {
755
862
  let deferred2_0;
756
863
  let deferred2_1;
757
864
  try {
758
- const ptr0 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
865
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
759
866
  const len0 = WASM_VECTOR_LEN;
760
- const ret = wasm.kyber_encaps(ptr0, len0);
867
+ const ret = wasm.sha3_384_hash_string(ptr0, len0);
761
868
  deferred2_0 = ret[0];
762
869
  deferred2_1 = ret[1];
763
870
  return getStringFromWasm0(ret[0], ret[1]);
@@ -823,7 +930,7 @@ function __wbg_get_imports() {
823
930
  imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
824
931
  arg0.getRandomValues(arg1);
825
932
  }, arguments) };
826
- imports.wbg.__wbg_log_d4050525ca8b0bd9 = function(arg0, arg1) {
933
+ imports.wbg.__wbg_log_0b3673147ca34569 = function(arg0, arg1) {
827
934
  console.log(getStringFromWasm0(arg0, arg1));
828
935
  };
829
936
  imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@maatara/core-pqc-wasm",
3
3
  "type": "module",
4
4
  "description": "Ma'atara PQC WASM bindings with elastic hash and frontier SSSP algorithms",
5
- "version": "0.4.5",
5
+ "version": "0.5.0",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",