Skip to content

Commit

Permalink
Message verification update
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed Sep 22, 2018
1 parent 7b3a917 commit 5a6fa0a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Gui/Common/SignMessageDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,25 @@ void SignMessageDialog::verifyMessage() {
Crypto::Hash hash;
Crypto::cn_fast_hash(message.data(), message.size(), hash);
const size_t header_len = strlen("SigV1");
if (!signature.size() < header_len || signature.substr(0, header_len) == "SigV1") {
std::string decoded;
Crypto::Signature s;
if (Tools::Base58::decode(signature.substr(header_len), decoded) || sizeof(s) == decoded.size()) {
memcpy(&s, decoded.data(), sizeof(s));
bool valid = Crypto::check_signature(hash, acc.spendPublicKey, s);
if (valid) {
m_ui->m_verificationResult->setText(tr("Signature is valid"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : green; }");
} else {
m_ui->m_verificationResult->setText(tr("Signature is invalid!"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : red; }");
}
std::string decoded;
Crypto::Signature s;
if (!signature.size() < header_len && signature.substr(0, header_len) == "SigV1" &&
Tools::Base58::decode(signature.substr(header_len), decoded) && sizeof(s) == decoded.size()) {
memcpy(&s, decoded.data(), sizeof(s));
if (Crypto::check_signature(hash, acc.spendPublicKey, s)) {
m_ui->m_verificationResult->setText(tr("Signature is valid"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : green; }");
} else {
m_ui->m_verificationResult->setText(tr("Signature is invalid!"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : red; }");
}
} else {
m_ui->m_verificationResult->setText(tr("Signature is invalid!"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : red; }");
}
} else {
m_ui->m_verificationResult->setText(tr("Address is invalid!"));
m_ui->m_verificationResult->setStyleSheet("QLabel { color : red; }");
}
}

Expand Down

0 comments on commit 5a6fa0a

Please sign in to comment.