I've been looking through EthereumJ, Trying to understand how transaction hashing and signing works.
From what I can tell from the code, the signature is created by signing the hash of the RLP encoded transaction. The reason I'm confused, however, is because the hash is generated from the r and s values of the signature along with the rest. Considering those r and s values don't exist yet, how would they be included?
A bit more digging into the code looks like two different hashes are generated. One "raw" hash, in which the r and s values are simply empty byte arrays, which is the hash that gets signed, and then one actual hash, which includes the generated r and s values.
Is this understanding correct? Why bother including the signature in the signing process? As in, why doesn't the signature simply sign the hash of the non-signature elements of the transaction? Why does the "raw" hash include the v r and s values (even though the r and s are empty)?