You seem to be under the impression that addresses are generated from a scriptSig, which is wrong. Addresses are always generated off of the scriptPubKey
in the output of a transaction. The scriptSig
spends that scriptPubKey
. Inside of the the scriptPubKey
, there is a constant called a pubkeyhash
which is what is used to generate a bitcoin adddress. This pubkeyhash
will be different depending on if your pubkey
is compressed or uncompressed. Here is an example of a console session using bitcoin-s to demonstrate how compressed vs uncompressed public keys generate different addresses
chris@chris-870Z5E-880Z5E-680Z5E:~/dev/bitcoins-core$ sbt console
[info] Loading project definition from /home/chris/dev/bitcoins-core/project
[info] Set current project to bitcoin-s-core (in build file:/home/chris/dev/bitcoins-core/)
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_101).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import org.bitcoins.core.crypto._
import org.bitcoins.core.crypto._
scala> import org.bitcoins.core.protocol._
import org.bitcoins.core.protocol._
scala> val privKey = ECPrivateKey()
privKey: org.bitcoins.core.crypto.ECPrivateKey = ECPrivateKey(06e166f6d40cf6366bfa8f0b60f8f8526fde4095322af89ee9db64569f7db680,true)
scala> val pubKey = privKey.publicKey
pubKey: org.bitcoins.core.crypto.ECPublicKey = ECPublicKey(023e5970f3fdf82372ca6778837caff638caf81bdee7a8ba70f16130a299b6c5d6)
scala> val unCompressedPrivKey = ECPrivateKey.fromHex(privKey.hex,false)
unCompressedPrivKey: org.bitcoins.core.crypto.ECPrivateKey = ECPrivateKey(06e166f6d40cf6366bfa8f0b60f8f8526fde4095322af89ee9db64569f7db680,false)
scala> val unCompressedPublicKey = unCompressedPrivKey.publicKey
unCompressedPublicKey: org.bitcoins.core.crypto.ECPublicKey = ECPublicKey(043e5970f3fdf82372ca6778837caff638caf81bdee7a8ba70f16130a299b6c5d6e05500f2e535d80296db3c106ee9030a31c34c1723d5dbd64f39335f9d18e0aa)
scala> import org.bitcoins.core.config._
import org.bitcoins.core.config._
//note these two hashes are different ! ! !
scala> val pubKeyHash = CryptoUtil.sha256Hash160(pubKey.bytes)
pubKeyHash: org.bitcoins.core.crypto.Sha256Hash160Digest = Sha256Hash160DigestImpl(a83f9e96392c2b9809cdc5e0ef3893b3877e575d)
scala> val unCompressedPubKeyHash = CryptoUtil.sha256Hash160(unCompressedPublicKey.bytes)
unCompressedPubKeyHash: org.bitcoins.core.crypto.Sha256Hash160Digest = Sha256Hash160DigestImpl(f1492e86f3daff5ed261e60980b9b494f6c13ff6)
scala> val address = P2PKHAddress(pubKeyHash, MainNet)
address: org.bitcoins.core.protocol.P2PKHAddress = P2PKHAddressImpl(1GLcjb1qbbspXEGBoGdm7aaU51KK4iKAa3)
scala> val unCompressedAddress = P2PKHAddress(unCompressedPubKeyHash, MainNet)
unCompressedAddress: org.bitcoins.core.protocol.P2PKHAddress = P2PKHAddressImpl(1NzoWzJkPWbNENd3XkJNYf1S9BxhLThb8M)
So if you were to provide the uncompressed version of the public key in the scriptSig
instead of the compressed version (or vice versa if you hashed the uncompressed version with OP_HASH160
) you will get an error saying the data was not equivalent.