viff

changeset 1365:04a696700b3f

config: Accept old config files. VIFF crashed on config files generated previously to the change allowing several Paillier key formats.
author Marcel Keller <mkeller@cs.au.dk>
date Wed, 28 Oct 2009 20:52:45 +0100
parents f441d4776bcc
children fd9867d4dc8c
files viff/config.py
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/viff/config.py	Wed Oct 28 20:24:18 2009 +0100
     1.2 +++ b/viff/config.py	Wed Oct 28 20:52:45 2009 +0100
     1.3 @@ -130,13 +130,23 @@
     1.4          id = p_unstr(player)
     1.5          host = config[player]['host']
     1.6          port = int(config[player]['port'])
     1.7 -        paillier_type = config[player]['paillier']['type']
     1.8 -        pub_key = config[player]['paillier']['pubkey']
     1.9 -        pubkey = paillierutil.deserializer(paillier_type, pub_key)
    1.10 +
    1.11 +        if 'paillier' in config[player]:
    1.12 +            paillier_type = config[player]['paillier']['type']
    1.13 +            pub_key = config[player]['paillier']['pubkey']
    1.14 +            pubkey = paillierutil.deserializer(paillier_type, pub_key)
    1.15 +        else:
    1.16 +            # old format
    1.17 +            pubkey = tuple(map(long, config[player]['pubkey']))
    1.18  
    1.19          if 'prss_keys' in config[player]:
    1.20 -            sec_key = config[player]['paillier']['seckey']
    1.21 -            seckey = paillierutil.deserializer(paillier_type, sec_key)
    1.22 +            if 'paillier' in config[player]:
    1.23 +                sec_key = config[player]['paillier']['seckey']
    1.24 +                seckey = paillierutil.deserializer(paillier_type, sec_key)
    1.25 +            else:
    1.26 +                # old format
    1.27 +                seckey = tuple(map(long, config[player]['seckey']))
    1.28 +
    1.29              keys = {}
    1.30              for subset in config[player]['prss_keys']:
    1.31                  keys[s_unstr(subset)] = config[player]['prss_keys'][subset]