Esempio n. 1
0
    def onVerify(self):
        # check fields
        addy = self.ui.addressLineEdit.text().strip()
        if len(addy) == 0:
            mess = "No address inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no address', mess)
            return
        if not checkPivxAddr(addy, True) and not checkPivxAddr(addy, False):
            mess = "PIVX address not valid. Insert valid PIVX address"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - invalid address', mess)
            return
        if self.ui.messageTextEdt.document().isEmpty():
            mess = "No message inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no message', mess)
            return
        if self.ui.signatureTextEdt.document().isEmpty():
            mess = "No signature inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)
            return

        try:
            ok = ecdsa_verify_addr(self.ui.messageTextEdt.toPlainText(),
                                   self.ui.signatureTextEdt.toPlainText(),
                                   self.ui.addressLineEdit.text().strip())
        except Exception as e:
            mess = "Error decoding signature:\n" + str(e)
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - invalid signature', mess)
            ok = False
        if ok:
            mess = "<span style='color: green'>Signature OK"
        else:
            mess = "<span style='color: red'>Signature doesn't verify"
        mess = "<b>" + mess + "</span></b>"
        self.ui.resultLabel.setText(mess)
        self.ui.resultLabel.setVisible(True)
Esempio n. 2
0
 def displaySignature(self, sig):
     if sig == "None":
         self.ui.signatureTextEdt.setText("Signature refused by the user")
         return
     from utils import b64encode
     self.ui.signatureTextEdt.setText(b64encode(sig))
     self.ui.copyBtn.setVisible(True)
     self.ui.saveBtn.setVisible(True)
     # verify sig
     ok = ecdsa_verify_addr(self.ui.messageTextEdt.toPlainText(), b64encode(sig), self.currAddress)
     if not ok:
         mess = "Signature doesn't verify."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)