Code Monkey home page Code Monkey logo

cream's People

Contributors

dependabot[bot] avatar exfinen avatar kazuakiishiguro avatar thelostone-mc avatar weil-yumiso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cream's Issues

[contract] MACIFactoryContract need to reduce gas

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)

[circuit/contract] signUpMaci fails

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.

Allow weighted votes

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.

[contract] deployMaci() method has to have onlyOwner modifier

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

Reduce contract size for deployment

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

[solc] Need to upgrade compiler version

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

Add e2e test

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

[New feature] Add voting deadline for contracts

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.

[contract] JS -> TS

To keep compatibility with other tools, make the contract directory in TypeScript.

Create own domainobjs for customized command

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.