@ledgerhq/zcash-utils 2.1.0 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # @ledgerhq/zcash-utils
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0a94002: Build a transparent send without a UFVK. `buildTransaction` required a UFVK for
8
+ every flow, including a fully transparent one — which carries no shielded bundle
9
+ and reads no shielded key material. Its only key requirement is the
10
+ account-level transparent pubkey at `m/44'/coin'/account'`, used to derive the
11
+ internal change address and to verify each input's signing path. A wallet always
12
+ holds those bytes (they are the payload of the account xpub) whereas obtaining a
13
+ UFVK takes a user confirmation on the device, so the requirement forced a
14
+ viewing-key export on anyone spending public funds.
15
+
16
+ `ufvk` is now optional and a `transparentAccountPubkey` field accepts those 65
17
+ bytes (32-byte chain code ‖ 33-byte compressed pubkey) as hex. A transparent
18
+ send supplies the pubkey and omits the UFVK; both may be supplied together, in
19
+ which case the UFVK's transparent component is authoritative and the standalone
20
+ field only has to agree with it — a mismatch means key material from two
21
+ different accounts and fails the build rather than picking one. Every flow with
22
+ a shielded bundle (an Orchard spend, or a shielded recipient) still requires the
23
+ UFVK and now says so explicitly instead of failing deeper on a missing Orchard
24
+ component; `buildIronwoodTransaction`, whose bundle is always shielded, is
25
+ unchanged.
26
+
27
+ The two orchestrators now share one transparent-input decoder, so the
28
+ fund-safety check that ties each input's `(derivationScope, addressIndex)` to
29
+ its pubkey has a single implementation instead of two copies.
30
+
31
+ ### Patch Changes
32
+
33
+ - 0a94002: Refresh the dependency lock and collapse the duplicate `shardtree`. The lock
34
+ carried two copies of it — our own `0.6.2` plus the `0.7.0` that
35
+ `zcash_client_backend` links — so the commitment-tree types existed twice under
36
+ identical names and a witness built against one could not cross into the other.
37
+ Declaring `shardtree = "0.7"` leaves a single `0.7.1` copy that both sides share.
38
+
39
+ `pczt` moves to `0.9.3`, still pinned exactly: it defines the byte stream the
40
+ firmware parses, so it may only move as a deliberate, tested step and never as a
41
+ side effect of `cargo update`. `bitcoin` stays on the `0.32.x` maintenance line
42
+ for the same reason — the parallel `0.32.10x` feature line sorts higher and a
43
+ broad update would otherwise drift onto it — and the pin is now documented in
44
+ `Cargo.toml` so the next refresh keeps it.
45
+
46
+ The rest is a routine refresh of transitive dependencies. No Zcash protocol crate
47
+ moves: `zcash_primitives`, `zcash_keys`, `zcash_transparent`, `orchard` and
48
+ `zcash_client_backend` all stay where they were.
49
+
50
+ ## 2.1.1
51
+
52
+ ### Patch Changes
53
+
54
+ - 152aa4d: Accept V6 transactions when recomputing the txid on broadcast. `broadcastTransaction` derived the txid behind a guard that admitted only V5, which dates from when V5 was the only post-ZIP-225 format and survived the V6 builder, the Ironwood finalize path, and the Ironwood PCZT parse without being revisited. Only a transparent t→t send stays on V5 — any shielded send carrying an Ironwood bundle finalizes to V6 — so every shielded send failed with `expected V5 transaction, got V6` _after_ the device had already signed, and before the transaction was ever submitted. Nothing was lost: the txid is computed before the transaction is handed to the server, so the failing path returned without broadcasting.
55
+
56
+ The guard now admits V5 and V6 and still rejects pre-ZIP-225 formats, whose wire layout differs. The txid derives from the stream for both versions: `Transaction::read` dispatches on the version header and forwards its consensus-branch argument only to the V4 reader, so a V6 txid is computed exactly as a V5 one is and still matches the operation hash the sync path records for the same transaction.
57
+
58
+ Also derive Ironwood completed-shard roots locally instead of calling `GetSubtreeRoots`. The deployed Zaino does not serve that RPC for the Ironwood pool — it rejects `ShieldedProtocol::Ironwood` as an invalid shielded protocol value — so Ironwood witness computation now streams the pool's cmx leaves over `GetBlockRange` and reduces each completed shard to its root with the same level-encoded Sinsemilla hash the server would have applied. The pure witness assembly is unchanged and still shared with Orchard.
59
+
60
+ The pool's first block is located by binary-searching the commitment-tree frontier on leaf count rather than on whether the server's tree-state field is a non-empty string, so the search does not depend on how a server represents an empty frontier. Two bounds are checked before any block is fetched: the pool must be small enough for local reduction to stay interactive, and the scan range must be plausible, so a misresolved activation height fails fast instead of streaming a large share of the chain through a request that carries no timeout. Collected leaf counts are reconciled against the frontier, so a disagreement surfaces as an error rather than a silently wrong witness, and a note position past the anchor's leaf count is rejected up front. Callers should move back to `GetSubtreeRoots` once the server serves it for Ironwood.
61
+
3
62
  ## 2.1.0
4
63
 
5
64
  ### Minor Changes
package/index.d.ts CHANGED
@@ -207,9 +207,37 @@ export interface TransparentInputJs {
207
207
  */
208
208
  addressIndex: number
209
209
  }
210
+ /**
211
+ * Arguments for [`build_transaction`].
212
+ *
213
+ * **Invariant: supply `ufvk`, or `transparentAccountPubkey`, or both.** The two
214
+ * are declared independently optional because this struct crosses into JS,
215
+ * where "exactly one of" has no encoding — napi rejects a data-carrying enum —
216
+ * so the rule cannot live in the type. Supplying neither is refused up front,
217
+ * before any work, rather than deeper in the build. Which one a given flow
218
+ * needs is on each field below.
219
+ */
210
220
  export interface BuildTransactionParams {
211
221
  grpcUrl: string
212
- ufvk: string
222
+ /**
223
+ * Unified full viewing key of the spending account. Required by every flow
224
+ * that carries an Orchard bundle (an Orchard spend, or a shielded
225
+ * recipient); omit it only for a fully transparent send, which reads no
226
+ * shielded key material and takes its transparent account key from
227
+ * `transparentAccountPubkey` instead. Spending transparent funds therefore
228
+ * never requires exporting a viewing key from the device.
229
+ */
230
+ ufvk?: string
231
+ /**
232
+ * 130-char hex (65 bytes: 32-byte chain code ‖ 33-byte compressed pubkey):
233
+ * the account-level transparent pubkey at `m/44'/coin'/account'` — the
234
+ * payload of the account xpub, which a wallet already holds. Used to derive
235
+ * the internal change address and to verify each transparent input's
236
+ * signing path. Optional when `ufvk` is supplied (its transparent component
237
+ * serves, and this field then only has to agree with it); required for a
238
+ * transparent send that omits the UFVK.
239
+ */
240
+ transparentAccountPubkey?: string
213
241
  network?: string
214
242
  /**
215
243
  * 64-char hex (32 bytes): ZIP-32 seed fingerprint of the wallet seed,
@@ -256,7 +284,8 @@ export interface BuildTransactionResult {
256
284
  * Supports Orchard-source (Private→*) and transparent-source (Public→*)
257
285
  * flows. Halo 2 proof generation happens here for Orchard-bundle transactions
258
286
  * (~2-5 s first call, ~hundreds of ms thereafter thanks to the process-global
259
- * ProvingKey cache). Transparent-only transactions skip the Orchard prover.
287
+ * ProvingKey cache). Transparent-only transactions skip the Orchard prover, and
288
+ * need no UFVK — see `ufvk` / `transparentAccountPubkey` on the params.
260
289
  *
261
290
  * Note: unlike `finalize_transaction` (purely CPU-bound, offloaded via
262
291
  * `spawn_blocking`), this is an async orchestrator that interleaves gRPC
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/zcash-utils",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Native Zcash key derivation and shielded sync — Node.js (NAPI)",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",