changeset 1359:27396792038d

Generate_config_files:Extracted Paillier key generation.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Wed, 28 Oct 2009 14:24:49 +0100
parents 712cbf4c2e1b
children 3fe6e03541c1
files apps/generate-config-files.py viff/config.py
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/apps/generate-config-files.py	Wed Oct 28 11:01:57 2009 +0100
+++ b/apps/generate-config-files.py	Wed Oct 28 14:24:49 2009 +0100
@@ -55,6 +55,7 @@
 from optparse import OptionParser
 
 from viff.config import generate_configs
+from viff import paillier
 
 parser = OptionParser()
 parser.add_option("-p", "--prefix",
@@ -81,7 +82,7 @@
     parser.error("must supply a hostname:port argument for each player")
 
 addresses = [arg.split(':', 1) for arg in args]
-configs = generate_configs(options.n, options.t, options.keysize, addresses,
+configs = generate_configs(options.n, options.t, lambda: paillier.generate_keys(options.keysize), addresses,
                            options.prefix, options.skip_prss)
 
 for config in configs.itervalues():
--- a/viff/config.py	Wed Oct 28 11:01:57 2009 +0100
+++ b/viff/config.py	Wed Oct 28 14:24:49 2009 +0100
@@ -156,7 +156,8 @@
     return owner_id, players
 
 
-def generate_configs(n, t, keysize=1024, addresses=None, prefix=None, skip_prss=False):
+def generate_configs(n, t, paillier_key_generator=lambda: paillier.generate_keys(1024),
+                     addresses=None, prefix=None, skip_prss=False):
     """Generate player configurations.
 
     Generates *n* configuration objects with a threshold of *t*. The
@@ -192,7 +193,7 @@
         """Convert a dealer ID to a string."""
         return "Dealer " + str(dealer)
 
-    key_pairs = dict([(p, paillier.generate_keys(keysize)) for p in players])
+    key_pairs = dict([(p, paillier_key_generator()) for p in players])
 
     configs = {}
     for p in players: