Member-only story

Logistic Function In Homomorphic Encryption — A Base for Privacy-Aware Machine Learning

Prof Bill Buchanan OBE FRSE
4 min readAug 5, 2024

We live in a world where AI can harvest citizen data. But can we find a way that we can learn on encrypted data? Well, with homomorphic encryption we can use encrypted data for our processing. So:

Enc(a operator b) = Enc(a) operator Enc(b)

and where operator could be any mathematical operation. While LLMs are a kinda false type of learning, the usage of artificial neural networks (ANN) allows us the opportunity to learn from data in the same way that our brain works. At the core of this is the logistic function (also known as the sigmoid function):

Ref: [Wikipedia]

Mathematically, this is defined as:

For example, if we have x=0.5, then, in Python, we get:

>>> import math
>>> x=0.5
>>> y=1/(1+math.exp(-x))
>>> print (y)
0.6224593312018546
>>> x=6
>>> print (y)
0.9975273768433653

An artificial neural network is created with weighted summation and a sigmoid function:

Approximate logistic function with Chebyshev approximation

With homomorphic encryption we can represent a mathematical operation in the form for a homomorphic equation. One of the most widely used methods is to use Chebyshev polynomials, and which allows the mapping of the function to a Chebyshev approximation. This is supported in OpenFHE, and which implements Chebyshev approximation. For this, we can use the function of:

Ciphertext<Element> EvalLogistic(ConstCiphertext<Element> ciphertext, double a, double b, uint32_t degree) const

and which evaluates 1/(1 + exp(-x)) for f(x), and where x is a range of coefficients with ciphertext. The value of a is the lower bound of the coefficients, and b is the upport bound. The degree value is the desired degree of approximation.

--

--

Prof Bill Buchanan OBE FRSE
Prof Bill Buchanan OBE FRSE

Written by Prof Bill Buchanan OBE FRSE

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.

No responses yet

Write a response