Agent skill
compact-core:privacy-disclosure
Use when encountering "potential witness-value disclosure" compiler errors, implementing commit-reveal patterns, working with persistentCommit/transientCommit vs persistentHash/transientHash, or designing privacy-preserving circuits with proper witness protection.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/privacy-disclosure
SKILL.md
Privacy & Disclosure
Essential guidance for Midnight's privacy model: when disclosure is required, commitment patterns, and witness protection.
The Disclosure Rule
Witness values cannot flow to public outputs without explicit disclose().
The compiler tracks all witness-derived values through your code. If a value touches any of these "disclosure triggers", you must wrap it with disclose():
| Trigger | Why Disclosure Required |
|---|---|
| Ledger storage | Data on-chain is public |
| Circuit return | Return values go to TypeScript |
| External contract | Data leaves your contract boundary |
| Comparison operations | Comparisons can leak information |
Quick Decision Tree
Is the value derived from a witness?
├── No → No disclosure needed
└── Yes → Does it flow to:
├── Ledger write → disclose() required
├── Circuit return → disclose() required
├── Comparison (==, <, >) → disclose() required
└── Commitment (transientCommit/persistentCommit) → Safe, no disclosure
Safe vs Unsafe Operations
| Operation | Safe? | Why |
|---|---|---|
persistentCommit(x) |
✅ Safe | Hides value with nonce |
transientCommit(x) |
✅ Safe | Hides value with nonce |
persistentHash(x) |
❌ Unsafe | No nonce, can be brute-forced |
transientHash(x) |
❌ Unsafe | No nonce, can be brute-forced |
Common Patterns
Commit-Reveal
witness get_secret(): Field;
// Phase 1: Commit
export circuit commit(): Bytes<32> {
const secret = get_secret();
return persistentCommit(secret); // Safe: commitment hides secret
}
// Phase 2: Reveal (requires disclosure)
export circuit reveal(): Field {
const secret = get_secret();
return disclose(secret); // Explicit: user knows this reveals
}
Nullifier Pattern
witness get_secret(): Field;
export circuit spend(commitment: Bytes<32>): Bytes<32> {
const secret = get_secret();
// Verify knowledge of secret
assert persistentCommit(secret) == commitment, "Invalid commitment";
// Generate nullifier (unique per secret, reveals nothing)
const nullifier = persistentHash("nullifier", secret);
return nullifier;
}
References
- Disclosure Rules - Complete decision tree
- Witness Protection - How the compiler tracks values
- Safe Operations - Safe vs unsafe stdlib functions
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?