Long story short: I'm in need of using ElGamal
encryption to perform multiplication on encoded numbers.
I'm currently using Kotlin
with OpenJDK 1.8
and found nice provider for JCE called Bouncy Castle. It provides ElGamal
encryption within standard JCE API
. However, I have no idea at all how to perform multiplication on encrypted messages I get out of it.
Security.addProvider(BouncyCastleProvider())
val keys = KeyPairGenerator.getInstance("ElGamal", "BC").generateKeyPair()
val cipher = Cipher.getInstance("ElGamal/None/NoPadding", "BC")
cipher.init(Cipher.ENCRYPT_MODE, keys.public)
val eleven = BigInteger.valueOf(11)
val three = BigInteger.valueOf(3)
val eleven_e = cipher.doFinal(eleven.toByteArray())
val three_e = cipher.doFinal(three.toByteArray())
//Do three_e * eleven_e