Getting Started
This tutorial will help you install Unirep and run examples
Download Unirep Social
Clone Unirep Social source code from github
git clone https://github.com/vivianjeng/Unirep-Social.gitInstall packages
Install packages used in Unirep Social
yarn installBuild the Circom circuits
Build circom circuits and generate their constraints and verification keys and proving keys files in the build/ directory.
Also export smart contract verifiers to be deployed with Unirep and Unirep Social smart contract.
yarn buildTest
Test all cli commands
yarn test-cliIntegration test
yarn testExample cli commands workflow
1. Run a testing net
We use hardhat here as a blockchain developing environment.
2. Deploy Unirep smart contract and its verifiers
If we choose the first account, we use 0xac097...ff80 as our deployerPrivateKeyparameter
Open another terminal and run:
Then we use the Unirep Social contract's address to interact with.
3. Generate user's identity and identity commitment
4. User signs up
The user signs up with his identity commitment instead of his real identity.
5. Attester signs up
NOTE: Though user signs up requires a private key, private key is used to interact with smart contract but not link identity commitment and the account.
However, attesterSignupbind the account with attester id. Whenever the user wants to attest others, the user has to use the account he has registered for as an attester.
Therefore, users can sign up their identity commitments and their attester ids with different accounts to enjoy more privacy protection.
6. User generates epoch key and epoch key proof
The user can generate an epoch key with his identity and nonce.
7. Attester verify epoch key proof
8. User publish a post with an epoch key and proof
When a user wants to publish a post, he has to generate his reputation proof to prove that he has enough reputation to make a post. The proof also validate the epoch key.
9. Verify reputation proof of certain transaction
Users can use the reputation proof with the transaction hash to obtain snark circuit and its public inputs. Then user can call the on-chain verifier to verify the proof.
10. Attester upvotes to epoch key
To upvote an epoch key, we need another user with different identity. So we generate an identity and sign up the second user in the same way.
Upvote or downvote will cost attester's reputation. Therefore, attester also generates his own epoch key to receive negative reputation.
The proof can also be verified with verifyReputationProoffunction
11. Epoch transition
12. User state transition
13. User generate reputation proof from certain attester
After user state transition, the user can generate a proof to prove that he has reputation from certain attester.
14. Verify the reputation proof
Every user with the reputation proof can verify the proof and its claim.
User can optionally choose to prove among -mp, -mn, -md or -gp
But the inputs of verification should be identical with the claim of which user uses to generate the proof.
Last updated
Was this helpful?