Skip to content

Instantly share code, notes, and snippets.

@Pringley
Pringley / breakdeterministicpaillier.py
Created May 6, 2014 06:22
Proof-of-concept showing that Paillier with a non-random (and public) noise value is insecure.
import collections
import gmpy
from Crypto.Util.number import getPrime
PublicKey = collections.namedtuple('PublicKey', ('modulus', 'generator'))
Key = collections.namedtuple('_Key', ('modulus', 'generator', 'lambda_', 'mu'))
Key.public = lambda self: PublicKey(self.modulus, self.generator)
# Generated by atmospheric noise
import Data.List (permutations, zip5)
2
3 main = do
4 putStrLn $ head [n | (n, _, _, "Water", _) <- answer] ++ " drinks Water"
5 putStrLn $ head [n | (n, _, "Zebra", _, _) <- answer] ++ " has the Zebra"
6 putStrLn "\nFull answer:"; mapM_ print answer
7
8 where
9 colors = ["Red", "Green", "Ivory", "Yellow", "Blue"]
10 nations = ["England", "Spain", "Ukraine", "Norway", "Japan"]
from itertools import permutations
colors = ["Red", "Green", "Ivory", "Yellow", "Blue"]
nations = ["England", "Spain", "Ukraine", "Norway", "Japan"]
drinks = ["Coffee", "Tea", "Milk", "Orange Juice", "Water"]
pets = ["Dog", "Snail", "Fox", "Horse", "Zebra"]
smokes = ["Old Gold", "Kool", "Chesterfield", "Lucky Strike", "Parliament"]
middle = lambda xs, x: xs[2] == x
first = lambda xs, x: xs[0] == x

Keybase proof

I hereby claim:

  • I am pringley on github.
  • I am pringle (https://keybase.io/pringle) on keybase.
  • I have a public key ASCNyhQcf8iNgwvmQv-3tE9FQX4cbH4JqJGQRWOPMBohugo

To claim this, I am signing this object: