Created
November 7, 2016 01:43
-
-
Save HenrikBengtsson/2b7b6a5d0bcda725dd5c5895c7f12513 to your computer and use it in GitHub Desktop.
Example of homomorphic encryption and operators in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example adopted and clarified from | |
## http://www.louisaslett.com/HomomorphicEncryption/ | |
library("HomomorphicEncryption") | |
p <- pars("FandV") | |
k <- keygen(p) | |
## Unencrypted data | |
x <- c(42, 34) | |
y <- c(7, 5) | |
## Calculation on unencrypted data | |
z <- x + y | |
z | |
## Encrypted data | |
cx <- enc(k$pk, x) | |
cy <- enc(k$pk, y) | |
## You can safely send the encrypted data (cx, cy) | |
## to anyone in the world and ask them to perform | |
## the calculation for you. | |
cz <- cx + cy | |
## They will not be able to see the data nor the | |
## results because it's all encrypted throughout! | |
cz | |
## The person sends you back the encrypted results | |
## and you are the only one who can decrypt it. | |
z <- dec(k$sk, cz) | |
z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is only it were possible to install this library