본문으로 건너뛰기
cccskills
무료GitHub에 공개

implementing-homomorphic-encryption

Guide to implementing homomorphic encryption for privacy-preserving computation under GDPR. Covers scheme selection (BFV, BGV, CKKS, TFHE), Microsoft SEAL, IBM HELib, and Google FHE transpiler. Includes performance benchmarks, parameter tuning, and basic HE example code for encrypted arithmetic operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md10.0 KB
  • assets/template.md4.2 KB
  • references/standards.md3.5 KB
  • references/workflows.md6.1 KB
  • scripts/process.py13.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Implementing Homomorphic Encryption

Overview

Homomorphic encryption (HE) enables computation on encrypted data without decryption. The data owner encrypts their data, sends the ciphertext to a computing party (e.g., a cloud processor under Article 28), and the computing party performs operations on the ciphertext. The encrypted results are returned to the data owner, who decrypts them to obtain the plaintext result. At no point does the computing party see unencrypted data.

This directly supports GDPR Article 32(1)(a), which identifies encryption as an appropriate technical measure, and Article 25(1), which requires data protection by design. HE enables a controller to outsource computation to a processor while maintaining cryptographic confidentiality of personal data.

HE Scheme Selection

Scheme Comparison

SchemeArithmetic TypeExact/ApproximateOperationsBest ForLibraries
BFVInteger (modular)ExactAdd, Multiply (limited depth)Counting, matching, exact integer computationMicrosoft SEAL, OpenFHE
BGVInteger (modular)ExactAdd, Multiply (with modulus switching)Deep circuits on integers, batched operationsHELib, OpenFHE
CKKSReal/ComplexApproximateAdd, Multiply, RotationML inference, statistical analysis, floating-point computationMicrosoft SEAL, OpenFHE, HEAAN
TFHEBoolean/IntegerExactArbitrary (gate-by-gate)Programmable bootstrapping, arbitrary functionsTFHE-rs, Concrete (Zama)

Decision Criteria

CriterionBFV/BGVCKKSTFHE
Need exact results?YesNo (approximate)Yes
Data typeIntegersReal numbersBoolean/Small integers
Multiplicative depthLimited (plan ahead)Limited (plan ahead)Unlimited (with bootstrapping)
SIMD batchingYes (thousands of slots)Yes (thousands of slots)Limited
PerformanceFast for shallow circuitsFast for ML workloadsSlow per operation, fast bootstrapping
Typical latencyMilliseconds (shallow) to secondsMilliseconds to secondsSeconds to minutes

Parameter Selection Guide

For BFV/CKKS with Microsoft SEAL, the key parameters are:

ParameterDescriptionSecurity ImpactPerformance Impact
poly_modulus_degree (N)Degree of the polynomial ringHigher N = more securityHigher N = slower operations, more memory
coeff_modulusProduct of primes defining the coefficient modulusDetermines noise budget and multiplicative depthMore primes = deeper circuits but larger ciphertexts
plain_modulus (BFV only)Modulus for plaintext encodingMust accommodate plaintext valuesLarger = less noise budget available
scale (CKKS only)Encoding scale factorDetermines precision of approximate resultsHigher scale = more precision but faster noise growth

Recommended parameter sets (128-bit security):

Use CaseNcoeff_modulus bitsMult DepthMemory/Ciphertext
Simple addition/comparison4096[40, 40]1~64 KB
Moderate computation (sum + multiply)8192[60, 40, 40, 60]2-3~256 KB
ML inference (logistic regression)16384[60, 40, 40, 40, 40, 60]4-5~1 MB
Deep neural network inference32768[60, 40×8, 60]8+~4 MB

Architecture for GDPR-Compliant HE Processing

┌────────────────────────────────────────────────────────────┐
│              Data Controller (Prism Data Systems AG)        │
│  ┌──────────────────┐  ┌──────────────────────────────┐   │
│  │ Key Generator     │  │ Encrypt personal data        │   │
│  │ (sk stays here)   │  │ with public key              │   │
│  └────────┬─────────┘  └──────────┬───────────────────┘   │
│           │ pk, rlk, gk           │ ciphertext             │
└───────────┼───────────────────────┼────────────────────────┘
            │                       │
            ▼                       ▼
┌────────────────────────────────────────────────────────────┐
│              Data Processor (Cloud Service)                  │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ Compute on ciphertext using pk, rlk, gk              │  │
│  │ (NEVER has access to sk — cannot decrypt)             │  │
│  │                                                        │  │
│  │ Operations: HE.Add, HE.Multiply, HE.Rotate           │  │
│  └──────────────────────────┬───────────────────────────┘  │
│                              │ encrypted result             │
└──────────────────────────────┼─────────────────────────────┘
                               │
                               ▼
┌────────────────────────────────────────────────────────────┐
│              Data Controller (Prism Data Systems AG)        │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ Decrypt result using sk                               │  │
│  │ Plaintext result = f(data) computed without exposure   │  │
│  └──────────────────────────────────────────────────────┘  │
└────────────────────────────────────────────────────────────┘

Key:
  sk = Secret key (never leaves controller)
  pk = Public key (for encryption and computation)
  rlk = Relinearization keys (for ciphertext multiplication)
  gk = Galois keys (for ciphertext rotation/SIMD operations)

Performance Considerations

Benchmark Reference (Microsoft SEAL, BFV, N=8192, 128-bit security)

OperationLatencyThroughput (ops/sec)
Key generation50 ms20
Encryption2 ms500
Decryption1 ms1,000
Ciphertext addition0.1 ms10,000
Ciphertext multiplication5 ms200
Relinearization3 ms333
SIMD rotation4 ms250

Optimization Strategies

StrategyBenefitTrade-off
SIMD batchingProcess thousands of values in parallelRequires data to be structured as vectors
Circuit depth minimizationFewer multiplications = less noise, smaller parametersMay require algorithmic redesign
Lazy relinearizationSkip intermediate relinearizationsLarger intermediate ciphertexts
Level-aware computationUse modulus switching to control noiseRequires careful depth planning
Hybrid HE + plaintextPerform non-sensitive operations in plaintextReduces privacy guarantee scope

Implementation Workflow

  1. Identify computation — Define the exact mathematical function to compute on encrypted data. Express it as additions and multiplications (and rotations for SIMD).

  2. Select scheme — Choose BFV for exact integer results, CKKS for approximate real-number results, TFHE for arbitrary boolean/integer functions.

  3. Estimate circuit depth — Count the maximum number of sequential multiplications in the computation graph. This determines parameter requirements.

  4. Select parameters — Choose poly_modulus_degree and coeff_modulus to support the required depth at 128-bit security.

  5. Implement and test — Implement the computation using an HE library. Test against plaintext reference implementation to verify correctness.

  6. Benchmark — Measure encryption, computation, and decryption latency. Verify memory requirements are within infrastructure limits.

  7. Deploy — Establish key management (secret key in HSM at controller, public keys distributed to processor), monitoring, and audit logging.

Key Regulatory References

  • GDPR Article 25(1) — Data protection by design (encryption as a design measure)
  • GDPR Article 32(1)(a) — Encryption as a security measure
  • GDPR Article 28 — Processor obligations (HE enables processing without plaintext exposure)
  • GDPR Recital 83 — Encryption to maintain security
  • ENISA Report: Data Protection Engineering (2022)
  • HomomorphicEncryption.org Standard: Homomorphic Encryption Standardization (2018)

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Implements 42 CFR Part 2 protections for substance use disorder patient records. Covers written consent requirements stricter than HIPAA, re-disclosure prohibition, court order procedures, qualified service organization agreements, and 2024 amendments aligning Part 2 with HIPAA. Keywords: 42 CFR Part 2, substance use disorder, SUD records, re-disclosure, consent, Part 2 amendments.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

Guides assessment of third-country adequacy decisions under GDPR Article 45 for international data transfers. Covers the current EC adequacy decisions list, adequacy assessment criteria, partial adequacy handling, and monitoring of adequacy decision reviews. Keywords: adequacy decision, Article 45, third country, adequate protection, EC adequacy list.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

Implements age-gating mechanisms for online services to restrict access based on user age. Covers hard gates versus soft gates, neutral age prompts, re-verification triggers, circumvention prevention, and regulatory requirements under GDPR, COPPA, UK Online Safety Act, and DSA. Keywords: age gate, age restriction, neutral prompt, children, online services, access control.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

Evaluates and implements age estimation and verification technologies for online services. Covers facial age estimation, digital ID verification, self-declaration with risk assessment, AI-based age estimation, and the accuracy versus privacy tradeoff. Includes ICO guidance and euCONSENT framework. Keywords: age verification, age estimation, facial analysis, digital ID, children, online safety.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

Preparing EU AI Act compliance documentation for high-risk AI systems. Covers Annex III classification, technical documentation under Art. 11, conformity assessment, risk management systems, and CE marking requirements. Keywords: EU AI Act, high-risk AI, Annex III, conformity assessment, CE marking.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

Implements GDPR Art. 22 automated decision-making and AI Act Art. 14 human oversight requirements for AI systems. Covers identification of solely automated decisions, meaningful human intervention design, logic explanation mechanisms, and contestation procedures. Keywords: Art. 22, automated decision, human oversight, AI Act, profiling, contestation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mukul975/Privacy-Data-Protection-Skills3132026년 3월 17일 업데이트

mukul975의 스킬 모두 보기

이 스킬의 문제 신고