IlyasRidhuan / HsPaillier

Simple Paillier cryptosystem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HsPaillier

A implenmentation of Paillier cryptosystem

The Paillier cryptosystem has some homomorphic properties.

  • Homomorphic addition of plaintexts
  • Homomorphic multiplication of plaintexts

Those properties mean that you can manipulate the ciphertext without decrypting it first.

For example,

(pubKey, prvKey) <- P.genKey 256 

let p = 2 :: Integer
c <- P.encrypt pubKey p

let p' = 100 :: Integer
c' <- P.encrypt pubKey p'

let c'' = P.cipherMul pubKey c c'
putStrLn $ "plaintext: " ++ show (P.decrypt prvKey pubKey c'')

The result will be 102 which is 2+100 (We just decrypt once!)

The above example is in the Main.hs

How to install

$ cabal configure

$ cabal build

$ cabal test

About

Simple Paillier cryptosystem

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 100.0%