def unpickle_pub_keys(self, msgs): """ Leader uses this method to unpack keys from other nodes """ addrs = [] key_dict = {} key_dict[self.id] = (self.key_from_file(1), AnonCrypto.sign(self.id, self.key1, self.key_from_file(2))) for data in msgs: (rem_id, rem_round, rem_ip, rem_port, rem_key1, rem_key2) = marshal.loads(data) self.debug("Unpickled msg from node %d" % (rem_id)) if rem_round != self.round_id: raise RuntimeError, "Mismatched round numbers! (mine: %d, other: %d)" % ( self.round_id, rem_round) k1 = AnonCrypto.pub_key_from_str(rem_key1) self.pub_keys[rem_id] = (k1, k1) k2 = AnonCrypto.pub_key_from_str( AnonCrypto.verify(self.pub_keys, rem_key2)) self.pub_keys[rem_id] = (k1, k2) addrs.append((rem_ip, rem_port)) key_dict[rem_id] = (rem_key1, rem_key2) return (marshal.dumps((self.round_id, key_dict)), addrs)
def unpickle_pub_keys(self, msgs): """ Leader uses this method to unpack keys from other nodes """ addrs = [] key_dict = {} key_dict[self.id] = ( self.key_from_file(1), AnonCrypto.sign(self.id, self.key1, self.key_from_file(2))) for data in msgs: (rem_id, rem_round, rem_ip, rem_port, rem_key1, rem_key2) = marshal.loads(data) self.debug("Unpickled msg from node %d" % (rem_id)) if rem_round != self.round_id: raise RuntimeError, "Mismatched round numbers! (mine: %d, other: %d)" % ( self.round_id, rem_round) k1 = AnonCrypto.pub_key_from_str(rem_key1) self.pub_keys[rem_id] = (k1, k1) k2 = AnonCrypto.pub_key_from_str(AnonCrypto.verify(self.pub_keys, rem_key2)) self.pub_keys[rem_id] = (k1, k2) addrs.append((rem_ip, rem_port)) key_dict[rem_id] = (rem_key1, rem_key2) return (marshal.dumps((self.round_id, key_dict)), addrs)
def initialize_keys(self): self.advance_phase() for index, participant in enumerate(self.participants_vector): msg, key = marshal.loads(participant[0]) (nonce, interest_ip, interest_gui_port, interest_com_port, pubkey1_str, pubkey2_str) = marshal.loads(msg) k1 = AnonCrypto.pub_key_from_str(pubkey1_str) k2 = AnonCrypto.pub_key_from_str(pubkey2_str) self.pub_keys[index] = (k1, k2) self.info('Unpickled public keys')
def initialize_keys(self): self.advance_phase() for index, participant in enumerate(self.participants_vector): msg, key = marshal.loads(participant[0]) (nonce, interest_ip, interest_gui_port, interest_com_port, pubkey1_str, pubkey2_str) = marshal.loads(msg) k1 = AnonCrypto.pub_key_from_str(pubkey1_str) k2 = AnonCrypto.pub_key_from_str(pubkey2_str) self.pub_keys[index] = (k1, k2) self.info('Unpickled public keys')
def unpickle_keyset(self, keys): """ Non-leader nodes use this to decode leader's key msg """ (rem_round_id, keydict) = marshal.loads(keys) if rem_round_id != self.round_id: raise RuntimeError, "Mismatched round ids" for i in keydict: s1,s2 = keydict[i] k1 = AnonCrypto.pub_key_from_str(s1) k1.check_key() self.pub_keys[i] = (k1, k1) k2 = AnonCrypto.pub_key_from_str(AnonCrypto.verify(self.pub_keys, s2)) k2.check_key() self.pub_keys[i] = (k1, k2) self.info('Unpickled public keys')
def unpickle_keyset(self, keys): """ Non-leader nodes use this to decode leader's key msg """ (rem_round_id, keydict) = marshal.loads(keys) if rem_round_id != self.round_id: raise RuntimeError, "Mismatched round ids" for i in keydict: s1, s2 = keydict[i] k1 = AnonCrypto.pub_key_from_str(s1) k1.check_key() self.pub_keys[i] = (k1, k1) k2 = AnonCrypto.pub_key_from_str( AnonCrypto.verify(self.pub_keys, s2)) k2.check_key() self.pub_keys[i] = (k1, k2) self.info('Unpickled public keys')
def unpickle_pub_keys(self, msgs): """ Method that the leader uses to unpack public keys from other nodes. """ addrs = [] for data in msgs: (rem_id, rem_round, rem_ip, rem_port, rem_key1, rem_key2) = marshal.loads(data) self.debug("Unpickled msg from node %d" % (rem_id)) if rem_round != self.round_id: raise RuntimeError, "Mismatched round numbers!\ (mine: %d, other: %d)" % ( self.round_id, rem_round, ) self.pub_keys[rem_id] = (AnonCrypto.pub_key_from_str(rem_key1), AnonCrypto.pub_key_from_str(rem_key2)) addrs.append((rem_ip, rem_port)) return addrs
def unpickle_keyset(self, keys): """ Method that non-leader nodes use to unpack all public keys from the leader's message. """ (rem_round_id, keydict) = marshal.loads(keys) if rem_round_id != self.round_id: raise RuntimeError, "Mismatched round ids" for i in keydict: s1, s2 = keydict[i] k1 = AnonCrypto.pub_key_from_str(s1) k2 = AnonCrypto.pub_key_from_str(s2) k1.check_key() k2.check_key() self.pub_keys[i] = (k1, k2) self.info("Unpickled public keys")
def unpickle_keyset(self, keys): """ Method that non-leader nodes use to unpack all public keys from the leader's message. """ (rem_round_id, keydict) = marshal.loads(keys) if rem_round_id != self.round_id: raise RuntimeError, "Mismatched round ids" for i in keydict: s1,s2 = keydict[i] k1 = AnonCrypto.pub_key_from_str(s1) k2 = AnonCrypto.pub_key_from_str(s2) k1.check_key() k2.check_key() self.pub_keys[i] = (k1, k2) self.info('Unpickled public keys')
def unpickle_pub_keys(self, msgs): """ Method that the leader uses to unpack public keys from other nodes. """ addrs = [] for data in msgs: (rem_id, rem_round, rem_ip, rem_port, rem_key1, rem_key2) = marshal.loads(data) self.debug("Unpickled msg from node %d" % (rem_id)) if rem_round != self.round_id: raise RuntimeError, "Mismatched round numbers!\ (mine: %d, other: %d)" % ( self.round_id, rem_round) self.pub_keys[rem_id] = ( AnonCrypto.pub_key_from_str(rem_key1), AnonCrypto.pub_key_from_str(rem_key2)) addrs.append((rem_ip, rem_port)) return addrs