core-concepts:privacy-patterns

Implement privacy-preserving design patterns for Compact smart contracts.

37|9|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/devrelaicom/midnight-expert --skill core-concepts-privacy-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: core-concepts:privacy-patterns
Source: https://github.com/devrelaicom/midnight-expert/tree/main/plugins/core-concepts/skills/privacy-patterns
Command: npx skills add https://github.com/devrelaicom/midnight-expert --skill core-concepts-privacy-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers design and reason about privacy-preserving patterns for Compact smart contracts so on-chain protocols can hide sensitive values, prove membership anonymously, and prevent linkability or double-actions without leaking secret data. It synthesizes commitments, nullifiers, Merkle membership proofs, commit-reveal flows, selective disclosure, and round-based unlinkability into actionable guidance and threat mitigations.

Core Features & Use Cases

  • Commitment vs Hash Guidance: When to use persistentCommit (hiding with randomness) versus persistentHash or transient variants, and how witness taint is affected.
  • Nullifier Construction & Domain Separation: Patterns to derive round-specific or purpose-specific nullifiers and store them safely in Sets to prevent double-actions.
  • MerkleTree & HistoricMerkleTree Usage: End-to-end anonymous membership proofs, computing merkleTreePathRoot from full path structs, and TypeScript witness integration for path construction.
  • Selective Disclosure & Threat Model: Techniques to disclose boolean checks only, mitigate leaf-guessing, and plan capacity and timing to reduce deanonymization risks.
  • Use Case Example: Build an anonymous voting system where members register commitments, prove membership with Merkle paths, and cast one vote per round via nullifiers.

Quick Start

Ask the assistant to design a Compact circuit that registers members with HistoricMerkleTree, derives round-specific nullifiers via domain-separated persistentHash, and enforces a commit-reveal or single-action-per-round flow while preserving selective disclosure.

Frequently Asked Questions about core-concepts:privacy-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement privacy-preserving commitments in Compact smart contracts?

To implement privacy-preserving commitments in Compact, use persistentCommit to hide values with randomness versus persistentHash for non-hiding hashes. This skill guides witness taint handling and selecting transient or persistent variants based on your contract's privacy requirements.

How do Merkle membership proofs work for anonymous voting in Compact?

Merkle membership proofs in Compact use MerkleTree or HistoricMerkleTree to anonymously prove registration. Compute merkleTreePathRoot from full path structs and integrate TypeScript witnesses for path construction, enabling members to prove eligibility without revealing identity.

When should I use persistentCommit versus persistentHash for hiding values in Compact?

Use persistentCommit in Compact when you need to hide values with embedded randomness, and persistentHash when hiding is unnecessary. This skill provides guidance on witness taint implications and helps you select the correct variant for your contract's threat model.

What are the limitations of selective disclosure in Compact smart contracts?

Selective disclosure in Compact requires mitigating leaf-guessing and planning capacity and timing to reduce deanonymization risks. This skill guides disclosing boolean checks only and highlights threat model precautions to prevent leaking sensitive data through ledger operations.

Can I build a commit-reveal protocol with round-based unlinkability in Compact?

Yes, you can build commit-reveal protocols with round-based unlinkability in Compact by combining HistoricMerkleTree registration with domain-separated nullifiers. This skill provides patterns to enforce single-action-per-round flows while preserving selective disclosure.