3

Suppose I have two inputs belonging to the same address.

  • Do I need to provide a signature script for each input that proves that I own it? Wouldn't that waste space? Also, in the standard client, are the signatures exactly the same, or are they two different but valid signatures?
  • Or can I prove that I own that address just once?
2

Do I need to provide a signature script for each input that proves that I own it?

Only signing and checking signatures once for each public key, assuming signed with SIGHASH_ALL, seems like it would be safe, but I don't think there's any such optimization in the bitcoin code. If something was signed with SIGHASH_SINGLE, though, then it wouldn't be okay to assume that the owner of the key approves of all other outputs too.

Wouldn't that waste space?

Yes, and signatures are the largest single component of a bitcoin transaction, so it's a non-negligible space too. At the same time, though, spending from two UTXOs that were sent to the same address probably isn't the most common type of transaction.

Also, in the standard client, are the signatures exactly the same, or are they two different but valid signatures?

Looking at the SignatureHash code, the input scripSigs are all emptied and then only the one corresponding to the input that is being signed is filled with the previous scriptPubKey (for somewhat strange reasons).

// Blank out other inputs' signatures
for (unsigned int i = 0; i < txTmp.vin.size(); i++)
    txTmp.vin[i].scriptSig = CScript();
txTmp.vin[nIn].scriptSig = scriptCode;

This makes it so that the hash that needs to be signed (the result of SignatureHash) is different for each input. Thus, since different data is being signed, the signatures will most definitely be different. Even if the data being signed were the same, ECC signatures are non-deterministic (involving a random number) and so will not be the same from signing to signing.


EDIT: The long and short of it is that the double hash that needs to be signed is different for each input in the new transaction, so even if the same key pair is being used, a new signature must be calculated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.