当前位置: 首页>>代码示例>>Python>>正文


Python AnonCrypto.verify方法代码示例

本文整理汇总了Python中anon_crypto.AnonCrypto.verify方法的典型用法代码示例。如果您正苦于以下问题:Python AnonCrypto.verify方法的具体用法?Python AnonCrypto.verify怎么用?Python AnonCrypto.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在anon_crypto.AnonCrypto的用法示例。


在下文中一共展示了AnonCrypto.verify方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unpickle_pub_keys

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
	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)
开发者ID:ecrypto,项目名称:shuffle,代码行数:27,代码来源:shuffle_node.py

示例2: recv_from_all

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
    def recv_from_all(self, verify=True):
        if not self.am_leader():
            raise RuntimeError, "Only leader can broadcast"

        indata = AnonNet.recv_from_n(self.sockets)
        if verify:
            outdata = []
            for d in indata:
                outdata.append(AnonCrypto.verify(self.pub_keys, d))
            return outdata
        else:
            return indata
开发者ID:ecrypto,项目名称:dissent,代码行数:14,代码来源:bulk_node.py

示例3: check_go_data

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
	def check_go_data(self, hashval, pickled_list):
		go_lst = marshal.loads(pickled_list)
		for item in go_lst:
			""" Verify signature on "GO" message """
			item_str = AnonCrypto.verify(self.pub_keys, item)
			(r_id, r_round, r_go, r_hash) = marshal.loads(item_str)
			if r_round != self.round_id:
			 	raise RuntimeError, "Mismatched round numbers"
			if not r_go:
			 	raise RuntimeError, "Node %d reports failure!" % (r_id)
			if r_hash != hashval:
			 	raise RuntimeError, "Node %d produced bad hash!" % (r_id)
		return True
开发者ID:ASchurman,项目名称:Dissent,代码行数:15,代码来源:shuffle_node.py

示例4: unpickle_keyset

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
	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')
开发者ID:ecrypto,项目名称:shuffle,代码行数:21,代码来源:shuffle_node.py

示例5: decrypt_ciphers

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
	def decrypt_ciphers(self, keyset):
		priv_keys = {}
		for item in keyset:
			""" Verify signature on each key """
			item_str = AnonCrypto.verify(self.pub_keys, item)
			(r_id, r_roundid, r_keystr) = marshal.loads(item_str)
			if r_roundid != self.round_id:
				raise RuntimeError, 'Mismatched round numbers'
			priv_keys[r_id] = AnonCrypto.priv_key_from_str(r_keystr)

		plaintexts = []
		for cipher in self.final_ciphers:
			(r_round, cipher_prime) = marshal.loads(cipher)
			if r_round != self.round_id:
				raise RuntimeError, 'Mismatched round ids'
			for i in xrange(0, self.n_nodes):
				cipher_prime = AnonCrypto.decrypt_with_rsa(priv_keys[i], cipher_prime)
			plaintexts.append(self.unpackage_msg(cipher_prime))
		
		self.anon_data = plaintexts
开发者ID:ASchurman,项目名称:Dissent,代码行数:22,代码来源:shuffle_node.py

示例6: recv_from_socket

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
 def recv_from_socket(self, sock, verify=True):
     d = AnonNet.recv_from_socket(sock)
     if verify:
         d = AnonCrypto.verify(self.pub_keys, d)
     return d
开发者ID:ecrypto,项目名称:dissent,代码行数:7,代码来源:bulk_node.py

示例7: recv_once

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import verify [as 别名]
 def recv_once(self, verify=True):
     d = AnonNet.recv_once(self.ip, self.port)
     if verify:
         d = AnonCrypto.verify(self.pub_keys, d)
     return d
开发者ID:ecrypto,项目名称:dissent,代码行数:7,代码来源:bulk_node.py


注:本文中的anon_crypto.AnonCrypto.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。