arnaucube
arnaucube/miksi-corePublic Self-hosted repository
miksi-core/README.md
README.mdRaw
 1# miksi [![Test](https://github.com/miksi-labs/miksi-core/workflows/Test/badge.svg)](https://github.com/miksi-labs/miksi-core/actions?query=workflow%3ATest)
 2
 3*From Esperanto, **miksi** (miks·i): to mingle, to blend, to mix, to shuffle*
 4
 5![](miksi-logo00-small.png)
 6
 7
 8**Warning:** This repository is in a very early stage.
 9
10## Circuits tests
11```
12npm run test-circuits
13```
14
15## Smart Contracts tests
16```
17npm run test-sc
18```
19
20### Compile circom circuit & generate Groth16 verifier contract
21
22```
23./compile-circuits.sh
24```
25
26
27## Spec draft
28
29### Deposit
30- user generates a random `secret` & `nullifier`
31- computes the `commitment`, which is the Poseidon hash: `commitment = H(coinCode, amount, secret, nullifier)`, where:
32	- `coinCode`: code that specifies which currency is being used (`0`==ETH)
33	- `amount`: the amount to be deposited
34	- `secret`: random, private
35	- `nullifier`: random
36- get all the commitments from the SmartContract
37- build the MerkleTree with the getted commitments
38- add the new computed `commitment` into the MerkleTree
39- generate zkSNARK proof, where is proving:
40	- prover knows the `secret` & `nullifier` for the `commitment`
41	- the transition from `RootOld` (the current one in the Smart Contract) to `RootNew` has been done following the rules (only one addition, no deletion)
42- user sends ETH to the smart contract `deposit` call, together with the zkProof data
43
44Deposit circuit can be found [here](https://github.com/miksi-labs/miksi-core/blob/master/circuits/deposit.circom).
45
46### Withdraw
47- user gets all the commitments from the SmartContract
48- build the MerkleTree with the getted commitments
49- generate the siblings for the `commitment` of which the user knows the `secret` & `nullifier`
50- generate zkSNARK proof, where is proving:
51        - user knows a `secret` for a public `nullifier`
52        - which `commitment` is in the MerkleTree
53        - which MerkleTree `root` is the one that knows the SmartContract
54- if the zkProof verification passes, and the nullifier was not already used, the Smart Contract sends the ETH to the specified address
55
56Withdraw circuit can be found [here](https://github.com/miksi-labs/miksi-core/blob/master/circuits/withdraw.circom).
57