You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

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