Signing transactions with un/compressed key

0

Good day.

I've created 2 addresses from the same private key. One address is of course compressed, while the other isn't.

compressed_public_key = "025d9a1a0a5dab7e3e4a84c30a42ddc0d71b2da0fa1f3b99fbda9fc03eb8c75cd5" 
corresponding_address = "mfjRUvWr9QZadpiRnbRfHS4UDSxdR9FE75"

uncompressed_public_key =  "045d9a1a0a5dab7e3e4a84c30a42ddc0d71b2da0fa1f3b99fbda9fc03eb8c75cd535a0b893f20338d37d20eebe2941859dfe53b175f0bb24a27bc77741f0bb8cac"
uncompressed_address = "mi4kMd3HcLUGJSouNdJZ87eUBbi7cNE6C3"

I've also send some coins to each address.

utxo_to_compressed = "963baf6eb615a09afcb05ebcdbd3db05a163994dd2035002477c753ba3281eff"
utxo_to_uncompressed = "08a1286bb379f6eb5151828505b934c1b917201592bb76bd252a53b7a3009b17"

Using bitcore I've created the private_key to sign the transactions and the utxos as follow:

privateKey = new bitcore.PrivateKey(BN, "testnet")

scriptSig =  "76a914" + hashedPubKey + "88ac";

And the hashed public keys are:
1bf398bb044e55f1971e384cc1e6d861dca3adb9 for the uncompressed 
025bafbac8a8a1fcbae04f9a6aa8b6f968c9d145 for the compressed

utxo_compressed = new bitcore.Transaction.UnspentOutput({
    "txId": "08a1286bb379f6eb5151828505b934c1b917201592bb76bd252a53b7a3009b17",
    "outputIndex": 0,
  "address": "mi4kMd3HcLUGJSouNdJZ87eUBbi7cNE6C3",
    "script": scriptSig,
    "satoshis": 5000000000
});

utxo_uncompressed = new bitcore.Transaction.UnspentOutput({
    "txId": "963baf6eb615a09afcb05ebcdbd3db05a163994dd2035002477c753ba3281eff",
    "outputIndex": 0,
  "address": "mfjRUvWr9QZadpiRnbRfHS4UDSxdR9FE75",
    "script": scriptSig,
    "satoshis": 5000000000
});

Signing the compressed utxo isn't a problem. But once I'm trying to sign the uncompressed transaction I receive an error message.

compressedTx = new bitcore.Transaction();
uncompressedTx = new bitcore.Transaction();
compressedTx.from(utxo).to(some output).sign(privateKey); <-This one works fine
uncompressedTx.from(utxo).to(some output).sign(privateKey); <-This one fails
//Some inputs have not been fully signed Use//

In the past, I've sent and redeemed transactions from uncompressed public key (I did it manually, using a simple python code). I can't seem to find any reason why the inputs weren't signed.

I'll highly appreciate any help you might have to offer

shultz

Posted 2016-12-05T10:38:00.770

Reputation: 171

Answers

1

compressed pubkey and uncompressed one have different hashes. so, your code should be something like:

scriptSig1 = "76a914" + hashedPubKey_1 + "88ac"; 
scriptSig2 = "76a914" + hashedPubKey_2 + "88ac"; 

amaclin

Posted 2016-12-05T10:38:00.770

Reputation: 5 763

Thank you for your comment. I'm indeed using 2 different hashed public keys. I'll update my original post ASAP to prevent further confusion.shultz 2016-12-05T13:59:00.250

Still, even though I'm using different hashed public key, I can't sign the uncompressed txshultz 2016-12-05T14:01:21.880

0

following code from sign.cpp about line25 now. Seems that the signing from uncompressed keys are purposed disabled in newer core code.

I didn't follow why that was disabled, maybe just to avoid potential hash collision in the future and keep data more standardized.

// Signing with uncompressed keys is disabled in witness scripts
if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed())
    return false;

Miya

Posted 2016-12-05T10:38:00.770

Reputation: 1

Uncompressed keys are only disabled for spending segwit outputs. The reason for disallowing them is to make transactions smaller and is unrelated to hash collisions.Andrew Chow 2018-06-13T00:06:10.487