viff

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 diff
     1.1 --- a/apps/generate-config-files.py	Wed Oct 28 11:01:57 2009 +0100
     1.2 +++ b/apps/generate-config-files.py	Wed Oct 28 14:24:49 2009 +0100
     1.3 @@ -55,6 +55,7 @@
     1.4  from optparse import OptionParser
     1.5  
     1.6  from viff.config import generate_configs
     1.7 +from viff import paillier
     1.8  
     1.9  parser = OptionParser()
    1.10  parser.add_option("-p", "--prefix",
    1.11 @@ -81,7 +82,7 @@
    1.12      parser.error("must supply a hostname:port argument for each player")
    1.13  
    1.14  addresses = [arg.split(':', 1) for arg in args]
    1.15 -configs = generate_configs(options.n, options.t, options.keysize, addresses,
    1.16 +configs = generate_configs(options.n, options.t, lambda: paillier.generate_keys(options.keysize), addresses,
    1.17                             options.prefix, options.skip_prss)
    1.18  
    1.19  for config in configs.itervalues():
     2.1 --- a/viff/config.py	Wed Oct 28 11:01:57 2009 +0100
     2.2 +++ b/viff/config.py	Wed Oct 28 14:24:49 2009 +0100
     2.3 @@ -156,7 +156,8 @@
     2.4      return owner_id, players
     2.5  
     2.6  
     2.7 -def generate_configs(n, t, keysize=1024, addresses=None, prefix=None, skip_prss=False):
     2.8 +def generate_configs(n, t, paillier_key_generator=lambda: paillier.generate_keys(1024),
     2.9 +                     addresses=None, prefix=None, skip_prss=False):
    2.10      """Generate player configurations.
    2.11  
    2.12      Generates *n* configuration objects with a threshold of *t*. The
    2.13 @@ -192,7 +193,7 @@
    2.14          """Convert a dealer ID to a string."""
    2.15          return "Dealer " + str(dealer)
    2.16  
    2.17 -    key_pairs = dict([(p, paillier.generate_keys(keysize)) for p in players])
    2.18 +    key_pairs = dict([(p, paillier_key_generator()) for p in players])
    2.19  
    2.20      configs = {}
    2.21      for p in players: