Skip to content

chrlyz/wrdhom_contracts

Repository files navigation

WrdHom: the auditable social-media platform

The internet has become increasingly manipulated by obscure and biased systems. Users don’t know why they see the content they see, and because of this, users can’t make conscious decisions about what settings to choose, or about how to behave in a platform, to personalize the content they see according to their true interests. As opposed to watching the content the owners of a platform want to amplify, while censoring other content.

Another issue is that users don’t know how moderation works, so moderation systems can hide their unfairness and arbitrarities behind a black box, and never improve or be accountable.

On top of this, users don’t own their accounts, so these can get shut down, by those obscure and arbitrary moderation systems, which can be very damaging, since it can disrupt a person’s support network; make people lose valuable data and connections; and decrease freedom of speech and the ability of people to coordinate in a fair and neutral environment.

All of this is very detrimental for our collective intelligence and creativity, and prevents us from making better decisions as a society, and from living better lives as free people.

We also would like to have more open and reliable APIs that behave more like protocols, so users and developers don’t need to worry about changes in the ownership of a platform, arbitrary business decisions, etc. Providing more guarantees to users and developers, and creating a more composable digital landscape.

We could and should try to improve legacy web2 platforms through better legislation, auditing, and accountability, but this is very challenging, because:

  • Even if they open source their code, there’s no way to guarantee that the code they release matches the code running on their servers,or to verify to what extend humans intervene arbitrarily.

  • Access to their APIs and data is expensive and restrictive.

  • They can find ways to trick audits.

  • The cost of permanently monitoring these platforms is prohibitive.

The WrdHom project aims to provide an alternative by building an open, auditable, and accountable platform by default. Guided by the following principles:

  • Users sign messages to authenticate their actions on the platform. This way users own their digital identity, since they own the keys to their accounts.

  • These signed messages are the input to zkPrograms that verify signatures, order actions on the platform, and generate proofs to update the state of the platform by following the established rules encoded in the zkPrograms. Then the associated smart-contracts verify that the proofs are valid and timestamp the moment of their inclusion.

  • The state of the platform is composed of on-chain and off-chain state. Our on-chain state lives in the Mina blockchain, and can be seen as the root of the whole state of our platform. This state is updated through the proofs generated by our zkPrograms, and can be used to verify that the off-chain state is valid.

  • The off-chain state lives in open and decentralized storage platforms like Filecoin. Data should be stored publicly and redundantly, so users have the guarantee that their data and the platform will remain available.

  • When users get content from the platform, the server responds with the content and the Merkle Map witnesses associated with each piece of content, so the client uses this to automatically calculate the roots for the state of the platform. The client also fetches the on-chain roots, and compares them with the calculated roots to make sure that the server response is valid according to our settings, and behaves as expected.

Mina also makes it possible to implement native zkApp-specific rollups, so we don’t have to make an on-chain transaction every time a user does something in the platform, which would be slow and expensive. Instead, we merge the proofs that we create to update the on-chain state, into a single proof that can be submitted to the network (e.g. The server receives 1,000 post requests, so it generates 1,000 proofs that then are merged, and the server uses the resulting proof to update the on-chain state for 1,000 posts in a single transaction). These proofs can also be generated in parallel, so the platform is able to handle an arbitrary number of user actions in the same amount of time, allowing the platform to scale.

So far four zkPrograms and four smart-contracts have been implemented to handle the root state of posts, Reactions, Comments, and Reposts; as well as the server that serves the auditable content and creates the proofs based on the actions of users; and the client that automatically audits these responses and provides a graphic user interface for users to interact with the platform.

Here is a video of a demo of the status of the project in January.

Testing and Deploying smart-contracts and zkPrograms

Clone

git clone git@github.com:chrlyz/wrdhom_contracts.git

Install

npm install

Config

Before building, running tests or deploying the project, set some parameters in the config.json of the project, and generate keys for the fee-payer and the PostsContract. To do this start by installing the zkApp-CLI:

npm install -g zkapp-cli

Then:

zk config

And go through the prompted instructions:

  1. Set the name to: posts.

  2. Set the Mina GraphQL API URL to: https://proxy.devnet.minaexplorer.com/graphql

  3. Set transaction fee to: 0.1

  4. Create a new fee-payer key or use one that you already have (just use keys that hold testnet tokens, don’t expose keys holding real tokens that have value, be careful with how you manage your keys).

  5. Make sure the fee-payer key has funds to make transactions (the zkApp-CLI will point you to a faucet to request testnet tokens in case you need to).

Build

npm run build

Run tests

npm run test -- -t 'PostsContract and Posts ZkProgram functionality'

Deploy

To deploy the PostsContract on the Berkeley testnet:

node build/src/posts/PostsDeploy.js

Similarly you can test and deploy the smart-contracts and zkPrograms for Reactions, Comments, and Reposts.

License

MIT

About

Mina smart contracts and zero-knowledge programs to power an auditable, open, user-centric, credibly-neutral, and composable social media platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages