set_v1.zk 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # 2 ** k is the maximum nubmer of rows in the circuit.
  2. k = 13;
  3. # Section to declare constants used in the circuit.
  4. constant "Set_V1" {}
  5. # Witness is the inputs to the circuit, both public and private.
  6. witness "Set_V1" {
  7. # An instance of `Base` is a field element, which is a member of
  8. # the finite field F_p where
  9. # p = 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001
  10. #
  11. # Private input a user generates locally.
  12. Base secret,
  13. # Whether to lock the name.
  14. Base lock,
  15. # Whether to set in the canonical root name registry.
  16. Base root,
  17. # The name.
  18. Base key,
  19. # The value the name resolves to or
  20. # the next sub name registry (i.e. an account).
  21. Base value,
  22. }
  23. circuit "Set_V1" {
  24. # var = statement(var_or_witness1, var_or_witness2, ...);
  25. account = poseidon_hash(secret);
  26. # `constrain_instance` requires the value be provided as public input.
  27. constrain_instance(account);
  28. constrain_instance(lock);
  29. constrain_instance(root);
  30. constrain_instance(key);
  31. constrain_instance(value);
  32. # Check whether `lock` and `root` are of {0, 1}.
  33. bool_check(lock);
  34. bool_check(root);
  35. }
  36. # The mental model for what this circuit does.
  37. #
  38. # # Prove
  39. #
  40. # The prove API is essentially: prove(proving_key, witness) -> proof
  41. # The proving key, essentially, is the same across different witnesses and proofs
  42. # but unique per circuit.
  43. #
  44. # # Verify
  45. #
  46. # The verifying API is essentially: verify(verifying_key, proof, public_inputs) -> {T, F}
  47. # The verifying key is the same across different proofs but unique per circuit.
  48. #
  49. # For more info, you can try this zk intro to get a mental model:
  50. # https:#learn.0xparc.org/materials/circom/learning-group-1/circom-1