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 wrap: on
line diff
--- a/viff/config.py	Wed Oct 28 20:24:18 2009 +0100
+++ b/viff/config.py	Wed Oct 28 20:52:45 2009 +0100
@@ -130,13 +130,23 @@
         id = p_unstr(player)
         host = config[player]['host']
         port = int(config[player]['port'])
-        paillier_type = config[player]['paillier']['type']
-        pub_key = config[player]['paillier']['pubkey']
-        pubkey = paillierutil.deserializer(paillier_type, pub_key)
+
+        if 'paillier' in config[player]:
+            paillier_type = config[player]['paillier']['type']
+            pub_key = config[player]['paillier']['pubkey']
+            pubkey = paillierutil.deserializer(paillier_type, pub_key)
+        else:
+            # old format
+            pubkey = tuple(map(long, config[player]['pubkey']))
 
         if 'prss_keys' in config[player]:
-            sec_key = config[player]['paillier']['seckey']
-            seckey = paillierutil.deserializer(paillier_type, sec_key)
+            if 'paillier' in config[player]:
+                sec_key = config[player]['paillier']['seckey']
+                seckey = paillierutil.deserializer(paillier_type, sec_key)
+            else:
+                # old format
+                seckey = tuple(map(long, config[player]['seckey']))
+
             keys = {}
             for subset in config[player]['prss_keys']:
                 keys[s_unstr(subset)] = config[player]['prss_keys'][subset]