@chainvue/verus-sapling 0.0.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.
Files changed (44) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +74 -0
  3. package/README.md +194 -0
  4. package/crate/pkg/package.json +17 -0
  5. package/crate/pkg/verus_sapling_prover.d.ts +71 -0
  6. package/crate/pkg/verus_sapling_prover.js +451 -0
  7. package/crate/pkg/verus_sapling_prover_bg.wasm +0 -0
  8. package/crate/pkg/verus_sapling_prover_bg.wasm.d.ts +15 -0
  9. package/dist/browser/grpcweb.d.ts +29 -0
  10. package/dist/browser/grpcweb.js +149 -0
  11. package/dist/browser/index.d.ts +23 -0
  12. package/dist/browser/index.js +23 -0
  13. package/dist/browser/lightwalletd-web.d.ts +36 -0
  14. package/dist/browser/lightwalletd-web.js +186 -0
  15. package/dist/browser/protobuf.d.ts +38 -0
  16. package/dist/browser/protobuf.js +115 -0
  17. package/dist/browser/prover-worker.d.ts +18 -0
  18. package/dist/browser/prover-worker.js +61 -0
  19. package/dist/browser/worker-prover.d.ts +38 -0
  20. package/dist/browser/worker-prover.js +51 -0
  21. package/dist/errors.d.ts +18 -0
  22. package/dist/errors.js +25 -0
  23. package/dist/hex.d.ts +11 -0
  24. package/dist/hex.js +32 -0
  25. package/dist/index.d.ts +33 -0
  26. package/dist/index.js +35 -0
  27. package/dist/lightwalletd.d.ts +113 -0
  28. package/dist/lightwalletd.js +99 -0
  29. package/dist/money.d.ts +23 -0
  30. package/dist/money.js +40 -0
  31. package/dist/parse.d.ts +45 -0
  32. package/dist/parse.js +129 -0
  33. package/dist/types.d.ts +29 -0
  34. package/dist/types.js +13 -0
  35. package/dist/wallet.d.ts +124 -0
  36. package/dist/wallet.js +179 -0
  37. package/dist/wasm.d.ts +91 -0
  38. package/dist/wasm.js +90 -0
  39. package/dist/zaddr.d.ts +19 -0
  40. package/dist/zaddr.js +107 -0
  41. package/package.json +90 -0
  42. package/proto/compact_formats.proto +62 -0
  43. package/proto/darkside.proto +124 -0
  44. package/proto/service.proto +172 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,74 @@
