Confidential smart contracts by example: Building a secret ballots

The Oasis Labs Team
Oasis Labs

--

One easy way to get started on the Oasis Devnet is to use some of our tutorials and sample code. To learn about confidential smart contracts we encourage you to view our tutorial for building a Secret Ballot Dapp.

The Secret Ballot DApp implements a simple voting system on the Oasis Devnet. By using confidential-preserving smart contracts, the DApp ensures everyone’s vote is private, with only vote totals released publicly. Additionally, the DApp hides the current vote totals of each candidate until the voting period has ended.

This is a great example of the type of use cases that are best achieved by using confidential smart contracts. If this type of application were deployed on Ethereum, anyone could see who voted for which candidate and learn vote totals at any time, since transaction data and contract state are publicly visible on Ethereum.

In comparison, with confidential smart contracts transaction data and smart contract state are automatically encrypted and accessible only by the smart contract. This means nobody can determine how users interact with the smart contract (i.e. who they voted for) and allows the smart contract to decide what information to release publicly (i.e. vote totals).

In addition to documentation and a simple demo to deploy a ballot yourself, you can also check out step-by-step instructions from CPO Noah Johnson here.

Next steps

If you’re excited about confidential smart contracts here are some things you can do after completing the tutorial.

Extend the Secret Ballot DApp

As we see blockchains used to enable and enhance civic engagement tools and in public elections, DApps such as secret ballots could serve as a powerful tool to build a system that is both secure and transparent — protecting the voting process more effectively than paper ballots ever could.

The current Secret Ballot DApp is a simple prototype intended for a tutorial. As a next step, you could modify the secret ballot DApp to add auditing capabilities, ensure people aren’t voting more than once, and verify identities of voters.

Build a new Privacy-Preserving Application

The tutorial teaches you the fundamentals of confidential smart contracts and Web3C so it can be used as the foundation for building new privacy-preserving applications.

You can extend the sample code to build more complex use-cases requiring confidentiality. Some examples include:

  • Financial auctions
  • Ticket sales
  • Polls and surveys
  • Private messaging applications

If you have feedback on our secret voting DApp, questions about how it works, or suggestions on use cases you want to learn about, let us know by going to feedback.oasiscloud.io. We can’t wait to hear from you and can’t wait to see what you build on the Devnet!

--

--