couger-inc / cream Goto Github PK
View Code? Open in Web Editor NEWzkCREAM is zk-SNARK based anonymized voting application using a token mixer
Home Page: https://zkcre.am
License: GNU General Public License v3.0
zkCREAM is zk-SNARK based anonymized voting application using a token mixer
Home Page: https://zkcre.am
License: GNU General Public License v3.0
Error: *** Deployment Failed ***
"MACIFactory" ran out of gas (using a value you set in your network config or deployment parameters.)
* Block limit: 6721975 (0x6691b7)
* Gas sent: 6000000 (0x5b8d80)
Related to #66
Implement signUpMaci()
method.
Implement publishMessage()
method test
Seems ipfs-only-hash
is good to encode but does not decode hash.
circuits/vote.circom
template Vote(levels) {
signal input root;
signal input nullifierHash;
signal private input nullifier;
signal private input secret;
signal private input path_elements[levels];
signal private input path_index[levels];
// Output: tree root
signal output new_root;
component hasher = Hasher();
hasher.nullifier <== nullifier;
hasher.secret <== secret;
hasher.nullifierHash === nullifierHash;
component tree = MerkleTree(levels);
tree.leaf <== hasher.commitment;
tree.root <== root;
for (var i = 0; i < levels; i++) {
tree.path_elements[i] <== path_elements[i];
tree.path_index[i] <== path_index[i];
}
// output new_root hash
new_root <== tree.root;
}
It fails to prove when the user calls signUpMaci()
.
If we commented out both signal output new_root;
and new_root<==tree.root
however it fails circuits/ts/__tests__/Vote.test.ts test
.
Remove inputs (recipient, relayer, fee) from the circuit and change the withdraw method.
Implement MACI contract to CREAM
Lets add documentation / tutorials that show the average user how they can verify their votes after voting has ended using the MACI CLI tool.
https://github.com/appliedzkp/maci/blob/master/cli/README.md#demonstration
For certain use cases, different participants may have different voting weight; i.e. their votes count more or less than other participants. We'd like to implement the input of weighting data for different participant addresses during distribution of the voting tokens, as well as the automatic calculation of voting weights during tallying.
Possibly the easiest way to do this is to issue multiple tokens to each participant according to their weight. However, this may allow users to vote simultaneously for multiple candidates during a voting round. We can therefore split this functionality into 2 modes: one that allows simultaneous voting, and one that disallows simultaneous voting.
Add setMaci()
method to Cream.sol
.
Implementing MACI is the simplest way to start at this moment.
To improve
Adding prettier
is good enough to maintain the code format.
Currently, it will revert with onlyOwner modifier with
1) Contract: CreamFactory
"before all" hook in "Contract: CreamFactory":
Error: Returned error: VM Exception while processing transaction: revert Ownable: caller is not the owner -- Reason given: Ownable: caller is not the owner.
at Context.<anonymous> (test/CreamFactory.Test.ts:36:31)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
even though debugging all state looks no problem
console.log(await maci.owner())
console.log(await creamFactory.owner())
console.log(accounts[0])
result
0x627306090abaB3A6e1400e9345bC60c78a8BEf57
0x627306090abaB3A6e1400e9345bC60c78a8BEf57
0x627306090abaB3A6e1400e9345bC60c78a8BEf57
Due to Github action error
As mentioned at #47, we need to change the function parameter type.
The current limit for smart contracts is 24576 bytes, so the size needs to be adjusted accordingly.
The current size of the MACIFactory contract is as follows
cat build/contracts/MACIFactory.json | jq -r '.deployedBytecode' | wc -c
68345
CompileError: maci-contracts/sol/MACI.sol:3:1: ParserError: Source file requires different compiler version (current compiler is
0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.12;
^----------------------^
)
current compiler version 0.5.16
Should add end to end test with MACI and Cream.
The tentative sequence looks something like this:
sequenceDiagram
participant Contract Owner
participant MACIFactory
participant MACI
participant SignUpGateKeeper
participant SignUpToken
participant ConstantinitialVoiceCreditProxy
participant CREAMFactory
participant CREAM
participant VotingToken
participant Recipients
participant Voter
participant Voter'
participant Coordinator
Contract Owner ->> MACIFactory: deploy MACI factory
MACIFactory -->> Contract Owner: MACIFactory instance address
Contract Owner ->> CREAMFactory: deploy CREAM factory
CREAMFactory -->> Contract Owner: CREAMFactory instance address
Contract Owner ->> MACIFactory: transfer ownership to CREAMFactory (call transterOwnership())
opt MACI parameters
Contract Owner ->> CREAMFactory: set MACI parameters
end
Coordinator -->> Contract Owner: provide public key
loop create election
Contract Owner ->> VotingToken: deploy VotingToken
Contract Owner ->> SignUpToken: deploy SignUpToken
Contract Owner ->> SignUpGateKeeper: deploy SignUpGateKeeper contract
Contract Owner ->> ConstantinitialVoiceCreditProxy: deploy ConstantinitialVoiceCreditProxy contract
Contract Owner ->> CREAMFactory: (call createCream())
CREAMFactory ->> CREAM: deploy new CREAM instance
CREAM ->> MACIFactory: (call deployMACI())
MACIFactory ->> MACI: deploy new MACI instance
MACI -->> CREAMFactory: MACI instance address
CREAMFactory ->> CREAM: Link MACI and CREAM (call setMaci())
CREAMFactory -->> Contract Owner: CREAM instance address
Contract Owner -->> SignUpToken: transfer ownership to CREAM instance address
loop *TODO* sign up authentication
Contract Owner ->> CREAM: transfer VotingToken (call safeTransferFrom())
CREAM -->> Voter: VotingToken
end
loop mixer round
Voter -->> Voter: generate nullifier and secret (commitment)
Voter ->> CREAM: deposit VotingToken (call deposit())
Voter -->> Voter': Switch wallet account
end
loop maci round
Voter' ->> CREAM: sign up (call signUpMaci())
CREAM -->> MACI: (call signUp())
CREAM -->> Voter': SignUpToken
Voter' -->> Voter': Voter' creates encrypted message(s)
alt Single message submission
Voter' ->> MACI: vote ( call publishMessage() )
else Batch submission
Voter' ->> CREAM: vote ( call submitMessageBatch() )
CREAM ->> MACI: call publishMessage()
end
end
Note over CREAM, MACI: voting deadline
Coordinator ->> MACI: process messages (call batchProcessMessage())
Note left of Coordinator: coordinator tallies the votes and generates proofs
Coordinator ->> MACI: prove the correctness of vote tally ( call proveVoteTallyBatch() )
Coordinator ->> MACI: tally votes
MACI -->> Coordinator: tally.json
Note left of Coordinator: coordinator uploads the tally to IPFS
Coordinator ->> CREAM: call publishTallyHash()
Contract Owner ->> CREAM: approve tally result (call aprooveTally())
loop token withdrawal
Coordinator ->> CREAM: (call withdraw())
CREAM ->> Recipients: transfer VotingToken
end
end
It works on my local machine however, it will fail on github action.
For batchProcessMessage()
test
We have formatProofForVerifierContract
and toSolidityInput
do (nearly) same thing.
We should use one of them.
Relate to #52
Passing something like votingDurationSeconds
to contract's constructor()
to setup voting duration.
The motivation for adding this feature is to allow for batch processing after the deadline by having a deadline for voting.
For efficiency
To keep compatibility with other tools, make the contract directory in TypeScript.
CREAM's goal of implementing MACI is be able to pass recipient address as action something like this:
Command = Action(Address or NewKey)
Message = Encrypt([Command, Signature], Kw)
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.