@cloak.dev/sdk 0.2.6-staging.af2dfc0 → 0.2.6-staging.f92dd96

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
@@ -92,6 +92,46 @@ it. These notes are still found by `matchDepositNote`, `matchSwapRefundLeaf`, `m
92
92
  * With no sample (a relay that predates the header, or no relay reachable) every stamp falls back to
93
93
  `Date.now()`, the 0.2.5 behaviour.
94
94
 
95
+ ### Note Index v1 (restore without walking the chain)
96
+
97
+ Restore and note discovery read the relay's Note Index: one bulk, unauthenticated, cacheable feed
98
+ of every confirmed Cloak transaction that the relay indexes once, server side. A restore costs one
99
+ `getMultipleAccounts` (the pool tree accounts) instead of a `getSignaturesForAddress` /
100
+ `getTransaction` walk per user. Needs a relay with migration `26_note_index.sql` and
101
+ `NOTE_INDEX_PUBLISH_ENABLED=true`.
102
+
103
+ #### Added
104
+
105
+ * `recoverNotesFromIndex({ relayUrl, connection, programId, poolMints, viewingKeyNk,
106
+ ownerUtxoKeypair, cursor?, legacyCutoffLeaf?, concurrency?, onProgress?, signal? })` returns
107
+ `{ notes, atRisk, pending, cursor, stats }`. It downloads every page (the only request
108
+ parameters are the epoch and the page number, so the relay learns nothing about which notes are
109
+ the wallet's), opens each item locally, rebuilds the tree of every listed pool from the index's
110
+ own leaf stream and checks it against the chain, and computes spent status from the index's
111
+ nullifiers. No nullifier of the wallet is sent to the relay or the RPC.
112
+ * A note is returned only when it opens under the wallet's keys, its commitment recomputes with
113
+ `ownerUtxoKeypair.publicKey` (or a legacy key this recovery derived from `nk`), and it sits at its
114
+ leaf in a root-verified tree. Notes owned by the wallet keypair go to `notes`; legacy notes whose
115
+ owner key is derivable from `nk` go to `atRisk` with `legacyExposed: true`, never into `notes`.
116
+ Candidates that cannot be verified yet are counted in `pending` and carried in the cursor.
117
+ * The cursor (format v2) is JSON with no key material; persist it for incremental syncs. An epoch
118
+ change, a broken hash chain or an invalid cursor re-syncs from page 0; a head behind the cursor
119
+ throws the retryable `NoteIndexHeadBehindError`.
120
+ * `fetchNoteIndexHead`, `fetchNoteIndexPage`, the strict wire format (`parseNoteIndexPage`,
121
+ `parseNoteIndexItem`, `encodeNoteIndexPage`, `encodeNoteIndexItem`, `computeNoteIndexChain`,
122
+ `NoteIndexFormatError`, `NOTE_INDEX_PAGE_SIZE`, `NOTE_INDEX_NO_LEAF`) and their types. The golden
123
+ vector `note-index-golden-v1.hex` is shared with the relay.
124
+
125
+ #### Security notes
126
+
127
+ * The relay is untrusted. It can hide items but cannot inject, alter or forge a note. A hidden
128
+ nullifier can make a spent note look unspent, so restored notes must be spent through
129
+ `transact`, `partialWithdraw`, `fullWithdraw` or `swapUtxo`, which run `preflightNullifiers`
130
+ before proving. `buildTransactInstruction` and `submitTransactToRelay` document that they do not.
131
+ * Note Index reads never set the relay clock. Complete pages are immutable and cacheable for a
132
+ year, so a cached response replays a stale `x-cloak-server-time`; learning from it would date
133
+ later signed requests in the past.
134
+
95
135
  ### Fixed
96
136
 
97
137
  * A failed deposit no longer rebuilds the Merkle tree from chain (98a818b). A deposit spends no