simple.zk 597 B

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