1
+ @chainvue/verus-sapling
2
+ Copyright (c) 2026 Robert Lech
3
+
4
+ Licensed under the Apache License, Version 2.0.
5
+
6
+ This package targets the Verus (VRSC) shielded protocol, which is stock Zcash
7
+ Sapling: unmodified circuit, byte-identical MPC parameters, and the stock
8
+ consensus branch id 0x76b809bb. Unlike @chainvue/verus-sdk, this package bundles
9
+ no VerusCoin source — the only Verus-specific value is that branch id.
10
+
11
+ --------------------------------------------------------------------------------
12
+ Bundled third-party software (statically linked into the published WASM artifact,
13
+ crate/pkg/verus_sapling_prover_bg.wasm)
14
+ --------------------------------------------------------------------------------
15
+
16
+ The WASM prover is compiled from the Rust crate in crate/ and links the following
17
+ libraries into its object code. Each remains under its own license.
18
+
19
+ Zcash Sapling protocol implementation — Electric Coin Company:
20
+ * sapling-crypto (MIT OR Apache-2.0) — Sapling circuit, Groth16 prover,
21
+ RedJubjub signatures, note encryption, bundle builder.
22
+ * zcash_note_encryption (MIT OR Apache-2.0) — ZIP-212 note encryption.
23
+ * bellman (MIT OR Apache-2.0) — Groth16 zk-SNARK proving system.
24
+ Copyright (c) Sean Bowe and the bellman contributors.
25
+
26
+ zkcrypto pairing / elliptic-curve libraries — Sean Bowe and the zkcrypto
27
+ contributors (all MIT OR Apache-2.0):
28
+ * bls12_381, jubjub, group, ff, pairing, pasta_curves
29
+
30
+ RedDSA / RedJubjub signature scheme — Henry de Valence and the Zcash Foundation
31
+ (all MIT OR Apache-2.0):
32
+ * reddsa, redjubjub
33
+
34
+ Utility libraries:
35
+ * blake2b_simd (MIT) — Copyright (c) Jack O'Connor
36
+ * subtle (BSD-3-Clause) — Copyright (c) Isis Lovecruft, Henry de Valence
37
+ * rand, rand_core, rand_chacha
38
+ (MIT OR Apache-2.0) — The Rand Project Developers
39
+ * hex (MIT OR Apache-2.0)
40
+ * serde_json (MIT OR Apache-2.0) — Copyright (c) David Tolnay, Erick Tryzelaar
41
+
42
+ The full text of the Apache License 2.0 is in LICENSE. Copies of the MIT and
43
+ BSD-3-Clause licenses accompany the respective upstream projects; see each
44
+ crate's repository (https://github.com/zcash, https://github.com/zkcrypto,
45
+ https://github.com/ZcashFoundation) for its license text and copyright notices.
46
+
47
+ Bundled protobuf definitions (proto/*.proto):
48
+ * The lightwalletd gRPC definitions (compact_formats.proto, service.proto,
49
+ darkside.proto) are the stock Zcash lightwalletd protos.
50
+ Copyright (c) 2019-2020 The Zcash developers. License: MIT (each file
51
+ retains its MIT header). Verus's lightwalletd fork does not modify them.
52
+
53
+ --------------------------------------------------------------------------------
54
+ Proving parameters — NOT bundled
55
+ --------------------------------------------------------------------------------
56
+
57
+ The Sapling proving parameters (sapling-spend.params ~47 MB, sapling-output.params
58
+ ~3.5 MB) are the canonical Zcash Sapling MPC parameters and are NOT included in
59
+ this package. Consumers obtain them separately and pass their bytes to the prover.
60
+ Verify integrity by SHA-256:
61
+
62
+ sapling-spend.params 8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13
63
+ sapling-output.params 2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4
64
+
65
+ These parameters are the output of the Zcash Sapling "Powers of Tau" and
66
+ parameter-generation ceremonies; see https://z.cash for provenance.
67
+
68
+ --------------------------------------------------------------------------------
69
+ Optional npm dependencies (installed under their own licenses, not bundled)
70
+ --------------------------------------------------------------------------------
71
+
72
+ * @grpc/grpc-js, @grpc/proto-loader (Apache-2.0) — used only by the optional
73
+ Node lightwalletd client (@chainvue/verus-sapling/lightwalletd). The package
74
+ root and the browser subpath pull in no gRPC runtime.
package/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # @chainvue/verus-sapling
2
+
3
+ <p>
4
+ <a href="https://github.com/chainvue/verus-sapling/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/chainvue/verus-sapling/actions/workflows/ci.yml/badge.svg"></a>
5
+ <a href="https://www.npmjs.com/package/@chainvue/verus-sapling"><img alt="npm" src="https://img.shields.io/npm/v/@chainvue/verus-sapling?color=cb3837&logo=npm"></a>
6
+ <img alt="node" src="https://img.shields.io/node/v/@chainvue/verus-sapling">
7
+ <img alt="types" src="https://img.shields.io/badge/types-included-3178c6?logo=typescript&logoColor=white">
8
+ <a href="./LICENSE"><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
9
+ <img alt="offline" src="https://img.shields.io/badge/network-none%20in%20signer-success">
10
+ </p>
11
+
12
+ > **Offline signing of Verus _shielded_ (Sapling) transactions** — `t→z`, `z→z`,
13
+ > `z→t`, with encrypted memos. It builds and signs bytes; your consumer
14
+ > broadcasts. **No full node on the signing host.**
15
+
16
+ Companion to [`@chainvue/verus-sdk`](https://www.npmjs.com/package/@chainvue/verus-sdk)
17
+ (transparent transactions). Where the SDK stays pure-TS and tiny, this package
18
+ adds the one thing shielded signing genuinely needs — a Sapling zk-prover —
19
+ compiled to WASM and kept opt-in.
20
+
21
+ - 🔐 **All three shielded flows:** shield (`t→z`), private send (`z→z`), deshield (`z→t`), each with a ZIP-302 memo.
22
+ - 🧾 **Real zk-proving in WASM** (`sapling-crypto` → Groth16/BLS12-381), RedJubjub spend-auth & binding signatures, note encryption.
23
+ - 🛰️ **Client-side note detection** — trial-decrypts compact blocks; no `z_listunspent`, no wallet daemon.
24
+ - 🌐 **Browser-ready** — a gRPC-web transport and Web Worker prover ship; a runnable MV3 extension broadcasts a private `z→z` from Chrome.
25
+ - 💰 **`bigint` satoshis end-to-end** — one checked crossing into float64, never a silent `number`.
26
+ - ✅ **Daemon-verified** — the byte-layout bar is acceptance by a real Verus daemon, not self-consistent tests.
27
+
28
+ > [!WARNING]
29
+ > Proven on **testnet**. Before mainnet or real funds, read
30
+ > [`SECURITY.md`](SECURITY.md) — the full spending key is present on the signing
31
+ > host (the same trust surface as a transparent WIF).
32
+
33
+ ## Contents
34
+
35
+ - [Install](#install) · [Quick start](#quick-start) · [How it works](#how-it-works)
36
+ - [Proving parameters](#proving-parameters) · [Backend](#backend-the-one-unavoidable-dependency)
37
+ - [Security](#security) · [Examples](#examples) · [Project layout](#project-layout) · [Contributing](#contributing)
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install @chainvue/verus-sapling
43
+ ```
44
+
45
+ The compiled WASM prover is shipped in the package (`crate/pkg/`). You supply the
46
+ two Sapling [proving parameters](#proving-parameters) (~50 MB, fetched once) at
47
+ runtime.
48
+
49
+ ## Quick start
50
+
51
+ Load the prover, then use the lightwalletd-driven orchestration. Chain data comes
52
+ through a `LightwalletdTransport`; the concrete Node gRPC client lives on the
53
+ `./lightwalletd` subpath (the package root pulls in **no** gRPC).
54
+
55
+ ```ts
56
+ import { detectNotes, buildShieldedSpend, initSapling } from '@chainvue/verus-sapling';
57
+ import { LightwalletdClient } from '@chainvue/verus-sapling/lightwalletd';
58
+
59
+ await initSapling(wasmBytes); // load the wasm module once
60
+ const client = new LightwalletdClient('lightwalletd:9077');
61
+
62
+ // 1. Find the wallet's own notes — no z_listunspent, no full node.
63
+ const notes = await detectNotes(client, detectProver, {
64
+ key: { dfvkHex }, // a viewing key is enough to scan (recommended)
65
+ fromHeight: walletBirthday, // toHeight defaults to the chain tip
66
+ });
67
+
68
+ // 2. Spend one detected note (z→z / z→t) with a memo.
69
+ const { hex } = await buildShieldedSpend(client, spendProver, {
70
+ note: { txid: notes[0].txid, outputIndex: notes[0].outputIndex, extskHex },
71
+ shieldedOutputs: [{ address, valueSats, memo }], // valueSats is a bigint
72
+ });
73
+ await client.sendTransaction(hex);
74
+ ```
75
+
76
+ `detectProver` / `spendProver` are thin callbacks you wire to the WASM builders
77
+ (`detectNotes` on the main thread; `spendShielded` in a Web Worker for the ~20 s
78
+ prove — see [`examples/extension`](examples/extension)). Memos are `string`,
79
+ ≤ 512 bytes. For `t→z` shielding, call the `shieldT2z` builder directly.
80
+
81
+ > **Scan with a viewing key, spend with the spending key.** `detectNotes` needs
82
+ > only a Diversifiable Full Viewing Key (`dfvkHex`); load the full spending key
83
+ > (`extskHex`) only to sign a spend. See [`SECURITY.md`](SECURITY.md).
84
+
85
+ ## How it works
86
+
87
+ The Rust crate (`crate/`) is compiled to WASM and owns the parts that must be
88
+ byte-exact: the **ZIP-243 sighash**, the **v4 transaction serializer**, Sapling
89
+ **proving**, the signatures, and note encryption. The TypeScript layer (`src/`)
90
+ stays thin: input validation, the `bigint` money invariant, the lightwalletd
91
+ transport, and address/key marshalling.
92
+
93
+ ### Verus = stock Zcash Sapling
94
+
95
+ Confirmed against Verus source and a live mainnet node: Verus shielded is
96
+ **stock Zcash Sapling** — unmodified `zcash/librustzcash` circuit, byte-identical
97
+ MPC parameters, stock consensus branch id `0x76b809bb`, version group id
98
+ `0x892f2085`, tx v4. Consensus is frozen at Sapling on **both** mainnet and
99
+ testnet (Canopy — which would gate ZIP-212 — is not in Verus's upgrade set), so
100
+ ZIP-212 enforcement is `Off`. The only Verus-specific value in the entire path is
101
+ that branch id, injected into the sighash. Even the lightwalletd wire protocol is
102
+ stock — `VerusCoin/lightwalletd`'s protos are byte-identical to Zcash's.
103
+
104
+ ### Backend: the one unavoidable dependency
105
+
106
+ - **`t→z` (shielding)** needs **no** commitment-tree witness — only the
107
+ transparent UTXOs you already fetch. The true "sign privately with zero extra
108
+ backend" case.
109
+ - **`z→z` / `z→t`** spend shielded notes, which need each note's Merkle **witness
110
+ + anchor** and **note detection**. Those come from a chain-scanning service —
111
+ a stock **Verus lightwalletd** (standard gRPC `GetBlockRange` / `GetTreeState`).
112
+ The signing host still runs no full node, but this service is required.
113
+ Browsers additionally need a gRPC-web proxy in front of it.
114
+
115
+ ## Proving parameters
116
+
117
+ The prover needs two parameter files — the **canonical Zcash Sapling MPC
118
+ parameters**, byte-identical for Verus. They are **not** bundled (≈50 MB would
119
+ bloat every install); fetch them once and pass their bytes to `initSapling` and
120
+ the prover.
121
+
122
+ | file | size | SHA-256 |
123
+ | --- | --- | --- |
124
+ | `sapling-spend.params` | ~47 MB | `8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13` |
125
+ | `sapling-output.params` | ~3.5 MB | `2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4` |
126
+
127
+ **Always verify the SHA-256.** Get them from any Zcash full node
128
+ (`zcutil/fetch-params.sh`), a local Verus install, or your own host — then cache
129
+ them (IndexedDB / Cache API in the browser, the filesystem in Node). Non-canonical
130
+ params produce proofs the daemon rejects.
131
+
132
+ ## Security
133
+
134
+ This library signs money and the spending key is present on the signing host.
135
+ [`SECURITY.md`](SECURITY.md) documents the trust model in full — what is
136
+ guaranteed (the key never crosses the network, is never logged, and is not in the
137
+ signed tx) and what is not (WASM memory is not zeroized; host/supply-chain
138
+ compromise). **Report vulnerabilities privately** via a GitHub security advisory,
139
+ never a public issue.
140
+
141
+ <details>
142
+ <summary><b>Daemon-verified on testnet</b> — txids</summary>
143
+
144
+ All three flows were built by this code and accepted by a Verus testnet daemon:
145
+
146
+ - **t→z** `1edf8aa6…6623` (native) and `d142edf8…a0ef` (built in WASM)
147
+ - **z→z** `53ea99fc…89feb` — fully private, recipient received 9.9999
148
+ - **z→t** `86951c8d…bd8a` — transparent recipient received 0.05
149
+ - **z→z, fully lightwalletd-sourced** `07e3b38e…f996` — every byte of chain data
150
+ from lightwalletd, signed in WASM, no full node
151
+
152
+ Note detection is cross-checked against consensus: the nullifier it predicts for
153
+ a note matches the on-chain nullifier of the spend that later consumed it,
154
+ byte-for-byte. The ZIP-243 serializer/sighash is regression-tested against
155
+ daemon-made golden vectors (`cargo test`).
156
+
157
+ </details>
158
+
159
+ ## Examples
160
+
161
+ - [`examples/extension`](examples/extension) — a runnable **MV3 browser
162
+ extension**: detect notes, read the inbox, and broadcast a private `z→z` from
163
+ Chrome, proving in a Web Worker.
164
+ - [`examples/messenger`](examples/messenger) — an end-to-end **shielded-memo
165
+ messenger**: framed messages carried in zero-value notes.
166
+
167
+ ## Project layout
168
+
169
+ ```
170
+ src/ TypeScript: validation, money, wallet orchestration, transport
171
+ browser/ gRPC-web transport + Web Worker prover (no external gRPC dep)
172
+ crate/ Rust: ZIP-243 sighash, v4 serializer, Sapling proving
173
+ pkg/ committed WASM build (so a fresh clone works without Rust)
174
+ proto/ stock Zcash lightwalletd gRPC definitions
175
+ examples/ runnable extension + messenger demos
176
+ test/ vitest suite (money, hex, protobuf, gRPC-web, wallet, zaddr, …)
177
+ ```
178
+
179
+ Docs: [SECURITY](SECURITY.md) · [CONTRIBUTING](CONTRIBUTING.md) ·
180
+ [RELEASING](RELEASING.md) · [NOTICE](NOTICE) ·
181
+ [Code of Conduct](CODE_OF_CONDUCT.md)
182
+
183
+ ## Contributing
184
+
185
+ Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). The gate is
186
+ `npm run build` → `npm run typecheck` → `npm test`, plus `cargo test` for the
187
+ crate. Commits follow [Conventional Commits](https://www.conventionalcommits.org/)
188
+ (they drive the automated release).
189
+
190
+ ## License
191
+
192
+ Apache-2.0. See [LICENSE](LICENSE). Third-party provenance for the WASM prover's
193
+ bundled Rust crates, the vendored lightwalletd protos, and the proving parameters
194
+ is in [NOTICE](NOTICE).
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "verus-sapling-prover",
3
+ "type": "module",
4
+ "description": "Sapling proving/signing core for Verus shielded transactions (t->z, z->z, z->t). Native + wasm32.",
5
+ "version": "0.0.0",
6
+ "license": "Apache-2.0",
7
+ "files": [
8
+ "verus_sapling_prover_bg.wasm",
9
+ "verus_sapling_prover.js",
10
+ "verus_sapling_prover.d.ts"
11
+ ],
12
+ "main": "verus_sapling_prover.js",
13
+ "types": "verus_sapling_prover.d.ts",
14
+ "sideEffects": [
15
+ "./snippets/*"
16
+ ]
17
+ }
@@ -0,0 +1,71 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Detect the wallet's own notes by trial-decrypting compact outputs (read path
6
+ * — no params, no proving). `spec_json` is the note-detection request (see
7
+ * `json_api::detect_notes_from_json`). Returns a JSON array of detected notes.
8
+ * Cheap (milliseconds); safe to call on the main thread.
9
+ */
10
+ export function detect_notes(spec_json: string): string;
11
+
12
+ /**
13
+ * Fully decrypt one incoming output (value + recipient + memo) with the
14
+ * wallet's viewing key. `spec_json` is the read request (see
15
+ * `json_api::read_note_from_json`). Returns a JSON object, or the string
16
+ * "null" if the output is not for this key. Cheap (no params, no proving).
17
+ */
18
+ export function read_note(spec_json: string): string;
19
+
20
+ /**
21
+ * Build + sign a t->z shielding transaction. `spec_json` is the t->z request
22
+ * (see `json_api::build_t2z_from_json`). Returns the transaction hex; the caller
23
+ * still has the daemon fill the transparent scriptSig (signrawtransaction).
24
+ */
25
+ export function shield_t2z(spec_json: string, spend_params: Uint8Array, output_params: Uint8Array): string;
26
+
27
+ /**
28
+ * Build + sign a z->z / z->t transaction that spends a shielded note. Complete
29
+ * after this (no transparent inputs) — broadcast directly.
30
+ */
31
+ export function spend_shielded(spec_json: string, spend_params: Uint8Array, output_params: Uint8Array): string;
32
+
33
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
34
+
35
+ export interface InitOutput {
36
+ readonly memory: WebAssembly.Memory;
37
+ readonly detect_notes: (a: number, b: number) => [number, number, number, number];
38
+ readonly read_note: (a: number, b: number) => [number, number, number, number];
39
+ readonly shield_t2z: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
40
+ readonly spend_shielded: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
41
+ readonly __wbindgen_exn_store: (a: number) => void;
42
+ readonly __externref_table_alloc: () => number;
43
+ readonly __wbindgen_externrefs: WebAssembly.Table;
44
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
45
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
46
+ readonly __externref_table_dealloc: (a: number) => void;
47
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
48
+ readonly __wbindgen_start: () => void;
49
+ }
50
+
51
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
52
+
53
+ /**
54
+ * Instantiates the given `module`, which can either be bytes or
55
+ * a precompiled `WebAssembly.Module`.
56
+ *
57
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
58
+ *
59
+ * @returns {InitOutput}
60
+ */
61
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
62
+
63
+ /**
64
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
65
+ * for everything else, calls `WebAssembly.instantiate` directly.
66
+ *
67
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
68
+ *
69
+ * @returns {Promise<InitOutput>}
70
+ */
71
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;