Skip to content

Instantly share code, notes, and snippets.

@phil8192
Last active March 10, 2020 13:17
Show Gist options
  • Select an option

  • Save phil8192/e7fe37924d822369d536b7fe53041cb6 to your computer and use it in GitHub Desktop.

Select an option

Save phil8192/e7fe37924d822369d536b7fe53041cb6 to your computer and use it in GitHub Desktop.
library(homomorpheR)
key.pair <- PaillierKeyPair$new(modulusBits=1024)
encrypt <- function(x) key.pair$pubkey$encrypt(x)
decrypt <- decrypt <- function(x) key.pair$getPrivateKey()$decrypt(x)
"%+%" <- function(a, b) key.pair$pubkey$add(a, b)
20 == decrypt(encrypt(1) %+% encrypt(19)) # TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment