rlnv2-diff-signal.zk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. k = 13;
  2. field = "pallas";
  3. constant "RlnV2_Diff_Signal" {}
  4. witness "RlnV2_Diff_Signal" {
  5. Base identity_nullifier,
  6. Base identity_trapdoor,
  7. MerklePath identity_path,
  8. Uint32 identity_leaf_pos,
  9. Base x, # The message hash
  10. Base external_nullifier, # Hash(Epoch, RLN identifier)
  11. Base message_id,
  12. Base user_message_limit,
  13. Base epoch,
  14. }
  15. circuit "RlnV2_Diff_Signal" {
  16. constrain_instance(epoch);
  17. constrain_instance(external_nullifier);
  18. less_than_strict(message_id, user_message_limit);
  19. # Identity secret hash
  20. a_0 = poseidon_hash(identity_nullifier, identity_trapdoor);
  21. a_1 = poseidon_hash(a_0, external_nullifier, message_id);
  22. # y = a_0 + x * a_1
  23. x_a_1 = base_mul(x, a_1);
  24. y = base_add(a_0, x_a_1);
  25. constrain_instance(x);
  26. constrain_instance(y);
  27. internal_nullifier = poseidon_hash(a_1);
  28. constrain_instance(internal_nullifier);
  29. identity_commitment = poseidon_hash(a_0, user_message_limit);
  30. root = merkle_root(identity_leaf_pos, identity_path, identity_commitment);
  31. constrain_instance(root);
  32. }