How Midnight Verifies tokens Without Computing It
Part 4 of building with Midnight. Part 1 | Part 2 | Part 3 Full source: https://github.com/tusharpamnani/midnight-quadratic-voting Every article in this series has had one moment where Midnight for...

Source: DEV Community
Part 4 of building with Midnight. Part 1 | Part 2 | Part 3 Full source: https://github.com/tusharpamnani/midnight-quadratic-voting Every article in this series has had one moment where Midnight forces you to think differently. In Part 1 it was the witness pattern; you don't compute inside the circuit, you verify. In Part 3 it was the commitment scheme; you don't share secret values, you prove knowledge of them. This article has the same moment, and it's the clearest example yet. Quadratic voting requires computing floor(sqrt(tokens)) for every voter. If you're thinking like a Solidity developer, your instinct is to implement a square root function and call it inside the contract. On Midnight, that instinct is wrong, and understanding why leads you directly to one of the most elegant patterns in ZK circuit design. What Quadratic Voting Is and Why It's Hard in ZK Standard voting gives each participant one vote regardless of their stake. Token-weighted voting gives proportional power to t