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