@str4d and I have previously done some work on sketching out a protocol for airdrops, proof-of-balance, or stake-weighted polling: Draft ZIP: Airdrops and Stake-weighted Polling - HackMD
Thanks for the link. It looks close to the same idea and supports weighted polling. It uses a new circuit and only works with Orchard.
It’s not really specific to Orchard; an almost identical protocol works for Sapling. It’s just stated for Orchard in that draft.
If it were applied to Sapling you would either need another phase-2 Groth16 trusted setup, or you can run Halo 2 on BLS12-381 or any suitable curve that has Jubjub as an embedded curve. (This does not need to be pairing-friendly or in a cycle, for example you can use Bröker and Stevenhagen’s method to construct one.) Sapling uses BLAKE2s-256 to derive its nullifiers and that hash function can be easily domain-separated, so defining \mathsf{DeriveAlternateNullifier} for Sapling is straightforward.
On the other hand, I don’t think it’s unreasonable to just require moving funds to Orchard in order to vote / prove balance using them.
The reason why the protocol Str4d and I drafted uses a new circuit, is that without that you have to reveal the nullifiers of the notes being proven. Those are the same between every instance of the voting / proof-of-balance protocol, and when the notes are eventually spent. Therefore, votes in different polls / proofs-of-balance that rely on the same note can be linked with each other and with the transaction that spends that note. That’s quite a serious privacy problem, I think: you could argue that the linkage with spends could be mitigated by renewing those notes using a fully shielded transaction sending to self, but that cannot mitigate linkage between votes/proofs that run concurrently.
The protocol in our draft does not have this problem, because nullifiers in different domains cannot be linked. In fact I think it is one of the simplest designs that can address this problem while still being able to run concurrent polls / proofs-of-balance, and without requiring actual spends as part of the protocol.
Oh, I just meant that there would be a need for a new trusted setup with Sapling.
That’s great. I didn’t think of that.
The linkage between votes is an interesting problem but as you said, it is a problem with concurrent polls, isn’t it? Otherwise, we can reshield the funds and get fresh nullifiers.
To clarify the idea of reshielding. Would this mean an extra transaction would have to occur or could this spend occur as part of the receipt?
It could be done as part of a step in the protocol.
If the anchor heights required for the proofs for multiple polls are all at some (different) times in the past, you wouldn’t be able to do that, and I think that for most purposes announcing a past anchor height will be desirable, to avoid the flash loan poll exploit.
In fact, for fairness in polling, I think that the anchor height for each separate poll should be determined by an algorithm like:
- The poll is announced, specifying a block height in the future (
POLL_GOVERNING_HEIGHT), and the current block height (POLL_ANNOUNCEMENT_HEIGHT) is recorded. - Once the chain tip is at or greater than
POLL_GOVERNING_HEIGHT + 100, the hash of the block atPOLL_GOVERNING_HEIGHTis used to seed a deterministic PRNG. That PRNG is used to uniformly choose a number in the range 1…=100000 (POLL_HEIGHT_OFFSET). - Voters in the poll must use the anchor at height
POLL_ANNOUNCEMENT_HEIGHT - POLL_HEIGHT_OFFSETto make their votes.
This guarantees that the result of the poll will be decided by the holders as of a random block some time in the ~3 months prior to when the poll was announced. This cannot be manipulated via a flash loan, and encourages users who want to be involved in governance to consistently keep their funds in the Orchard pool for long periods of time.
I think it would be unfair to people who actively trade ZEC. IMO the flash loan exploit can be avoided by a randomized height as suggested earlier (Coin Voting / Shielded Airdrop / Proof of Balance - #11 by hanh)
Would this system allow for an allocation of the block reward to be paid out to users with funds held in orchard pool, say once a month?
If 10% of the block reward was set aside for this, then it would be a good incentive to not only migrate funds to orchard pool, but also for miners to hold onto mined ZEC
It’d be like a monthly airdrop so this should work too. However, the claimer must resubmit a proof every month.
@hanh at the most recent meeting, the @ZcashGrants Committee voted to approve Milestone 1 of this proposal, for a total of $40,000 and has requested that you provide monthly updates via the forum in this thread. Please amend the grant to reflect this on the Submittable platform.
(Speaking just for myself and not for ECC or as a ZIP Editor.)
This is only a thought exercise on how this functionality could be achieved, not whether we should do it.
It’s not necessary to require proofs of balance (which have potential privacy weaknesses when used for this purpose) in order to claim interest for holding funds in the Orchard pool. To do that, we could alter the protocol as follows:
Define the “compounded value” of an Orchard note at a given block height to be 1 at the activation height of this protocol change, and to be multiplied at each block by (1 + the per-block interest rate).
The per-block interest rate can vary; at each block, we subtract \mathsf{ceiling}(\mathsf{perBlockInterestRate} \cdot \mathsf{orchardChainValuePoolBalance}) from the block subsidy and add it to \mathsf{orchardChainValuePoolBalance}, in order to account for the increase in value of Orchard notes relative to other ZEC notes/UTXOs.
(Due to rounding both here and in the circuit below, the Orchard chain value pool balance becomes a slight overestimate of the actual sum of values of Orchard notes, but since a zatoshi is very small in practical value, that might be acceptable.)
Define the “anchor height” of a note output in a transaction with a given anchor, to be the height of the block with final treestate referenced by that anchor.
The relation between compounded values and note positions is public. Find a way to check this relation in zk, for example:
- recompute the note commitment tree so that it commits to both note commitments and compounded values; or
- include the compounded value in each new note commitment input and validate it on the output side of the circuit.
Change the Orchard Action circuit so that in each Action, the net value balance input to \mathsf{ValueCommit^{Orchard}_{rcv}} becomes \mathsf{floor}\!\left(\frac{\mathsf{compoundedValue^{new}}}{\mathsf{compoundedValue^{old}}}\right) \cdot \mathsf{v^{old}} - \mathsf{v^{new}}.
The idea here is that the value of each Orchard note relative to other ZEC notes/UTXOs is multiplied by 1 + \mathsf{blockInterestRate} each block, but this is only claimed when the note is spent. It’s equivalent to splitting ZEC into two currencies that are pegged to each other, with the peg being deflationary on the Orchard side. (I make no comment on the economic consequences of that, which could be quite substantial.)
Notice that this could easily be generalized to keep track of arbitrary exchange rates between pairs of ZSAs or other subsets of notes, as long as there is some way to agree on them as part of consensus.
If I’m understanding correctly, would this effectively double the number of orchard transactions? I.e. everytime you transaction there is a redemption transaction on interest earned? Could be problematic down the road, maybe
No; the user experience of this would just be their balance increasing over time in proportion to their holdings; if you receive X ZEC at time 1, then you have X + interest ZEC available to spend at time 2. It would effectively just redirect part of the issuance to the holders by decreasing the block reward; the interest would essentially be “newly issued” (as a fraction of the accumulated value of the decrease in the block reward) at the moment that it is spent.
Thanks for clarity on that
Another way to do it is to have the note commit to a fixed-point representation of \frac{\mathsf{v}}{\mathsf{compoundedValue}}. For example, suppose that we start out with \mathsf{compoundedValue} as 100000000, representing 1.0 in fixed point. Each time we read the value from an Orchard note we multiply it by \frac{\mathsf{compoundedValue}}{100000000}, and each time we write the value we multiply it by \frac{100000000}{\mathsf{compoundedValue}}. The effect is essentially the same as before, except that now we don’t have to keep track of the compounded value as part of the commitments. All existing notes automatically have the correct value at the activation block for this change.
(I haven’t checked that this is sufficient precision, so treat this with a pinch of salt with regard to the details.)
Quick Update: Working on the voting workflows and the protocol.
Posted to Orchard Proof of Balance / Domain Nullifier
Copied here (but with some loss of formatting
)
Purpose
The Orchard Proof of Balance is a mechanism by which
one can establish possession of a certain amount of funds
in the Orchard Pool with complete privacy.
- The proof is tied to a given height, the snapshot height (SH)
- coins acquired after SH cannot be used
- coins spent after SH can be used
- The proof is scoped to a given Election
- proofs from different elections cannot be linked
- coins can be used in different Elections
- coins cannot be used twice in the same Election
Example
The organizer publishes the Election definition. It uniquely
identifies a “Domain” based on the organizer:
- url
- election name
- snapshot height
- etc.
Proofs are only valid for a particular Domain.
Election Definition
url = "https://election.methyl.cc"
name = "Test Election 2024"
spapshot_height = 2462430
lockdown_height = 2460000
closing_height = 2460000
msg_size = 64
cmx_root="063121a1fed23f154e18d9dfc70a13867f295207fd3c59d0e3f86615b857d332"
nf_root="deed4e046cafeadc541328fe879f3997cb404e4c7c3daf7c9825b653b3015933"
Prover
The prover downloads the election definition from the
website of the Election Organizer.
Download Blockchain Data (Orchard Actions)
The first step is to download the Orchard actions from
the blockchain by connecting to a lightwalletd server.
The tool only saves nullifiers and note
commitments of the Orchard Actions.
The rest is ignored. The output is the actions.bin file.
:::info
This is the only step that needs to be done online.
:::
[hanh@archlinux election-board]$ ./target/release/election-board
>> download http://127.0.0.1:9067
[2024-04-09T04:10:11Z INFO election_board::lwd_client] LightdInfo { version: "", vendor: "ECC LightWalletD", taddr_support: true, chain_name: "main", sapling_activation_height: 419200, consensus_branch_id: "c2d6d0b4", block_height: 2464714, git_commit: "e4ead2505394c402b3c1f78a8a9f7a77e6eae984", branch: "", build_date: "2024-02-20", build_user: "hanh", estimated_height: 2464715, zcashd_build: "v1.6.0", zcashd_subversion: "/Zebra:1.6.0/" }
[2024-04-09T04:10:11Z INFO election_board::lwd_client] height 1688000
[2024-04-09T04:10:11Z INFO election_board::lwd_client] height 1689000
[2024-04-09T04:10:11Z INFO election_board::lwd_client] height 1690000
...
Build Reference Data
From the actions file, use the tool to precompute the
Merkle Trees. This takes a while because of the amount
of hashing required. But this may be shared.
>> build-reference-data
[2024-04-09T04:24:32Z INFO election_board] Splitting Actions File...
[2024-04-09T04:27:13Z INFO election_board] Building Note Commitment Tree...
[2024-04-09T04:27:41Z INFO election_board::cmx] Hash Count 24363540
[2024-04-09T04:31:22Z INFO election_board::cmx] Hash Count 12181770
[2024-04-09T04:33:12Z INFO election_board::cmx] Hash Count 6090885
[2024-04-09T04:34:09Z INFO election_board::cmx] Hash Count 3045443
[2024-04-09T04:34:37Z INFO election_board::cmx] Hash Count 1522722
...
[2024-04-09T04:35:04Z INFO election_board::cmx] Hash Count 1
[2024-04-09T04:35:04Z INFO election_board::cmx] Hash Count 1
[2024-04-09T04:35:04Z INFO election_board::cmx] Hash Count 1
[2024-04-09T04:35:05Z INFO election_board] Building Nullifier Tree Leaves...
[2024-04-09T04:36:37Z INFO election_board] Building Nullifier Tree...
[2024-04-09T04:37:32Z INFO election_board::cmx] Hash Count 48727081
[2024-04-09T04:44:56Z INFO election_board::cmx] Hash Count 24363541
[2024-04-09T04:48:37Z INFO election_board::cmx] Hash Count 12181771
[2024-04-09T04:50:28Z INFO election_board::cmx] Hash Count 6090886
[2024-04-09T04:51:24Z INFO election_board::cmx] Hash Count 3045443
[2024-04-09T04:51:52Z INFO election_board::cmx] Hash Count 1522722
...
[2024-04-09T04:52:20Z INFO election_board::cmx] Hash Count 1
[2024-04-09T04:52:20Z INFO election_board::cmx] Hash Count 1
[2024-04-09T04:52:20Z INFO election_board::cmx] Hash Count 1
Create Proof of Balance
Finally, this step uses the zec.db database file (from Ywallet)
to retrieve your notes.
Here we create a proof for the funds in account 1 and save it
to pob.bin. The proof must be sent to the election
organizer for verification and count.
>> create-proof pob.bin 1
cmx anchor: 063121a1fed23f154e18d9dfc70a13867f295207fd3c59d0e3f86615b857d332
nf anchor: deed4e046cafeadc541328fe879f3997cb404e4c7c3daf7c9825b653b3015933
The values of the anchors must match the ones in the election
definition file.
Organizer
The organizer collects the proofs and verifies them. The proofs can
be verified by anyone as they don’t contain any sensitive
information besides the amount.
Verify Proof of Balance
The tool can be used to verify the proof. It does not require
any external data. Verification only takes a few seconds.
:::success
No blockchain data is needed!
:::
>> verify-proof pob.bin
ZK Proof verified!
Spending Signature verified!
Binding Signature verified!
Verified 0.02000000 ZEC
Technical Details
The design follows Air drops, Proof-of-Balance, and Stake-weighted Polling
:::warning
This is of proof of concept and further work is required before
making it production ready. Do not use with real coins.
:::
This is wonderful work thank you!
Much better than my temporary “solution” of voting by sending shielded coins to burn addresses representing different options (presumably those with larger stakes would be willing to burn more coins in order to vote for something they deemed important).