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


Python AnonCrypto.pub_key_from_str方法代码示例

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


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

示例1: unpickle_pub_keys

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import pub_key_from_str [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: initialize_keys

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

示例3: unpickle_keyset

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import pub_key_from_str [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

示例4: unpickle_pub_keys

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

示例5: unpickle_keyset

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


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