本文整理汇总了Python中anon_crypto.AnonCrypto.hash_list方法的典型用法代码示例。如果您正苦于以下问题:Python AnonCrypto.hash_list方法的具体用法?Python AnonCrypto.hash_list怎么用?Python AnonCrypto.hash_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anon_crypto.AnonCrypto
的用法示例。
在下文中一共展示了AnonCrypto.hash_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_phase4
# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import hash_list [as 别名]
def run_phase4(self):
self.advance_phase()
if self.am_leader():
self.debug("Leader broadcasting ciphers to all nodes")
self.broadcast_to_all_nodes(marshal.dumps(self.final_ciphers))
self.debug("Cipher set len %d" % (len(self.final_ciphers)))
else:
""" Get C' ciphertexts from leader. """
self.final_ciphers = marshal.loads(self.recv_from_leader())
"""
self.final_ciphers holds an array of
pickled (round_id, cipher_prime) tuples
"""
my_cipher_str = marshal.dumps((self.round_id, self.cipher_prime))
go = False
if my_cipher_str in self.final_ciphers:
self.info("Found my ciphertext in set")
go = True
else:
self.critical("ABORT! My ciphertext is not in set!")
self.debug(self.final_ciphers)
go = False
raise RuntimeError, "Protocol violation: My ciphertext is missing!"
hashval = AnonCrypto.hash_list(self.final_ciphers)
go_msg = marshal.dumps((
self.id,
self.round_id,
go,
hashval))
go_data = ''
if self.am_leader():
""" Collect go msgs """
data = self.recv_from_all(False)
""" Add leader's signed GO message to set """
data.append(AnonCrypto.sign(self.id, self.key1, go_msg))
go_data = marshal.dumps((data))
self.broadcast_to_all_nodes(go_data)
else:
""" Send go msg to leader """
self.send_to_leader(go_msg)
go_data = self.recv_from_leader()
self.check_go_data(hashval, go_data)
self.info("All nodes report GO")
return