Skip to content

manos02/ckks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CKKS: A Step-by-Step Homomorphic Encryption Walkthrough

This repository is a hands-on exploration of the Cheon-Kim-Kim-Song (CKKS) scheme, a homomorphic encryption scheme for approximate arithmetic.

The main goal of the project is clarity: the notebook walks through the core CKKS ideas step by step, starting from encoding and decoding, then moving into encryption, decryption, and homomorphic operations.

It is based on the paper:

Homomorphic Encryption for Arithmetic of Approximate Numbers
Jung Hee Cheon, Andrey Kim, Miran Kim, and Yongsoo Song
Advances in Cryptology - ASIACRYPT 2017
Read the paper

Why This Repo

  • Learn CKKS through an interactive notebook rather than only theory
  • See the full flow from vector encoding to encrypted computation
  • Study exact polynomial arithmetic for ciphertext operations
  • Compare the direct encoding method with an FFT-based alternative
  • Use small toy examples that are easy to inspect and verify

What You Will Find

Main notebook

  • ckks.ipynb: the main tutorial notebook
  • Covers encoding, decoding, encryption, decryption, addition, and multiplication
  • Includes a step-by-step FFT alternative for encoding and decoding

Supporting files

Current Coverage

  • CKKS encoding and decoding
  • CKKS encryption and decryption
  • Homomorphic addition
  • Homomorphic multiplication tutorial example
  • FFT-based encoding and decoding alternative
  • Integration with machine learning applications

Quick Start

1. Create or activate the virtual environment

If you already have the included environment, activate it:

source myenv/bin/activate

2. Launch Jupyter

jupyter notebook

Then open ckks.ipynb.

3. Run the notebook from top to bottom

The notebook is written as a guided walkthrough, so running cells in order will give the clearest explanation and the most consistent state.

Project Focus

This repository is primarily educational.

That means the code favors readability and step-by-step explanation over production-grade optimization or cryptographic hardening. The examples use small parameters so the arithmetic is easy to follow.

Notes

  • CKKS works with approximate arithmetic, so decoded values are expected to be close to the original values rather than always exactly equal
  • The notebook now includes an FFT-based view of encoding and decoding, which becomes much more important as the polynomial degree grows
  • The multiplication section uses exact integer coefficient lists for ciphertext arithmetic so the algebra stays correct even when coefficients become large

References

  1. Jung Hee Cheon, Andrey Kim, Miran Kim, and Yongsoo Song
    Homomorphic Encryption for Arithmetic of Approximate Numbers
    Advances in Cryptology - ASIACRYPT 2017
    ePrint Archive

  2. AI Tech Research Lab
    Introduction to BFV HE for ML
    GitHub Repository

  3. Inferati Blog
    An Introduction to Fully Homomorphic Encryption and CKKS Scheme
    FHE Schemes Overview

  4. OpenMined Blog
    CKKS Explained: Part 1 - Simple Encoding and Decoding
    CKKS Blog Post

About

This repository implements homomorphic encryption using the CKKS scheme. It supports encoding and decoding, encryption and decryption, and addition and multiplication for approximate arithmetic operations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages