signal.zk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. k = 13;
  2. field = "pallas";
  3. constant "RlnSignal" {}
  4. witness "RlnSignal" {
  5. Base secret_key,
  6. MerklePath identity_path,
  7. Uint32 identity_leaf_pos,
  8. # These are public so have to be properly constructed
  9. Base message_hash, # x
  10. Base epoch,
  11. Base rln_identifier,
  12. }
  13. circuit "RlnSignal" {
  14. constrain_instance(epoch);
  15. constrain_instance(rln_identifier);
  16. constrain_instance(message_hash);
  17. # This has to be the same constant used outside
  18. identity_derivation_path = witness_base(11);
  19. nullifier_derivation_path = witness_base(12);
  20. identity_commit = poseidon_hash(identity_derivation_path, secret_key);
  21. root = merkle_root(identity_leaf_pos, identity_path, identity_commit);
  22. constrain_instance(root);
  23. external_nullifier = poseidon_hash(epoch, rln_identifier);
  24. a_1 = poseidon_hash(secret_key, external_nullifier);
  25. internal_nullifier = poseidon_hash(nullifier_derivation_path, a_1);
  26. constrain_instance(internal_nullifier);
  27. y_a = base_mul(a_1, message_hash);
  28. y = base_add(y_a, secret_key);
  29. constrain_instance(y);
  30. }