スキル一覧に戻る
FractionEstate

privacy-patterns

by FractionEstate

0🍴 0📅 2026年1月5日
GitHubで見るManusで実行

SKILL.md


name: privacy-patterns description: >- Implement privacy-preserving patterns using zero-knowledge proofs on Midnight Network. Use when designing private data handling, commitment schemes, nullifiers, or selective disclosure. Triggers on privacy, ZK proof, commitment, nullifier, or confidential computing questions.

Privacy Patterns for Midnight

Design and implement privacy-preserving applications using zero-knowledge proofs.

Core Privacy Model

ConceptDescriptionVisibility
PublicLedger stateEveryone
PrivateCircuit inputsOnly prover
WitnessProver-provided dataOnly prover
DisclosedExplicitly revealedEveryone

Reference Files

TopicResource
Zero-Knowledge Basicsreferences/zk-fundamentals.md
Commitment Schemesreferences/commitments.md
Nullifier Patternsreferences/nullifiers.md
Selective Disclosurereferences/selective-disclosure.md

Pattern Overview

1. Commitment Scheme

Hide a value while binding to it:

commitment = persistentCommit(value, randomness);
// Later: prove you know the opening

2. Nullifier Pattern

Prevent double-use without revealing identity:

nullifier = transientHash(secret, commitment);
// Can only be generated once per commitment

3. Selective Disclosure

Prove properties without revealing data:

// Prove over 18 without revealing actual age
disclose(age >= 18);  // Only boolean is public

4. Merkle Membership

Prove membership in a set without revealing position:

// Verify path from leaf to root
assert verifyMerklePath(leaf, proof, root);

Quick Examples

Private Balance Check

// Only reveal if balance is sufficient, not actual amount
export circuit checkFunds(balance: Uint<64>, required: Uint<64>): Boolean {
  return disclose(balance >= required);
}

Anonymous Voting

export circuit vote(voter: Bytes<32>, choice: Boolean): [] {
  // Voter identity disclosed (prevents double voting)
  hasVoted.insert(voter);
  // Choice remains private, only totals change
  if (choice) { yesCount = yesCount + 1; }
}

Commitment-Reveal

witness randomness: Field;

// Phase 1: Commit
export circuit commit(value: Uint<64>): Field {
  return persistentCommit(value, randomness);
}

// Phase 2: Reveal
export circuit reveal(value: Uint<64>, commitment: Field): [] {
  assert persistentCommit(value, randomness) == commitment;
  disclose(value);
}

Privacy Best Practices

  • ✅ Use witness for data that should never appear on-chain
  • ✅ Use persistentCommit (with randomness) to hide values
  • ✅ Use nullifiers to prevent double-actions
  • ✅ Disclose only what's necessary (prefer booleans)
  • ❌ Don't store unhashed sensitive data on ledger
  • ❌ Don't use predictable randomness in commitments
  • ❌ Don't reveal intermediate values unnecessarily

Privacy Levels

┌────────────────────────────────────────────────┐
│ Level 0: Fully Public                          │
│ - All data visible on-chain                    │
├────────────────────────────────────────────────┤
│ Level 1: Hidden Values                         │
│ - Commitments on-chain, values private         │
├────────────────────────────────────────────────┤
│ Level 2: Unlinkable Actions                    │
│ - Nullifiers prevent linking actions           │
├────────────────────────────────────────────────┤
│ Level 3: Anonymous Membership                  │
│ - Merkle proofs hide set position              │
└────────────────────────────────────────────────┘

When to Use Each Pattern

PatternUse Case
CommitmentSealed bids, hidden votes before reveal
NullifierPreventing double-spend, one-time tokens
Merkle ProofMembership in allowlist without revealing identity
Selective DisclosureAge verification, credential proofs

Resources

スコア

総合スコア

45/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です