2

I've been way in over my head hacking around in various Python Bitcoin libraries. From what I understand, input public keys have to be compressed to be accepted. Is that correct? I have an uncompressed address that I am trying to send funds from.

If I compress the input public key it shows the input address as the compressed version which shows no balance in block explorers. However, I get a Signature must be zero for failed CHECK(MULTI)SIG operation error when I try to broadcast this transaction.

This is the transaction: 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000008b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d414104e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000

If I do not compress the input I get this error: Script failed an OP_EQUALVERIFY operation

And this is the uncompressed key transaction: 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000006b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d412103e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000

Am I correct in understanding that OP_CHECKSIG comes after OP_EQUALVERIFY, so the first transaction is closer to being valid? And thus all I need to do is fix the signature? Or is there something else I'm missing?

Thank you!

5
  • All I can say is, "Whoops".
    – gotnull
    Nov 24, 2017 at 4:52
  • I didn't leak a private key by mistake, did I?
    – sega01
    Nov 24, 2017 at 14:17
  • No. Publishing invalid signature twice does not cause leaking private key. Usually :)
    – amaclin
    Nov 24, 2017 at 17:19
  • 1
    Good day? Do you resolve this problem with bitcash? Same situation Jan 25, 2018 at 9:23
  • @AlexMuravyov yes! This works in bitcash now.
    – sega01
    Feb 5, 2018 at 18:12

1 Answer 1

1

first (uncompressed pubkey):

sendrawtransaction 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000008b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d414104e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000
16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation) (code -26)

second (compressed pubkey):

sendrawtransaction 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000006b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d412103e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000
16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation) (code -26)

input: https://blockdozer.com/insight/tx/f8919b54de8ef3256799c90b8dfd147a92e732aff4c7df0251dd1d8cf090c9ed

from address: 1BJPrnDajNczh8cQw2cHGgWyCcRXRDWNFU

checking pubkeys:

void checkpub ( )
{
  const MyByteArray classic    ( QByteArray::fromHex ( "04e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19" ) );
  const MyByteArray compressed ( QByteArray::fromHex ( "03e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2" ) );
  qDebug ( ) << classic.hash160 ( ).toString ( );
  qDebug ( ) << compressed.hash160 ( ).toString ( );
}

the result:

"1BJPrnDajNczh8cQw2cHGgWyCcRXRDWNFU"
"1Fk7x75LYzySLi9e7wj9DBJkcAhe3kVcCa"

Conclusion: your first transaction with uncompressed public key is closer to be correct, but the signature is wrong. BitcoinCash has another algorithm for transaction digest calculation

3
  • Thank you! I thought maybe the "invalid signature" message was a bit generic and being thrown for the use of uncompressed keys in the transaction.
    – sega01
    Nov 24, 2017 at 13:57
  • BIP 143 says that uncompressed public keys are not allowed. Does that apply to Bitcoin Cash? github.com/bitcoin/bips/blob/master/…
    – sega01
    Nov 24, 2017 at 14:18
  • 2
    Uncompressed public keys are not allowed in segwit parts of Bitcoin. They are ok in regular Bitcoin/BitcoinCash transactions
    – amaclin
    Nov 24, 2017 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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