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.

52 lines
1.1 KiB

  1. pragma solidity ^0.6.0;
  2. import './verifier.sol';
  3. contract Miksi {
  4. Verifier verifier;
  5. constructor( address _verifierContractAddr) public {
  6. verifier = Verifier(_verifierContractAddr);
  7. }
  8. mapping(uint256 => Deposit) deposits;
  9. struct Deposit {
  10. uint256 coinCode;
  11. uint256 amount;
  12. }
  13. function deposit(
  14. uint256 coinCode,
  15. uint256 amount,
  16. uint256 commitment
  17. ) public {
  18. deposits[commitment] = Deposit(coinCode, amount);
  19. }
  20. function getDeposit(
  21. uint256 commitment
  22. ) public view returns (uint256, uint256) {
  23. return (
  24. deposits[commitment].coinCode,
  25. deposits[commitment].amount
  26. );
  27. }
  28. function withdraw(
  29. uint256 commitment,
  30. uint[2] memory a,
  31. uint[2][2] memory b,
  32. uint[2] memory c
  33. ) public {
  34. uint256[3] memory input = [
  35. deposits[commitment].coinCode,
  36. deposits[commitment].amount,
  37. commitment
  38. ];
  39. require(verifier.verifyProof(a, b, c, input), "zkProof withdraw could not be verified");
  40. // zk verification passed, proceed with the withdraw
  41. }
  42. }