token_mint_v1.zk 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Circuit used to mint arbitrary coins for given token attributes.
  2. k = 11;
  3. field = "pallas";
  4. constant "TokenMint_V1" {
  5. EcFixedPointShort VALUE_COMMIT_VALUE,
  6. EcFixedPoint VALUE_COMMIT_RANDOM,
  7. EcFixedPointBase NULLIFIER_K,
  8. }
  9. witness "TokenMint_V1" {
  10. # TokenAttributes {
  11. Base token_auth_function,
  12. Base token_user_data,
  13. Base token_blind,
  14. # }
  15. # CoinAttributes {
  16. Base coin_public_x,
  17. Base coin_public_y,
  18. Base coin_value,
  19. Base coin_spend_hook,
  20. Base coin_user_data,
  21. Base coin_blind,
  22. # }
  23. }
  24. circuit "TokenMint_V1" {
  25. # Constrain the token authority function
  26. constrain_instance(token_auth_function);
  27. # Derive the token ID
  28. token_id = poseidon_hash(token_auth_function, token_user_data, token_blind);
  29. # Then constrain that the derived minted coin contains the token ID
  30. coin = poseidon_hash(
  31. coin_public_x,
  32. coin_public_y,
  33. coin_value,
  34. token_id,
  35. coin_spend_hook,
  36. coin_user_data,
  37. coin_blind,
  38. );
  39. constrain_instance(coin);
  40. # At this point we've enforced all of our public inputs.
  41. }