Draft: Add PIR-based spendability checking and witness fetching#15
Draft
p0mvn wants to merge 1 commit into
Draft
Draft: Add PIR-based spendability checking and witness fetching#15p0mvn wants to merge 1 commit into
p0mvn wants to merge 1 commit into
Conversation
Orchard notes are not spendable until the shard-tree scanner catches up to the block that contains them. For wallets restoring from seed or lagging behind the chain tip, this can mean waiting hours before funds are usable. Private Information Retrieval lets the wallet query a server to (1) learn which notes have been spent and (2) obtain note commitment tree witnesses — all without revealing which notes belong to the wallet. This makes funds spendable before the scanner completes, dramatically improving the restore experience. Made-with: Cursor
This was referenced Apr 10, 2026
p0mvn
commented
Apr 10, 2026
| spendingKey: spendingKey | ||
| ) | ||
| } catch { | ||
| logger.info("[PIR-DEBUG] createProposedTransactions: status=\(isSyncing), usePIRWitnesses=\(proposal.pirWitnessConfig?.usePIRWitnesses ?? false), pirServerURL=\(proposal.pirWitnessConfig?.serverURL ?? "nil")") |
Author
There was a problem hiding this comment.
Note: logs are intentionally left for now for ease of retesting. Tracking to remove before opening up in the upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use Private Information Retrieval to detect spent notes and fetch witnesses before sync completes, giving users early visibility into pending spends. Adds the full data flow (SDK synchronizer interface, Root reducer orchestration, shared state), a PIR setup screen in Advanced Settings with a persisted user toggle, and pending-spend UI treatment in transaction rows.
Motivation
During normal wallet sync, Orchard notes are not spendable until the
shard-tree scanner has processed enough blocks to construct a Merkle
authentication path for each note. For wallets that are catching up after
being offline, this can mean a significant delay before funds become
available.
Nullifier PIR (Private Information Retrieval) sidesteps this by querying
an external server for two pieces of information:
wallet mark notes as spent before the scanner confirms it.
needed to spend a note, so the wallet does not need to wait for its
local shard to be fully scanned.
Together, these allow the wallet to display accurate spendable balances
and build transactions within seconds of startup, rather than waiting for
a full scan.
Design Assumptions
Video Demo
https://screen.studio/share/tm6q8yUz
Related PRs
This code review checklist is intended to serve as a starting point for the author and reviewer, although it may not be appropriate for all types of changes (e.g. fixing a spelling typo in documentation). For more in-depth discussion of how we think about code review, please see Code Review Guidelines.
Author
Reviewer