Ejemplo n.º 1
0
 def genMsg(self):
     values = (
         self.msgType,
         self.nodeType,
         bytes(self.IP, 'utf-8'),
         self.port,
         self.signature,
         cryptostuff.keyToBytes(self.key),
     )
     return self.fmt.pack(*values)  # splat
Ejemplo n.º 2
0
Archivo: CH.py Proyecto: APWHY/carlsb
    def verifyTransaction(self, pubKeyTransSender, pubKeySender, sig):
        check, sender = self.checkCM(pubKeySender)
        if not check:
            raise AssertionError("This user doesn't exist")

        check, transSender = self.checkCM(pubKeyTransSender)
        if check:
            contractAddr = transSender.contract
        else:
            contractAddr = self.manager.getNode(
                cryptostuff.keyToBytes(pubKeyTransSender))
        if sender == 0:
            res = False

        res = self.manager.checkMsg(contractAddr, sig)
        msg = packers.VerifyMsg(consts.TYPE_CH, sig, pubKeyTransSender,
                                self.pubKey, res).genMsg()
        self.sendTCP(msg, sender.IP, sender.port)
Ejemplo n.º 3
0
Archivo: CH.py Proyecto: APWHY/carlsb
    def sendTransaction(self, pubKey, sig):
        check, sender = self.checkCM(pubKey)
        if not check:
            for d in self.CMs:
                print(d.pubKey.public_numbers())
            print(pubKey.public_numbers(), sig)
            raise AssertionError(
                "Attempt to send transaction from unregistered CM")

        # I store the public Key as string because I ran into problems with dynamic byte arrays in dicts for solidity
        # That may have been due to another issue which has since been resolved since this decision was made fairly early on
        pubKeyBytes = cryptostuff.keyToBytes(pubKey)

        if sender.contract == "":  # The CM doesn't have an Individual contract yet
            self.manager.addNode(pubKeyBytes, sig)
            sender.contract = self.manager.getNode(pubKeyBytes)
        else:
            self.manager.postMsg(sender.contract, sig)

        self.sendTCP(
            packers.TransMsg(consts.TYPE_CH, sig, self.pubKey).genMsg(),
            sender.IP, sender.port)
Ejemplo n.º 4
0
 def genMsg(self):
     values = (self.msgType, self.nodeType, self.signature,
               cryptostuff.keyToBytes(self.key))
     return self.fmt.pack(*values)  # splat
Ejemplo n.º 5
0
 def genMsg(self):
     values = (self.msgType, self.nodeType, self.signature,
               cryptostuff.keyToBytes(self.keyTransSender),
               cryptostuff.keyToBytes(self.keySender), self.result)
     return self.fmt.pack(*values)  # splat