nucypher/nufhe

NuCypher fully homomorphic encryption (NuFHE) library implemented in Python

Python

453

233 commits

updated Jun 21, 2022

See the code

README

A GPU implementation of fully homomorphic encryption on torus

This library implements the fully homomorphic encryption algorithm from TFHE using CUDA and OpenCL. Unlike TFHE, where FFT is used internally to speed up polynomial multiplication, nufhe can use either FFT or purely integer NTT (DFT-like transform on a finite field). The latter is based on the arithmetic operations and NTT scheme from cuFHE. Refer to the project documentation for more details.

Usage example

    import random
    import nufhe

    size = 32
    bits1 = [random.choice([False, True]) for i in range(size)]
    bits2 = [random.choice([False, True]) for i in range(size)]
    reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]

    ctx = nufhe.Context()
    secret_key, cloud_key = ctx.make_key_pair()

    ciphertext1 = ctx.encrypt(secret_key, bits1)
    ciphertext2 = ctx.encrypt(secret_key, bits2)

    vm = ctx.make_virtual_machine(cloud_key)
    result = vm.gate_nand(ciphertext1, ciphertext2)
    result_bits = ctx.decrypt(secret_key, result)

    assert all(result_bits == reference)

Performance

PlatformLibraryPerformance (ms/bit)
Binary GateMUX Gate
Single Core/Single GPU - FFTTFHE (CPU)1326
nuFHE0.130.22
Speedup100.9117.7
Single Core/Single GPU - NTTcuFHE0.35N/A
nuFHE0.350.67
Speedup1.0-

Contributors

fjarri

229 commits

derekpierre

2 commits

tuxxy

1 commits

nucypher/nufhe

NuCypher fully homomorphic encryption (NuFHE) library implemented in Python

Python

453

233 commits

updated Jun 21, 2022

See the code

README

A GPU implementation of fully homomorphic encryption on torus

This library implements the fully homomorphic encryption algorithm from TFHE using CUDA and OpenCL. Unlike TFHE, where FFT is used internally to speed up polynomial multiplication, nufhe can use either FFT or purely integer NTT (DFT-like transform on a finite field). The latter is based on the arithmetic operations and NTT scheme from cuFHE. Refer to the project documentation for more details.

Usage example

    import random
    import nufhe

    size = 32
    bits1 = [random.choice([False, True]) for i in range(size)]
    bits2 = [random.choice([False, True]) for i in range(size)]
    reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]

    ctx = nufhe.Context()
    secret_key, cloud_key = ctx.make_key_pair()

    ciphertext1 = ctx.encrypt(secret_key, bits1)
    ciphertext2 = ctx.encrypt(secret_key, bits2)

    vm = ctx.make_virtual_machine(cloud_key)
    result = vm.gate_nand(ciphertext1, ciphertext2)
    result_bits = ctx.decrypt(secret_key, result)

    assert all(result_bits == reference)

Performance

PlatformLibraryPerformance (ms/bit)
Binary GateMUX Gate
Single Core/Single GPU - FFTTFHE (CPU)1326
nuFHE0.130.22
Speedup100.9117.7
Single Core/Single GPU - NTTcuFHE0.35N/A
nuFHE0.350.67
Speedup1.0-

Contributors

fjarri

229 commits

derekpierre

2 commits

tuxxy

1 commits

Languages

Python

78.9%

Mako

21.1%