Skip to content

Imagine a technology that allows dealerships and financial institutions to process and analyze data without ever exposing it in its raw form. homomorphic encryption makes this possible by using advanced mathematical algorithms that perform computations directly on encrypted data.

License

Notifications You must be signed in to change notification settings

ArkS0001/Homomorphic-Encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Homomorphic-Encryption

Imagine a technology that allows dealerships and financial institutions to process and analyze data without ever exposing it in its raw form. homomorphic encryption makes this possible by using advanced mathematical algorithms that perform computations directly on encrypted data.

Homomorphic encryption is a groundbreaking cryptographic method that allows computations to be performed directly on encrypted data without needing to decrypt it first. This means you can, for example, add or multiply numbers in their encrypted form—and when you decrypt the result, it’s exactly as if you’d performed the operations on the original data. Key Points

Preservation of Data Privacy: Since data remains encrypted throughout processing, sensitive information is never exposed, making it ideal for cloud computing and multi-party computations.

Types of Homomorphic Encryption:

    Partially Homomorphic Encryption (PHE): Supports only one type of operation (like RSA for multiplication or Paillier for addition).

    Somewhat Homomorphic Encryption (SHE): Allows a limited number of both addition and multiplication operations.

    Fully Homomorphic Encryption (FHE): Supports arbitrary computations (both addition and multiplication) on encrypted data, enabling any function to be computed without ever decrypting the data.

Historical Milestones:

    The concept dates back to proposals by Rivest, Adleman, and Dertouzos in 1978.

    In 2009, Craig Gentry introduced the first FHE scheme based on ideal lattices, which was a pivotal breakthrough in the field.

Applications:

    Cloud Computing: Securely process data on remote servers without exposing plaintext data.

    Privacy-Preserving Machine Learning: Train and run models on encrypted datasets.

    Secure Voting Systems: Tally votes without revealing individual ballots.

Homomorphic encryption continues to evolve, with research aimed at improving its efficiency and practicality for real-world applications.

Python code using the Pyfhel library—a popular Python wrapper for homomorphic encryption. This snippet demonstrates how to set up the encryption parameters, generate keys, encrypt two integers, perform homomorphic addition and multiplication, and finally decrypt the results.

        from Pyfhel import Pyfhel
        
        # Initialize Pyfhel object and generate context parameters.
        HE = Pyfhel()                       
        # Here, p is the plaintext modulus and m is the polynomial modulus degree.
        # These parameters are chosen for the BFV scheme.
        HE.contextGen(p=65537, m=8192)       
        HE.keyGen()                        
        
        # Define two numbers to encrypt.
        a = 5
        b = 10
        
        # Encrypt the integers.
        ctxt_a = HE.encryptInt(a)
        ctxt_b = HE.encryptInt(b)
        
        # Perform homomorphic operations.
        # Homomorphic addition: The decrypted result should equal (a + b)
        ctxt_sum = ctxt_a + ctxt_b
        # Homomorphic multiplication: The decrypted result should equal (a * b)
        ctxt_product = ctxt_a * ctxt_b
        
        # Decrypt the results.
        res_sum = HE.decryptInt(ctxt_sum)
        res_product = HE.decryptInt(ctxt_product)
        
        print("Homomorphic Addition (5 + 10):", res_sum)
        print("Homomorphic Multiplication (5 * 10):", res_product)

Explanation

Setup:
We create a Pyfhel instance and generate a context with chosen parameters (e.g., plaintext modulus p=65537 and polynomial modulus degree m=8192), which are essential for the BFV scheme used in this example.

Key Generation:
The keys are generated with HE.keyGen(), creating both the public and secret keys.

Encryption:
The integers a and b are encrypted using HE.encryptInt(), resulting in ciphertexts ctxt_a and ctxt_b.

Homomorphic Operations:

    Addition: The ciphertexts are added directly (ctxt_a + ctxt_b) to obtain a new ciphertext which, when decrypted, equals the sum of a and b.

    Multiplication: Similarly, multiplying the ciphertexts (ctxt_a * ctxt_b) produces a ciphertext that decrypts to the product of a and b.

Decryption:
Finally, the results are decrypted using HE.decryptInt() and printed.

This code demonstrates the core idea of homomorphic encryption: you can compute on encrypted data without ever exposing the underlying plaintext.

About

Imagine a technology that allows dealerships and financial institutions to process and analyze data without ever exposing it in its raw form. homomorphic encryption makes this possible by using advanced mathematical algorithms that perform computations directly on encrypted data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published