How Do I Find Out The Difference in Age Between Bob and Alice, Without Revealing Their Ages?

--

I have a function on a blockchain which determines the difference between the ages of two users. Let’s say they are Bob and Alice. We now need to create a function which will allow us to read encrypted values, and find the difference between the values, and return an encrypted answer.

For this, we first create a key pair with a public key (pk) and a private key (sk). We then store the public key on the blockchain. Bob and Alice can then store the encrypted ages on the blockchain using the available public key. We can then use homomorphic encryption to perform a subtraction, and return back an encrypted value, and where we then use our private key (sk) to decrypt it. We will then know the difference in the ages between Bob and Alice.

For this we will use HEAAN (Homomorphic Encryption for Arithmetic of Approximate Numbers) which defines a homomorphic encryption method proposed by Cheon, Kim, Kim and Song (CKKS) in 2016 [here]:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

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