a16z / cicada Goto Github PK
View Code? Open in Web Editor NEWA protocol for private on-chain voting, implemented in Solidity.
License: GNU Affero General Public License v3.0
A protocol for private on-chain voting, implemented in Solidity.
License: GNU Affero General Public License v3.0
Hi! Congrats! Nice work! Here are a few initial ideas for gas-golfing. Hope you'll find them useful.
Toom-Cook multiplication: Currently, the mul512
function uses a schoolbook multiplication algorithm. I wonder if It would be more gas-efficient if we used a Toom-4 algorithm. Specifically, you split the 1024-bit integers exactly like you do now into 4 256-bit segments, then apply the Toom-4 algorithm. Generally, the rule of thumb is that after 300-bit or so, it is more efficient to use the Toom-Cook algorithm than the schoolbook multiplication algorithm. Though, not sure this observation also holds for the specific environment of EVM.
Verifying modular multiplication on-chain: Another possible way to computea*b=c mod N
(not sure if this is more gas-efficient than the current solution since it requires twice as long calldata than the current solution) is that the contract receives the quadruple (a,b,c,k)
(all of these values have 1024 bits) and checks the multiplication over the integers mod p
, i.e., whether a*b-c = k*N mod p
where p
should be a pseudorandom number, not necessarily a prime (e.g., BLOCKHASH
) not known to the prover prior calling any of the Cicada contract's functions (note that p
has roughly 256 bits, i.e., a single EVM word). Then the contract checks whether ((a mod p) * (b mod p)) - c mod p = (k mod p)*(N mod p)
. These mod p
operations can be computed efficiently using the 0x06 MOD
opcode on the constituent 256-bit words of a,b,c
, and k
.
Or rather something along these lines: A note on probabilistically verifying integer and polynomial products
0
or 1
, i.e., (8
group elements and the verifier's work is 5
modular multiplication. Using the distributive law, would not it be more efficient to rather prove A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.