wickra-zk 0.1.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-APACHE 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 Derivative
95
+ 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 2026 kingchenc and the Wickra 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.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kingchenc and the Wickra contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/wickra-banner.webp" alt="Wickra" width="100%">
3
+ </p>
4
+
5
+ # wickra-zk
6
+
7
+ [![Built on Wickra](https://img.shields.io/badge/built%20on-wickra-3b82f6)](https://github.com/wickra-lib/wickra)
8
+ [![Status](https://img.shields.io/badge/status-pre--release-orange)](https://github.com/wickra-lib/wickra-zk)
9
+ [![CI](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/ci.svg)](https://github.com/wickra-lib/wickra-zk/actions/workflows/ci.yml)
10
+ [![CodeQL](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/codeql.svg)](https://github.com/wickra-lib/wickra-zk/actions/workflows/codeql.yml)
11
+ [![codecov](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/codecov.svg)](https://codecov.io/gh/wickra-lib/wickra-zk)
12
+ [![GitHub release](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/release.svg)](https://github.com/wickra-lib/wickra-zk/releases/latest)
13
+ [![crates.io](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/crates.svg)](https://crates.io/crates/wickra-zk)
14
+ [![PyPI](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/pypi.svg)](https://pypi.org/project/wickra-zk/)
15
+ [![npm](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/npm.svg)](https://www.npmjs.com/package/wickra-zk)
16
+ [![NuGet](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/nuget.svg)](https://www.nuget.org/packages/Wickra.Zk)
17
+ [![Maven Central](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/maven.svg)](https://central.sonatype.com/artifact/org.wickra/wickra-zk)
18
+ [![Go module](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/go.svg)](https://pkg.go.dev/github.com/wickra-lib/wickra-zk-go)
19
+ [![R-universe](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/r-universe.svg)](https://wickra-lib.r-universe.dev)
20
+ [![License: MIT OR Apache-2.0](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/license.svg)](#license)
21
+ [![OpenSSF Scorecard](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/scorecard.svg)](https://scorecard.dev/viewer/?uri=github.com/wickra-lib/wickra-zk)
22
+ [![OpenSSF Best Practices](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/best-practices.svg)](https://www.bestpractices.dev)
23
+ [![Build provenance](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/provenance.svg)](https://github.com/wickra-lib/wickra-zk/attestations)
24
+ [![Docs](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/docs.svg)](https://zk.wickra.org)
25
+ [![Verified across 10 languages](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/verified.svg)](golden/)
26
+ [![Zero-knowledge](https://img.shields.io/badge/proof-zero--knowledge-8b5cf6)](#what-is-proved--what-stays-private)
27
+
28
+ **Prove a backtest in zero knowledge. The deterministic Wickra engine runs inside a RISC Zero zkVM guest, and the receipt proves the report's hash and headline metrics without revealing the candles or the strategy.**
29
+
30
+ > **Part of the [Wickra ecosystem](https://github.com/wickra-lib):** the same
31
+ > data-driven core also powers
32
+ > [wickra-backtest](https://github.com/wickra-lib/wickra-backtest),
33
+ > [wickra-proof](https://github.com/wickra-lib/wickra-proof),
34
+ > [wickra-verify](https://github.com/wickra-lib/wickra-verify) and 20 more — see
35
+ > [the full list](https://github.com/wickra-lib).
36
+
37
+ **wickra-zk** runs a deterministic [Wickra](https://github.com/wickra-lib/wickra)
38
+ backtest as a guest program inside the [risc0](https://risczero.com) zkVM and
39
+ produces a succinct **zero-knowledge proof** over it. Anyone holding the proof
40
+ -- a server, an auditor, a browser -- checks it against the pinned guest and
41
+ can trust the reported performance metrics **without ever seeing the price
42
+ data or the strategy internals**. The proof is a constant-size STARK receipt;
43
+ wrapping it for an on-chain verifier is on the [roadmap](ROADMAP.md).
44
+
45
+ This works only because Wickra computes byte-deterministically: the report the
46
+ guest proves is exactly the one `wickra-backtest` produces natively and
47
+ `wickra-proof` canonicalizes and hashes.
48
+
49
+ ```rust
50
+ use wickra_zk_host::{commit_dataset, prove, verify, ProveOptions, ZkSpec};
51
+
52
+ // The strategy and the candles are the private inputs; the proof is bound to
53
+ // the candles through their canonical hash, which the guest recomputes.
54
+ let spec = ZkSpec { strategy, dataset_commitment: commit_dataset(&candles)? };
55
+ let proof = prove(&spec, &candles, ProveOptions::default())?;
56
+
57
+ // Anyone verifies the receipt against the pinned guest and reads the journal
58
+ // from it -- the report hash, the commitment, sharpe, pnl, the trade count.
59
+ let journal = verify(&proof)?;
60
+ println!("report_hash: {}", journal.report_hash);
61
+ ```
62
+
63
+ The same envelope -- `prove`, `commit`, `verify`, `version` as JSON -- is
64
+ what the CLI and every binding speak: Python, Node.js, C, C++, C#, Go, Java and
65
+ R prove and verify natively, and a WebAssembly build verifies in the browser.
66
+
67
+ ## What is proved
68
+
69
+ - A public **`report_hash`** — the canonical hash of the full `BacktestReport`.
70
+ - A small set of **public metrics** (e.g. `sharpe`, `pnl`, `n_trades`).
71
+ - Bound to a specific **`GUEST_ID`** (the program that ran) so a verifier knows
72
+ the honest engine produced the result.
73
+
74
+ What stays **private**: the OHLCV candles and the strategy internals — they are
75
+ guest inputs, never revealed by the receipt.
76
+
77
+ ## Status
78
+
79
+ Early development (0.1.0); 0.1.0 is the first published release. See
80
+ [ROADMAP.md](ROADMAP.md).
81
+
82
+ ## Documentation
83
+
84
+ - [ARCHITECTURE.md](ARCHITECTURE.md) — host/guest split, zkVM choice, determinism chain
85
+ - [docs/ZK.md](docs/ZK.md) — receipt, journal, image ID; what is and is not proved
86
+ - [docs/DETERMINISM.md](docs/DETERMINISM.md) — why the journal hash equals the native hash
87
+ - [docs/PROVING.md](docs/PROVING.md) — dev-mode vs. production proving, timing, memory
88
+ - [docs/Cookbook.md](docs/Cookbook.md) — prove/verify recipes
89
+ - [THREAT_MODEL.md](THREAT_MODEL.md), [SECURITY.md](SECURITY.md)
90
+
91
+ ## Quickstart
92
+
93
+ ```bash
94
+ cargo install wickra-zk
95
+ wickra-zk prove --spec examples/specs/momentum.json --data examples/data/BTCUSDT.csv --out momentum.proof.json
96
+ wickra-zk verify --proof momentum.proof.json
97
+ ```
98
+
99
+ The prover is in-process and the compiled guest ships inside the crate, so
100
+ nothing else is installed. Add `--dev` (or `RISC0_DEV_MODE=1`) for a fast,
101
+ unsound receipt while developing; a real proof takes minutes. One runnable
102
+ example per language lives under [`examples/`](examples/README.md).
103
+
104
+ ## Building everything from source
105
+
106
+ ```bash
107
+ git clone https://github.com/wickra-lib/wickra-zk && cd wickra-zk
108
+ cargo build --release # host, CLI, C ABI, Python and Node crates
109
+ RISC0_DEV_MODE=1 cargo test --workspace # dev-mode receipts: seconds, unsound
110
+ ```
111
+
112
+ The compiled guest is committed, so this needs no risc0 toolchain. Changing
113
+ the guest does -- see [CONTRIBUTING.md](CONTRIBUTING.md) for the builder and
114
+ the reproducible rebuild CI holds it to.
115
+
116
+ ## Project layout
117
+
118
+ ```
119
+ crates/wickra-zk-host/ the host: prove, verify, the ZkSpec/PublicOutputs model
120
+ crates/wickra-zk-cli/ the `wickra-zk` command line
121
+ crates/wickra-zk-bench/ criterion benchmarks over the proving path
122
+ guest/methods/guest/ the guest program -- the code that runs inside the
123
+ zkVM and whose honest execution the receipt attests
124
+ guest/methods/ the compiled guest, committed: its ELF and image id
125
+ guest/builder/ compiles the guest through risc0-build and writes
126
+ the two files above; the only risc0 consumer
127
+ bindings/ c, python, node, wasm (verify only), go, csharp,
128
+ java, r -- one JSON envelope over the host
129
+ examples/ one runnable prove/verify per language
130
+ golden/ frozen (spec, data) -> expected journals, one real
131
+ receipt, the case-to-dataset map
132
+ fuzz/ libfuzzer targets over the JSON boundary
133
+ ```
134
+
135
+ ## Testing
136
+
137
+ Run the suites with the commands in
138
+ [Building everything from source](#building-everything-from-source).
139
+
140
+ - **`wickra-zk-host`** — the determinism chain, end to end: the native path's
141
+ report hash, the dev-mode guest's journal, and the blessed fixtures must all
142
+ agree. That equality is the product; if the guest and the native engine ever
143
+ disagree, the proof attests to something other than what the engine computes.
144
+ - **The guest** is rebuilt for `riscv32im-risc0-zkvm-elf` in risc0's build
145
+ container on every change and compared byte for byte with the committed ELF
146
+ and image id, and linted for that target separately, because a guest that
147
+ builds on the host proves nothing about the one that runs in the circuit.
148
+ - **Every binding** proves the golden cases through the envelope in dev-mode
149
+ and holds the journal to the blessed report hash and metrics; the WebAssembly
150
+ verifier and the host verify a committed real receipt, so the sound path is
151
+ exercised on every push without a prover.
152
+ - **`fuzz/`** — libfuzzer targets over the spec and journal parsers, run as a
153
+ time-boxed smoke in CI.
154
+ - **Nightly** — `prove.yml` runs the real proving path rather than dev mode.
155
+ Dev mode produces an unsound receipt quickly, which is right for CI and wrong
156
+ as the only thing ever exercised.
157
+
158
+ ## Benchmarks
159
+
160
+ `crates/wickra-zk-bench` measures the proving path with criterion, and CodSpeed
161
+ reports instruction counts on every pull request. Absolute proving times depend
162
+ on the machine and on whether the receipt is real or dev-mode; the numbers worth
163
+ watching are relative, which is what CodSpeed reports.
164
+
165
+ ```bash
166
+ cargo bench -p wickra-zk-bench
167
+ ```
168
+
169
+ ## Requirements
170
+
171
+ - Linux or macOS. risc0 has no Windows host, so neither the crates nor any
172
+ binding build there; on Windows use WSL.
173
+ - Rust 1.90+. The prover is in-process and the compiled guest is committed, so
174
+ building, proving and verifying need no risc0 toolchain; changing the guest
175
+ does (see [CONTRIBUTING.md](CONTRIBUTING.md)).
176
+ - On macOS, Xcode's Metal toolchain: risc0 compiles its Metal kernels whenever
177
+ the prover is built there. `xcodebuild -downloadComponent MetalToolchain`
178
+ once; the crate reports `cannot execute tool 'metal'` until then.
179
+ - Per binding: Python 3.9+, Node.js 20+, a C toolchain and CMake, .NET 8 SDK,
180
+ JDK 22+, Go 1.23+, R 4.1+ -- the floors the manifests declare.
181
+ - See [CONTRIBUTING.md](CONTRIBUTING.md) for the full verify workflow.
182
+
183
+ ## Ecosystem
184
+
185
+ Part of the [Wickra](https://github.com/wickra-lib/wickra) family — each one a
186
+ data-driven core with a CLI and the same binding surface:
187
+
188
+ - [**wickra**](https://github.com/wickra-lib/wickra) — main library (Rust core + Python / Node.js / WASM bindings + a C ABI for C / C++ / C# / Go / Java / R)
189
+ - [**wickra-playground**](https://github.com/wickra-lib/wickra-playground) — a polyglot strategy playground: one StrategySpec live side by side in Python, Rust, JS and Go, entirely in the browser
190
+ - [**wickra-exchange**](https://github.com/wickra-lib/wickra-exchange) — unified market-data + execution across ten crypto exchanges
191
+ - [**wickra-backtest**](https://github.com/wickra-lib/wickra-backtest) — event-driven backtester over the Wickra core
192
+ - [**wickra-terminal**](https://github.com/wickra-lib/wickra-terminal) — the trading terminal: a TUI and a browser renderer over the stack
193
+ - [**wickra-screener**](https://github.com/wickra-lib/wickra-screener) — parallel multi-symbol screening over 514 streaming indicators
194
+ - [**wickra-radar**](https://github.com/wickra-lib/wickra-radar) — perp-universe alert radar: OI delta, funding flip, book imbalance, liquidation clusters, OI/price divergence
195
+ - [**wickra-copilot**](https://github.com/wickra-lib/wickra-copilot) — local market copilot grounded in real order-book, liquidation and funding microstructure
196
+ - [**wickra-shazam**](https://github.com/wickra-lib/wickra-shazam) — match an asset's current microstructure fingerprint against its entire history
197
+ - [**wickra-benchmark**](https://github.com/wickra-lib/wickra-benchmark) — reproducible, golden-verified benchmark suite — recompute any (strategy, dataset, report) in ten languages and confirm it byte-for-byte
198
+ - [**wickra-strategy-ci**](https://github.com/wickra-lib/wickra-strategy-ci) — Jest for trading strategies: golden-pin the report, catch regressions in CI, property-test against fuzzed data
199
+ - [**wickra-verify**](https://github.com/wickra-lib/wickra-verify) — confirm or refute a claimed backtest report against its strategy and data, in ten languages
200
+ - [**wickra-proof**](https://github.com/wickra-lib/wickra-proof) — Proof-of-Backtest: deterministic (spec, data) → report + blake3 hash, recomputable byte-for-byte in ten languages
201
+ - [**wickra-zk**](https://github.com/wickra-lib/wickra-zk) — this repository: prove a backtest zero-knowledge, verifiable anywhere without the data or the strategy
202
+ - [**wickra-impact**](https://github.com/wickra-lib/wickra-impact) — the backtester that knows you would have moved the market: agent-based fills on the real historical L2 order book
203
+ - [**wickra-darwin**](https://github.com/wickra-lib/wickra-darwin) — evolutionary strategy search at millions of backtests per second, mutating and crossing JSON specs across the 514-indicator space
204
+ - [**wickra-gym**](https://github.com/wickra-lib/wickra-gym) — a Gymnasium-compatible, microstructure-aware backtest environment with O(1) steps for deterministic RL rollouts
205
+ - [**wickra-feature-store**](https://github.com/wickra-lib/wickra-feature-store) — OHLCV and microstructure streams into ML-ready feature matrices over 514 O(1) streaming indicators
206
+
207
+ ## Contributing
208
+
209
+ Pull requests welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). By participating
210
+ you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
211
+
212
+ ## Security
213
+
214
+ Report vulnerabilities privately — see [SECURITY.md](SECURITY.md).
215
+
216
+ ## License
217
+
218
+ Dual-licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE)
219
+ at your option.
220
+
221
+ The in-process prover links risc0's circuit crates, which depend on
222
+ [malachite](https://crates.io/crates/malachite) (LGPL-3.0-only) for big-integer
223
+ arithmetic. Every binary and package this repository publishes is built from
224
+ source available here under the licences above, which satisfies the LGPL's
225
+ relinking condition for statically linked libraries; risc0-zkvm itself ships
226
+ the same way. `deny.toml` names the exception.
227
+
228
+ ## Disclaimer
229
+
230
+ This software is provided for research and educational purposes. It is not
231
+ financial advice. A zero-knowledge proof attests only to the honest execution of
232
+ the pinned guest program over the prover's inputs; it makes no claim about the
233
+ quality, provenance, or future performance of a trading strategy.
234
+
235
+ ---
236
+
237
+ <p align="center">
238
+ <a href="https://github.com/wickra-lib/wickra-zk">
239
+ <img alt="GitHub stars" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/stars.svg">
240
+ </a>
241
+ <a href="https://github.com/wickra-lib/wickra-zk/network/members">
242
+ <img alt="GitHub forks" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/forks.svg">
243
+ </a>
244
+ <a href="https://github.com/wickra-lib/wickra-zk/issues">
245
+ <img alt="GitHub issues" src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/issues.svg">
246
+ </a>
247
+ </p>
248
+
249
+ <p align="center">
250
+ Built on <a href="https://github.com/wickra-lib/wickra">Wickra</a>. If it saved you time, the cheapest way to say thanks is to ⭐ the repo.
251
+ </p>
252
+
253
+ <p align="center">
254
+ <img alt="wickra-zk star history" width="640"
255
+ src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-zk/star-history.svg">
256
+ </p>
package/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A prover driven by JSON commands.
6
+ *
7
+ * The host's command surface is a free function; the handle exists so every
8
+ * binding in the family reads the same way. It carries the host version it
9
+ * was created against, which is what `version()` reports.
10
+ */
11
+ export declare class Prover {
12
+ /** Create a prover. */
13
+ constructor()
14
+ /** Apply a command JSON and return the resulting response JSON. */
15
+ command(cmdJson: string): string
16
+ /** The library version. */
17
+ version(): string
18
+ }
19
+
20
+ /** The library version. */
21
+ export declare function version(): string
package/index.js ADDED
@@ -0,0 +1,703 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /* auto-generated by NAPI-RS */
4
+
5
+ const { readFileSync } = require('fs')
6
+ let nativeBinding = null
7
+ const loadErrors = []
8
+
9
+ const isMusl = () => {
10
+ let musl = false
11
+ if (process.platform === 'linux') {
12
+ musl = isMuslFromFilesystem()
13
+ if (musl === null) {
14
+ musl = isMuslFromReport()
15
+ }
16
+ if (musl === null) {
17
+ musl = isMuslFromChildProcess()
18
+ }
19
+ }
20
+ return musl
21
+ }
22
+
23
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
24
+
25
+ const isMuslFromFilesystem = () => {
26
+ try {
27
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
28
+ } catch {
29
+ return null
30
+ }
31
+ }
32
+
33
+ const isMuslFromReport = () => {
34
+ let report = null
35
+ if (process.report && typeof process.report.getReport === 'function') {
36
+ process.report.excludeNetwork = true
37
+ report = process.report.getReport()
38
+ }
39
+ if (!report) {
40
+ return null
41
+ }
42
+ if (report.header && report.header.glibcVersionRuntime) {
43
+ return false
44
+ }
45
+ if (Array.isArray(report.sharedObjects)) {
46
+ if (report.sharedObjects.some(isFileMusl)) {
47
+ return true
48
+ }
49
+ }
50
+ return false
51
+ }
52
+
53
+ const isMuslFromChildProcess = () => {
54
+ try {
55
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
56
+ } catch (e) {
57
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
58
+ return false
59
+ }
60
+ }
61
+
62
+ function requireNative() {
63
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
64
+ try {
65
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
66
+ } catch (err) {
67
+ loadErrors.push(err)
68
+ }
69
+ } else if (process.platform === 'android') {
70
+ if (process.arch === 'arm64') {
71
+ try {
72
+ return require('./wickra-zk.android-arm64.node')
73
+ } catch (e) {
74
+ loadErrors.push(e)
75
+ }
76
+ try {
77
+ const binding = require('wickra-zk-android-arm64')
78
+ const bindingPackageVersion = require('wickra-zk-android-arm64/package.json').version
79
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
80
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
81
+ }
82
+ return binding
83
+ } catch (e) {
84
+ loadErrors.push(e)
85
+ }
86
+ } else if (process.arch === 'arm') {
87
+ try {
88
+ return require('./wickra-zk.android-arm-eabi.node')
89
+ } catch (e) {
90
+ loadErrors.push(e)
91
+ }
92
+ try {
93
+ const binding = require('wickra-zk-android-arm-eabi')
94
+ const bindingPackageVersion = require('wickra-zk-android-arm-eabi/package.json').version
95
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
96
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
97
+ }
98
+ return binding
99
+ } catch (e) {
100
+ loadErrors.push(e)
101
+ }
102
+ } else {
103
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
104
+ }
105
+ } else if (process.platform === 'win32') {
106
+ if (process.arch === 'x64') {
107
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
108
+ try {
109
+ return require('./wickra-zk.win32-x64-gnu.node')
110
+ } catch (e) {
111
+ loadErrors.push(e)
112
+ }
113
+ try {
114
+ const binding = require('wickra-zk-win32-x64-gnu')
115
+ const bindingPackageVersion = require('wickra-zk-win32-x64-gnu/package.json').version
116
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
117
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
118
+ }
119
+ return binding
120
+ } catch (e) {
121
+ loadErrors.push(e)
122
+ }
123
+ } else {
124
+ try {
125
+ return require('./wickra-zk.win32-x64-msvc.node')
126
+ } catch (e) {
127
+ loadErrors.push(e)
128
+ }
129
+ try {
130
+ const binding = require('wickra-zk-win32-x64-msvc')
131
+ const bindingPackageVersion = require('wickra-zk-win32-x64-msvc/package.json').version
132
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
133
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
134
+ }
135
+ return binding
136
+ } catch (e) {
137
+ loadErrors.push(e)
138
+ }
139
+ }
140
+ } else if (process.arch === 'ia32') {
141
+ try {
142
+ return require('./wickra-zk.win32-ia32-msvc.node')
143
+ } catch (e) {
144
+ loadErrors.push(e)
145
+ }
146
+ try {
147
+ const binding = require('wickra-zk-win32-ia32-msvc')
148
+ const bindingPackageVersion = require('wickra-zk-win32-ia32-msvc/package.json').version
149
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
150
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
151
+ }
152
+ return binding
153
+ } catch (e) {
154
+ loadErrors.push(e)
155
+ }
156
+ } else if (process.arch === 'arm64') {
157
+ try {
158
+ return require('./wickra-zk.win32-arm64-msvc.node')
159
+ } catch (e) {
160
+ loadErrors.push(e)
161
+ }
162
+ try {
163
+ const binding = require('wickra-zk-win32-arm64-msvc')
164
+ const bindingPackageVersion = require('wickra-zk-win32-arm64-msvc/package.json').version
165
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
166
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
167
+ }
168
+ return binding
169
+ } catch (e) {
170
+ loadErrors.push(e)
171
+ }
172
+ } else {
173
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
174
+ }
175
+ } else if (process.platform === 'darwin') {
176
+ try {
177
+ return require('./wickra-zk.darwin-universal.node')
178
+ } catch (e) {
179
+ loadErrors.push(e)
180
+ }
181
+ try {
182
+ const binding = require('wickra-zk-darwin-universal')
183
+ const bindingPackageVersion = require('wickra-zk-darwin-universal/package.json').version
184
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
185
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
186
+ }
187
+ return binding
188
+ } catch (e) {
189
+ loadErrors.push(e)
190
+ }
191
+ if (process.arch === 'x64') {
192
+ try {
193
+ return require('./wickra-zk.darwin-x64.node')
194
+ } catch (e) {
195
+ loadErrors.push(e)
196
+ }
197
+ try {
198
+ const binding = require('wickra-zk-darwin-x64')
199
+ const bindingPackageVersion = require('wickra-zk-darwin-x64/package.json').version
200
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
201
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
202
+ }
203
+ return binding
204
+ } catch (e) {
205
+ loadErrors.push(e)
206
+ }
207
+ } else if (process.arch === 'arm64') {
208
+ try {
209
+ return require('./wickra-zk.darwin-arm64.node')
210
+ } catch (e) {
211
+ loadErrors.push(e)
212
+ }
213
+ try {
214
+ const binding = require('wickra-zk-darwin-arm64')
215
+ const bindingPackageVersion = require('wickra-zk-darwin-arm64/package.json').version
216
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
217
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
218
+ }
219
+ return binding
220
+ } catch (e) {
221
+ loadErrors.push(e)
222
+ }
223
+ } else {
224
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
225
+ }
226
+ } else if (process.platform === 'freebsd') {
227
+ if (process.arch === 'x64') {
228
+ try {
229
+ return require('./wickra-zk.freebsd-x64.node')
230
+ } catch (e) {
231
+ loadErrors.push(e)
232
+ }
233
+ try {
234
+ const binding = require('wickra-zk-freebsd-x64')
235
+ const bindingPackageVersion = require('wickra-zk-freebsd-x64/package.json').version
236
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
237
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
238
+ }
239
+ return binding
240
+ } catch (e) {
241
+ loadErrors.push(e)
242
+ }
243
+ } else if (process.arch === 'arm64') {
244
+ try {
245
+ return require('./wickra-zk.freebsd-arm64.node')
246
+ } catch (e) {
247
+ loadErrors.push(e)
248
+ }
249
+ try {
250
+ const binding = require('wickra-zk-freebsd-arm64')
251
+ const bindingPackageVersion = require('wickra-zk-freebsd-arm64/package.json').version
252
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
253
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
254
+ }
255
+ return binding
256
+ } catch (e) {
257
+ loadErrors.push(e)
258
+ }
259
+ } else {
260
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
261
+ }
262
+ } else if (process.platform === 'linux') {
263
+ if (process.arch === 'x64') {
264
+ if (isMusl()) {
265
+ try {
266
+ return require('./wickra-zk.linux-x64-musl.node')
267
+ } catch (e) {
268
+ loadErrors.push(e)
269
+ }
270
+ try {
271
+ const binding = require('wickra-zk-linux-x64-musl')
272
+ const bindingPackageVersion = require('wickra-zk-linux-x64-musl/package.json').version
273
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
274
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
275
+ }
276
+ return binding
277
+ } catch (e) {
278
+ loadErrors.push(e)
279
+ }
280
+ } else {
281
+ try {
282
+ return require('./wickra-zk.linux-x64-gnu.node')
283
+ } catch (e) {
284
+ loadErrors.push(e)
285
+ }
286
+ try {
287
+ const binding = require('wickra-zk-linux-x64-gnu')
288
+ const bindingPackageVersion = require('wickra-zk-linux-x64-gnu/package.json').version
289
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
291
+ }
292
+ return binding
293
+ } catch (e) {
294
+ loadErrors.push(e)
295
+ }
296
+ }
297
+ } else if (process.arch === 'arm64') {
298
+ if (isMusl()) {
299
+ try {
300
+ return require('./wickra-zk.linux-arm64-musl.node')
301
+ } catch (e) {
302
+ loadErrors.push(e)
303
+ }
304
+ try {
305
+ const binding = require('wickra-zk-linux-arm64-musl')
306
+ const bindingPackageVersion = require('wickra-zk-linux-arm64-musl/package.json').version
307
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
308
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
309
+ }
310
+ return binding
311
+ } catch (e) {
312
+ loadErrors.push(e)
313
+ }
314
+ } else {
315
+ try {
316
+ return require('./wickra-zk.linux-arm64-gnu.node')
317
+ } catch (e) {
318
+ loadErrors.push(e)
319
+ }
320
+ try {
321
+ const binding = require('wickra-zk-linux-arm64-gnu')
322
+ const bindingPackageVersion = require('wickra-zk-linux-arm64-gnu/package.json').version
323
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
324
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
325
+ }
326
+ return binding
327
+ } catch (e) {
328
+ loadErrors.push(e)
329
+ }
330
+ }
331
+ } else if (process.arch === 'arm') {
332
+ if (isMusl()) {
333
+ try {
334
+ return require('./wickra-zk.linux-arm-musleabihf.node')
335
+ } catch (e) {
336
+ loadErrors.push(e)
337
+ }
338
+ try {
339
+ const binding = require('wickra-zk-linux-arm-musleabihf')
340
+ const bindingPackageVersion = require('wickra-zk-linux-arm-musleabihf/package.json').version
341
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
342
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
343
+ }
344
+ return binding
345
+ } catch (e) {
346
+ loadErrors.push(e)
347
+ }
348
+ } else {
349
+ try {
350
+ return require('./wickra-zk.linux-arm-gnueabihf.node')
351
+ } catch (e) {
352
+ loadErrors.push(e)
353
+ }
354
+ try {
355
+ const binding = require('wickra-zk-linux-arm-gnueabihf')
356
+ const bindingPackageVersion = require('wickra-zk-linux-arm-gnueabihf/package.json').version
357
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
358
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
359
+ }
360
+ return binding
361
+ } catch (e) {
362
+ loadErrors.push(e)
363
+ }
364
+ }
365
+ } else if (process.arch === 'loong64') {
366
+ if (isMusl()) {
367
+ try {
368
+ return require('./wickra-zk.linux-loong64-musl.node')
369
+ } catch (e) {
370
+ loadErrors.push(e)
371
+ }
372
+ try {
373
+ const binding = require('wickra-zk-linux-loong64-musl')
374
+ const bindingPackageVersion = require('wickra-zk-linux-loong64-musl/package.json').version
375
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
376
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
377
+ }
378
+ return binding
379
+ } catch (e) {
380
+ loadErrors.push(e)
381
+ }
382
+ } else {
383
+ try {
384
+ return require('./wickra-zk.linux-loong64-gnu.node')
385
+ } catch (e) {
386
+ loadErrors.push(e)
387
+ }
388
+ try {
389
+ const binding = require('wickra-zk-linux-loong64-gnu')
390
+ const bindingPackageVersion = require('wickra-zk-linux-loong64-gnu/package.json').version
391
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
392
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
393
+ }
394
+ return binding
395
+ } catch (e) {
396
+ loadErrors.push(e)
397
+ }
398
+ }
399
+ } else if (process.arch === 'riscv64') {
400
+ if (isMusl()) {
401
+ try {
402
+ return require('./wickra-zk.linux-riscv64-musl.node')
403
+ } catch (e) {
404
+ loadErrors.push(e)
405
+ }
406
+ try {
407
+ const binding = require('wickra-zk-linux-riscv64-musl')
408
+ const bindingPackageVersion = require('wickra-zk-linux-riscv64-musl/package.json').version
409
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
410
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
411
+ }
412
+ return binding
413
+ } catch (e) {
414
+ loadErrors.push(e)
415
+ }
416
+ } else {
417
+ try {
418
+ return require('./wickra-zk.linux-riscv64-gnu.node')
419
+ } catch (e) {
420
+ loadErrors.push(e)
421
+ }
422
+ try {
423
+ const binding = require('wickra-zk-linux-riscv64-gnu')
424
+ const bindingPackageVersion = require('wickra-zk-linux-riscv64-gnu/package.json').version
425
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
426
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
427
+ }
428
+ return binding
429
+ } catch (e) {
430
+ loadErrors.push(e)
431
+ }
432
+ }
433
+ } else if (process.arch === 'ppc64') {
434
+ try {
435
+ return require('./wickra-zk.linux-ppc64-gnu.node')
436
+ } catch (e) {
437
+ loadErrors.push(e)
438
+ }
439
+ try {
440
+ const binding = require('wickra-zk-linux-ppc64-gnu')
441
+ const bindingPackageVersion = require('wickra-zk-linux-ppc64-gnu/package.json').version
442
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
443
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
444
+ }
445
+ return binding
446
+ } catch (e) {
447
+ loadErrors.push(e)
448
+ }
449
+ } else if (process.arch === 's390x') {
450
+ try {
451
+ return require('./wickra-zk.linux-s390x-gnu.node')
452
+ } catch (e) {
453
+ loadErrors.push(e)
454
+ }
455
+ try {
456
+ const binding = require('wickra-zk-linux-s390x-gnu')
457
+ const bindingPackageVersion = require('wickra-zk-linux-s390x-gnu/package.json').version
458
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
459
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
460
+ }
461
+ return binding
462
+ } catch (e) {
463
+ loadErrors.push(e)
464
+ }
465
+ } else {
466
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
467
+ }
468
+ } else if (process.platform === 'openharmony') {
469
+ if (process.arch === 'arm64') {
470
+ try {
471
+ return require('./wickra-zk.openharmony-arm64.node')
472
+ } catch (e) {
473
+ loadErrors.push(e)
474
+ }
475
+ try {
476
+ const binding = require('wickra-zk-openharmony-arm64')
477
+ const bindingPackageVersion = require('wickra-zk-openharmony-arm64/package.json').version
478
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
479
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
480
+ }
481
+ return binding
482
+ } catch (e) {
483
+ loadErrors.push(e)
484
+ }
485
+ } else if (process.arch === 'x64') {
486
+ try {
487
+ return require('./wickra-zk.openharmony-x64.node')
488
+ } catch (e) {
489
+ loadErrors.push(e)
490
+ }
491
+ try {
492
+ const binding = require('wickra-zk-openharmony-x64')
493
+ const bindingPackageVersion = require('wickra-zk-openharmony-x64/package.json').version
494
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
495
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
496
+ }
497
+ return binding
498
+ } catch (e) {
499
+ loadErrors.push(e)
500
+ }
501
+ } else if (process.arch === 'arm') {
502
+ try {
503
+ return require('./wickra-zk.openharmony-arm.node')
504
+ } catch (e) {
505
+ loadErrors.push(e)
506
+ }
507
+ try {
508
+ const binding = require('wickra-zk-openharmony-arm')
509
+ const bindingPackageVersion = require('wickra-zk-openharmony-arm/package.json').version
510
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
511
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
512
+ }
513
+ return binding
514
+ } catch (e) {
515
+ loadErrors.push(e)
516
+ }
517
+ } else {
518
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
519
+ }
520
+ } else {
521
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
522
+ }
523
+ }
524
+
525
+ function createLoadErrorChain(errors) {
526
+ return errors.reduce((previous, current) => {
527
+ let message
528
+ try {
529
+ message =
530
+ current && typeof current.message === 'string'
531
+ ? current.message
532
+ : String(current)
533
+ } catch {
534
+ message = 'Unknown error'
535
+ }
536
+ const error = new Error(message)
537
+ error.cause = previous
538
+ return error
539
+ }, null)
540
+ }
541
+
542
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
543
+ // unset / any other value → native binding preferred, WASI is only a fallback
544
+ // 'true' → prefer WASI, but retain native as a lazy fallback
545
+ // 'error' → require WASI without initializing a native fallback
546
+ // Treating any non-empty string as truthy (the historical behavior) meant
547
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
548
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
549
+ //
550
+ // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
551
+ // WASI loading. It never crosses into another flavor or falls back to native.
552
+ const __napiWasiFlavors = ['wasm32-wasi']
553
+ const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
554
+ const __napiWasiFlavorRequested =
555
+ typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
556
+ if (
557
+ __napiWasiFlavorRequested &&
558
+ __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
559
+ ) {
560
+ throw new Error(
561
+ 'Unsupported WASI flavor "' +
562
+ __napiWasiFlavor +
563
+ '". Available flavors: ' +
564
+ __napiWasiFlavors.join(', '),
565
+ )
566
+ }
567
+ const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
568
+ const forceWasi =
569
+ process.env.NAPI_RS_FORCE_WASI === 'true' ||
570
+ forceWasiError ||
571
+ __napiWasiFlavorRequested
572
+
573
+ if (!forceWasi) {
574
+ nativeBinding = requireNative()
575
+ }
576
+
577
+ if (!nativeBinding || forceWasi) {
578
+ let wasiBinding = null
579
+ let wasiBindingLoaded = false
580
+ const wasiBindingErrors = []
581
+ const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
582
+ try {
583
+ require.resolve(specifier)
584
+ } catch (resolveError) {
585
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
586
+ throw resolveError
587
+ }
588
+ if (isPackage) {
589
+ try {
590
+ require.resolve(specifier + '/package.json')
591
+ } catch (packageError) {
592
+ if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
593
+ return resolveError
594
+ }
595
+ // An exports restriction proves the package exists even when its
596
+ // package.json is not public. Preserve the root resolution failure.
597
+ throw resolveError
598
+ }
599
+ // The package exists but its main/export target is broken.
600
+ throw resolveError
601
+ }
602
+ return resolveError
603
+ }
604
+ if (localArtifacts) {
605
+ let artifactError = null
606
+ for (let i = 0; i < localArtifacts.length; i++) {
607
+ try {
608
+ require.resolve(localArtifacts[i])
609
+ return null
610
+ } catch (resolveError) {
611
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
612
+ throw resolveError
613
+ }
614
+ artifactError = resolveError
615
+ }
616
+ }
617
+ return artifactError
618
+ }
619
+ return null
620
+ }
621
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
622
+ let candidateError = null
623
+ let candidateFailed = false
624
+ try {
625
+ candidateError = __napiWasiResolveCandidate('./wickra-zk.wasi.cjs', false, ['./wickra-zk.wasm32-wasi.debug.wasm', './wickra-zk.wasm32-wasi.wasm'])
626
+ candidateFailed = candidateError !== null
627
+ if (!candidateFailed) {
628
+ wasiBinding = require('./wickra-zk.wasi.cjs')
629
+ nativeBinding = wasiBinding
630
+ wasiBindingLoaded = true
631
+ }
632
+ } catch (err) {
633
+ candidateError = err
634
+ candidateFailed = true
635
+ }
636
+ if (candidateFailed) {
637
+ wasiBindingErrors.push(candidateError)
638
+ loadErrors.push(candidateError)
639
+ }
640
+ }
641
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
642
+ let candidateError = null
643
+ let candidateFailed = false
644
+ try {
645
+ candidateError = __napiWasiResolveCandidate('wickra-zk-wasm32-wasi', true, undefined)
646
+ candidateFailed = candidateError !== null
647
+ if (!candidateFailed) {
648
+ if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
649
+ const bindingPackageVersion = require('wickra-zk-wasm32-wasi/package.json').version
650
+ if (bindingPackageVersion !== '0.1.0') {
651
+ throw new Error(`WASI binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
652
+ }
653
+ }
654
+ wasiBinding = require('wickra-zk-wasm32-wasi')
655
+ nativeBinding = wasiBinding
656
+ wasiBindingLoaded = true
657
+ }
658
+ } catch (err) {
659
+ candidateError = err
660
+ candidateFailed = true
661
+ }
662
+ if (candidateFailed) {
663
+ wasiBindingErrors.push(candidateError)
664
+ loadErrors.push(candidateError)
665
+ }
666
+ }
667
+ if (
668
+ !wasiBindingLoaded &&
669
+ forceWasi &&
670
+ !forceWasiError &&
671
+ !__napiWasiFlavorRequested
672
+ ) {
673
+ nativeBinding = requireNative()
674
+ }
675
+ if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
676
+ const error = new Error(
677
+ __napiWasiFlavorRequested
678
+ ? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
679
+ : 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
680
+ )
681
+ error.cause = createLoadErrorChain(wasiBindingErrors)
682
+ throw error
683
+ }
684
+ }
685
+
686
+ if (!nativeBinding) {
687
+ if (loadErrors.length > 0) {
688
+ const error = new Error(
689
+ `Cannot find native binding. ` +
690
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
691
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
692
+ )
693
+ // assign instead of the `new Error(message, { cause })` options form,
694
+ // which Node < 16.9 silently ignores
695
+ error.cause = createLoadErrorChain(loadErrors)
696
+ throw error
697
+ }
698
+ throw new Error(`Failed to load native binding`)
699
+ }
700
+
701
+ module.exports = nativeBinding
702
+ module.exports.Prover = nativeBinding.Prover
703
+ module.exports.version = nativeBinding.version
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "wickra-zk",
3
+ "version": "0.1.0",
4
+ "description": "Prove your backtest \u2014 zero-knowledge, on-chain-verifiable performance without revealing your data or strategy.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "license": "MIT OR Apache-2.0",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/wickra-lib/wickra-zk.git"
11
+ },
12
+ "engines": {
13
+ "node": ">= 20"
14
+ },
15
+ "napi": {
16
+ "binaryName": "wickra-zk",
17
+ "targets": [
18
+ "x86_64-unknown-linux-gnu",
19
+ "aarch64-unknown-linux-gnu",
20
+ "x86_64-apple-darwin",
21
+ "aarch64-apple-darwin"
22
+ ]
23
+ },
24
+ "files": [
25
+ "index.js",
26
+ "index.d.ts",
27
+ "LICENSE-MIT",
28
+ "LICENSE-APACHE"
29
+ ],
30
+ "scripts": {
31
+ "build": "napi build --platform --release",
32
+ "test": "node --test __tests__"
33
+ },
34
+ "devDependencies": {
35
+ "@napi-rs/cli": "^3.9.0"
36
+ },
37
+ "optionalDependencies": {
38
+ "wickra-zk-darwin-arm64": "0.1.0",
39
+ "wickra-zk-darwin-x64": "0.1.0",
40
+ "wickra-zk-linux-arm64-gnu": "0.1.0",
41
+ "wickra-zk-linux-x64-gnu": "0.1.0"
42
+ }
43
+ }