Exemplo n.º 1
0
 def test_authenticity(self):
     node_a = AuthenticityNode("a")
     node_b = AuthenticityNode("b")
     message_a = node_a.send()
     key_pair = generate_key_pair()
     invalid_identity = Identity(5, key_pair.public)
     invalid_signature = sign(invalid_identity, key_pair.private)
     invalid_certificate = Certificate(invalid_signature, invalid_identity)
     message_a.content.certificate = invalid_certificate
     self.assertRaises(ValueError, node_b.receive, message_a)
Exemplo n.º 2
0
 def send(self):
     slmp_payload = self.__node.send()
     content = AuthenticityMessage(self.__certificate, slmp_payload)
     signature = sign(content, self.__private_key)
     return SignedMessage(signature, content)
Exemplo n.º 3
0
 def send(self):
     slmp_payload = JoinRequest(self.__context, self.__id)
     content = AuthenticityMessage(self.__certificate, slmp_payload)
     signature = sign(content, self.__private_key)
     return SignedMessage(signature, content)
Exemplo n.º 4
0
 def broadcast(self):
     signature = sign(self.__views, self.__private_key)
     content = ViewsBroadcast(self.__id, self.__views)
     message = SignedMessage(signature, content)
     return message
Exemplo n.º 5
0
 def send(self):
     slmp_payload = self.__node.send()
     content = IntegrityMessage(self.__public_key, slmp_payload)
     signature = sign(content, self.__private_key)
     return SignedMessage(signature, content)
Exemplo n.º 6
0
 def issue_certificate(self, public_key):
     self.__incremental_id += 1
     identity = Identity(self.__incremental_id, public_key)
     signature = sign(identity, self.__private_key)
     certificate = Certificate(signature, identity)
     return certificate