simple.zk 605 B

12345678910111213141516171819202122232425
  1. k = 13;
  2. constant "Simple" {
  3. EcFixedPointShort VALUE_COMMIT_VALUE,
  4. EcFixedPoint VALUE_COMMIT_RANDOM,
  5. }
  6. witness "Simple" {
  7. Base value,
  8. Scalar value_blind,
  9. }
  10. circuit "Simple" {
  11. # Pedersen commitment for coin's value
  12. vcv = ec_mul_short(value, VALUE_COMMIT_VALUE);
  13. vcr = ec_mul(value_blind, VALUE_COMMIT_RANDOM);
  14. value_commit = ec_add(vcv, vcr);
  15. # Since the value commit is a curve point, we fetch its coordinates
  16. # and constrain them:
  17. value_commit_x = ec_get_x(value_commit);
  18. value_commit_y = ec_get_y(value_commit);
  19. constrain_instance(value_commit_x);
  20. constrain_instance(value_commit_y);
  21. }