qt: use CHashWriter also in SignVerifyMessageDialog

This eliminates unnecessary copying of data being hashed.
This commit is contained in:
Pavel Vasin 2015-07-28 09:05:14 +03:00
parent 08e9c57ba2
commit 5e56ef5152

View File

@ -148,12 +148,12 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
return; return;
} }
CDataStream ss(SER_GETHASH, 0); CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic; ss << strMessageMagic;
ss << ui->messageIn_SM->document()->toPlainText().toStdString(); ss << ui->messageIn_SM->document()->toPlainText().toStdString();
std::vector<unsigned char> vchSig; std::vector<unsigned char> vchSig;
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) if (!key.SignCompact(ss.GetHash(), vchSig))
{ {
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>")); ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>"));
@ -223,12 +223,12 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()
return; return;
} }
CDataStream ss(SER_GETHASH, 0); CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic; ss << strMessageMagic;
ss << ui->messageIn_VM->document()->toPlainText().toStdString(); ss << ui->messageIn_VM->document()->toPlainText().toStdString();
CPubKey pubkey; CPubKey pubkey;
if (!pubkey.RecoverCompact(Hash(ss.begin(), ss.end()), vchSig)) if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
{ {
ui->signatureIn_VM->setValid(false); ui->signatureIn_VM->setValid(false);
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");