Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 922 Lines • ▼ Show 20 Lines | try { | ||||
return set_error( | return set_error( | ||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | ||||
} | } | ||||
valtype &vchSig = stacktop(-3); | valtype &vchSig = stacktop(-3); | ||||
valtype &vchMessage = stacktop(-2); | valtype &vchMessage = stacktop(-2); | ||||
valtype &vchPubKey = stacktop(-1); | valtype &vchPubKey = stacktop(-1); | ||||
// The size of the message must be 32 bytes. | |||||
if (vchMessage.size() != 32) { | |||||
return set_error(serror, | |||||
SCRIPT_ERR_INVALID_OPERAND_SIZE); | |||||
} | |||||
if (!CheckDataSignatureEncoding(vchSig, flags, | if (!CheckDataSignatureEncoding(vchSig, flags, | ||||
serror) || | serror) || | ||||
!CheckPubKeyEncoding(vchPubKey, flags, serror)) { | !CheckPubKeyEncoding(vchPubKey, flags, serror)) { | ||||
// serror is set | // serror is set | ||||
return false; | return false; | ||||
} | } | ||||
bool fSuccess = false; | bool fSuccess = false; | ||||
if (vchSig.size()) { | if (vchSig.size()) { | ||||
uint256 message(vchMessage); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << vchMessage; | |||||
uint256 message = ss.GetHash(); | |||||
Mengerian: Does ss.GetHash() return double-SHA256? That's how I wrote it in the Spec.
Maybe this is crazy… | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsCorrect, this is double-sha256. jasonbcox: Correct, this is double-sha256. | |||||
MengerianUnsubmitted Not Done Inline ActionsOK, thanks. That confirms the spec is worded properly. You can ignore the rest of my above comment.. It was just an idea, but unclear if it's a benefit, and not worth changing this late. Mengerian: OK, thanks. That confirms the spec is worded properly.
You can ignore the rest of my above… | |||||
CPubKey pubkey(vchPubKey); | CPubKey pubkey(vchPubKey); | ||||
fSuccess = pubkey.Verify(message, vchSig); | fSuccess = pubkey.Verify(message, vchSig); | ||||
} | } | ||||
if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && | if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && | ||||
vchSig.size()) { | vchSig.size()) { | ||||
return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); | return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 713 Lines • Show Last 20 Lines |
Does ss.GetHash() return double-SHA256? That's how I wrote it in the Spec.
Maybe this is crazy, but would it be possible to have the opcode use single-SHA256 for the hash function?
That would make it easier to construct transaction with spend conditions based on SigHashes of other unrelated transactions being signed.
Eg: https://bitco.in/forum/threads/gold-collapsing-bitcoin-up.16/page-1213#post-75916