Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: HeadsOrTails on July 28, 2015, 12:58:12 AM



Title: Validating DER sig (brainwallet Tx eg)
Post by: HeadsOrTails on July 28, 2015, 12:58:12 AM
https://blockchain.info/tx/54a44539ada32ea5eb218ed5d853a08712be6129d8ec752b8c77f6c88bfe721a (https://blockchain.info/tx/54a44539ada32ea5eb218ed5d853a08712be6129d8ec752b8c77f6c88bfe721a)

So we have:

  • sha256("cat")
  • sha256("password")

Code:
'01000000020fa5ed9983859c6703c5469bdda6f30ee2b59febe89d3e9755e601a35bfe837c020000007f3c303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302205eff1e344551d115b708155eed631cafa4fe719be5ec68c1f3abbf8670d34e11014104a45ebc40f95cc06ef93a5f5e9daa22774a5c9a120ac14d87c328b44c1158f81cddd109246a4d8bff5f93cbba79a17f2dc6e7c73da8d6bd0d98615d1bf353f8beffffffff0fa5ed9983859c6703c5469bdda6f30ee2b59febe89d3e9755e601a35bfe837c030000007f3c303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302201e74d38e5abd2836e9e17acf1b94f267b4f99704e2b22eac02ab136ec4740b76014104b568858a407a8721923b89df9963d30013639ac690cce5f555529b77b83cbfc76950f90be717e38a3ece1f5558f40179f8c2502deca11183bb3a3aea797736a6ffffffff01dc05000000000000232103d68f90ba81455256cb7a0df14fb3930d6df61393207f2f3e71659414d296e0f0ac00000000'

dersig1 = "3c303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302205eff1e344551d115b708155eed631cafa4fe719be5ec68c1f3abbf8670d34e11"
dersig2 = "3c303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302201e74d38e5abd2836e9e17acf1b94f267b4f99704e2b22eac02ab136ec4740b76"

How, using pybitcointools (or Python), does one validate these DER sigs (given we know both privkeys)?

(PS: if someone can weigh on this related question (https://bitcointalk.org/index.php?topic=1136084.0), I'd greatly appreciate it


Title: Re: Validating DER sig (brainwallet Tx eg)
Post by: amaclin on July 28, 2015, 01:49:05 PM
How, using pybitcointools (or Python), does one validate these DER sigs (given we know both privkeys)?
Throw away your knowledge of privkeys.
Validating ecdsa signature does not require privkeys.

Start from here
http://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx
http://www.nilsschneider.net/2013/01/28/recovering-bitcoin-private-keys.html
http://bitcoin.stackexchange.com/questions/32305/how-does-the-ecdsa-verification-algorithm-work-during-transaction

dersigs in your transaction (or may be is it my transaction?  ;D ) are
Code:
303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302205eff1e344551d115b708155eed631cafa4fe719be5ec68c1f3abbf8670d34e11
303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302201e74d38e5abd2836e9e17acf1b94f267b4f99704e2b22eac02ab136ec4740b76


Title: Re: Validating DER sig (brainwallet Tx eg)
Post by: doug_armory on July 29, 2015, 03:15:47 AM
How, using pybitcointools (or Python), does one validate these DER sigs (given we know both privkeys)?
Throw away your knowledge of privkeys.
Validating ecdsa signature does not require privkeys.

Start from here
http://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx
http://www.nilsschneider.net/2013/01/28/recovering-bitcoin-private-keys.html
http://bitcoin.stackexchange.com/questions/32305/how-does-the-ecdsa-verification-algorithm-work-during-transaction

dersigs in your transaction (or may be is it my transaction?  ;D ) are
Code:
303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302205eff1e344551d115b708155eed631cafa4fe719be5ec68c1f3abbf8670d34e11
303902153b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6302201e74d38e5abd2836e9e17acf1b94f267b4f99704e2b22eac02ab136ec4740b76

Strictly speaking, BC Core also treats the follow-up byte ("sighash (https://en.bitcoin.it/wiki/OP_CHECKSIG)") as part-and-parcel with the actual DER signature, even though it's not included as part of the DER encoding. In this case, both transactions are SIGHASH_ALL (0x01).


Title: Re: Validating DER sig (brainwallet Tx eg)
Post by: amaclin on July 29, 2015, 03:20:21 AM
Strictly speaking, BC Core also treats the follow-up byte
I told about first byte