Sharing some R&D from MontaQ Labs. Started as an experiment to see if homomorphic encryption was even practical on PVM. Turned out it is. We have a working contract on Passet Hub testnet. Figured this would be a good place to get feedback.
The Problem (you already know this)
Public blockchains have a privacy problem. Not a controversial take.
Your token balances? Public. Your salary from a DAO? Public. How you voted? Public. This is fine until it isn’t and for a lot of real-world use cases, it really isn’t.
The usual solutions are either:
-
ZK rollups (complex, latency, separate execution environment)
-
TEEs like SGX (trusted hardware = trusted Intel, which… yeah)
-
Privacy-focused chains (great, but now you’re not on Polkadot)
We wanted to try something different: what if regular PVM contracts could just do math on encrypted data?
What We Built
Summa is a Somewhat Homomorphic Encryption library for PVM. The key idea:
Encrypt(100) + Encrypt(50) = Encrypt(150)
The contract does the addition. It never sees 100, 50, or 150. Only the key holder can decrypt the result.
That’s it. That’s the trick.
We’re using Twisted ElGamal on JubJub. The “twisted” part means values are encoded in the exponent, which gives you additive homomorphism. You can add encrypted values, subtract them, multiply by public scalars all on-chain, all without decryption.
What you CAN’T do: multiply two encrypted values together. That would require fully homomorphic encryption, which is expensive and slow. We’re intentionally staying in “somewhat homomorphic” territory because it’s actually practical.
Cool, But Does It Work?
Yeah. We deployed a confidential token contract on Passet Hub testnet.
Contract: 0x68d64d2b645ff6da083ef35a90f3b3931ea20b29
Network: Passet Hub Testnet
What we tested:
-
Deployed the contract (~48KB, fits fine)
-
Registered public keys
-
Minted encrypted tokens
-
Did homomorphic balance updates
-
Decrypted client-side and got correct values
The moment where Enc(500) + Enc(100) decrypted to 600 was genuinely satisfying. Math works.
What Can You Actually Build With This?
Confidential Tokens
The obvious one. ERC-20 but balances are encrypted. Only you can see your balance. Transfers update encrypted values. Nobody watching the chain knows how much you have or how much you’re sending.
DAO Payroll
Your DAO pays contributors. Currently everyone can see who gets what. With Summa, the treasury contract maintains encrypted balances per contributor. Individual salaries are hidden, total spend is still auditable.
Sealed-Bid Voting
Submit Encrypt(votes) during voting period. Contract sums everything homomorphically. Decrypt the total only after deadline. No more watching how others vote and strategically following the herd.
Dark Pool Settlement
Combine with off-chain ZK for order matching. Summa handles the encrypted balance updates on-chain. Trade sizes stay private.
The Catch (There’s Always a Catch)
Let’s be honest about what this doesn’t do:
Still public:
-
Transaction graph — who transacts with whom is visible
-
Account existence
-
Total supply (though you could encrypt this too)
The range proof tax:
Here’s a fun attack: what if someone transfers Encrypt(-1000000) to themselves? Their balance goes up, yours wraps around. Classic underflow.
Solution: Bulletproofs-style range proofs. Every transfer proves 0 ≤ amount < 2^64 without revealing the amount.
Problem: range proof verification is expensive. We’re looking at ~500k gas per verification. Not cheap. This is probably the biggest blocker to making this practical for high-frequency use cases.
Decryption is… interesting:
Twisted ElGamal has a quirk. To decrypt, you solve a discrete log. For small values (like token balances), this is fast with Baby-Step Giant-Step lookup tables. For arbitrary values? Not happening.
We’ve optimized for 64-bit integers, which covers most financial use cases. Decryption happens client-side in milliseconds. But it’s worth knowing this constraint exists.
Why PVM?
Honest answer: because we wanted to see if it was possible.
PVM is new. The tooling is maturing. We wanted to push on it and see where it breaks. Turns out, it doesn’t break JubJub curve operations, SCALE-encoded ciphertexts, storage/retrieval of complex encrypted types, all works.
Also, there’s something appealing about privacy as a library rather than a separate chain. You’re still on Polkadot. You still get shared security. Your contracts just happen to work on encrypted data now.
What’s Next
Some things we’re thinking about:
-
Pallet-revive precompiles for range proof verification — could cut gas costs 10x
-
Multi-asset support — one contract, multiple confidential token types
-
Better decryption — precomputed BSGS tables for production
-
Maybe a ZK-rollup hybrid — Summa for state storage, Plonky2 for complex verification
But honestly, we’re at the “share it and see what happens” stage.
The Code
Everything’s open source:
Repo: GitHub - MontaQLabs/summa: Privacy-Preserving Smart Contracts on PVM via Twisted ElGamal Encryption
Structure:
-
summa/ — core crypto library (Twisted ElGamal, JubJub, etc.)
-
contracts/confidential-asset/ — the deployed token contract
-
tools/gen-ciphertext/ — CLI for encrypt/decrypt/keygen
Questions / Looking for Feedback
A few things we’d genuinely love input on:
-
Alternative schemes? We went with Twisted ElGamal because it’s simple and well-understood. Anyone explored other options that might work better on PVM?
-
Range proof costs. ~500k gas is rough. Ideas for bringing this down without sacrificing security?
-
Use cases we’re not thinking of? What would you build with homomorphic operations on-chain?
That’s Summa. It’s not going to solve every privacy problem, but for the subset of use cases where you need balances hidden and math done on-chain, it works today. On PVM. Without trusted hardware.