Bitcoin Forum
May 07, 2024, 11:55:46 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: very difficult question about real verify the signature  (Read 198 times)
zhengjianxun (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
August 12, 2018, 12:04:40 PM
 #1

this question maybe some High difficulty , but it about important detail about bitcoin.real bitcoin expert can explain it.

i want to verify the signature in bitcoin.so i usesd the information in
https://blockchain.info/rawtx/5c76eb4dfb0941856a229833ef05b2f5c669dadc98ed2a34ea11974cacba9dc7?format=hex
this website is its hex serialize.

first:
0100000001107f46ae8f3ba0f1f9c5170f950a6fb0d6461a92718b5aa06ee776c4e114afdb00000 00048473044022014d647cd08f1ea5b31d1e6539b6cbceb9182f6e7b2e29fb969354ef7e3434923022 028bb4eda36af410149baa936322e7c0e46cc5540a3aa89c811bc3c360028bfd301ffffffff020a372f2d010000001976a9148ff0d9ee3c2c4b86d19d265cbd360e95c5191e3d88ac3 2ee9f00000000001976a9145c11f917883b927eef77dc57707aeb853f6d389488ac00000000

the red is the sig

second:
delete the sig

third:
add the previous output  script
https://blockchain.info/rawtx/dbaf14e1c476e76ea05a8b71921a46d6b06f0a950f17c5f9f1a03b8fae467f10?format=hex
it is 434104b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782 eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7bac

four :
add  to posithon of sig :
0100000001107f46ae8f3ba0f1f9c5170f950a6fb0d6461a92718b5aa06ee776c4e114afdb00000 000434104b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576 782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7bacffffffff020a372f2d0 10000001976a9148ff0d9ee3c2c4b86d19d265cbd360e95c5191e3d88ac32ee9f00000000001976 a9145c11f917883b927eef77dc57707aeb853f6d389488ac00000000

five :
add the hashtype:
01000000

so the code is :
0100000001107f46ae8f3ba0f1f9c5170f950a6fb0d6461a92718b5aa06ee776c4e114afdb00000 000434104b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576 782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7bacffffffff020a372f2d0 10000001976a9148ff0d9ee3c2c4b86d19d265cbd360e95c5191e3d88ac32ee9f00000000001976 a9145c11f917883b927eef77dc57707aeb853f6d389488ac0000000001000000

six:
double hash256 is :
f27c6c3aa42563c958292922be1e53fe107f4db0dfadba11122f0b12bf77f3ab

but when i want to verify it ,false,false,false  so  what happend , i think i am right!!


the verify go code is :

package main

import (
   "crypto/ecdsa"
   "crypto/elliptic"
   "fmt"
   "math/big"
   "encoding/hex"
)


func main(){


   pubkey,_:=hex.DecodeString("b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668 a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b");



   curve := elliptic.P256()
   //公钥的长度
   keyLen := len(pubkey)

   x := big.Int{}
   y := big.Int{}
   x.SetBytes(pubkey[:(keyLen / 2)])
   y.SetBytes(pubkey[(keyLen / 2):])

   rawPubKey := ecdsa.PublicKey{curve, &x, &y}


   //hash
   hash,_:=hex.DecodeString("f27c6c3aa42563c958292922be1e53fe107f4db0dfadba11122f0b12bf77f3ab   ")


   
   r := big.Int{}
   s := big.Int{}
   rr,_:=hex.DecodeString("14d647cd08f1ea5b31d1e6539b6cbceb9182f6e7b2e29fb969354ef7e3434923")
   ss,_:=hex.DecodeString("28bb4eda36af410149baa936322e7c0e46cc5540a3aa89c811bc3c360028bfd3")

   r.SetBytes(rr)
   s.SetBytes(ss)

   

   if ecdsa.Verify(&rawPubKey, hash[:], &r, &s) == false {
      fmt.Printf("%s\n", "true")
   }else{
      fmt.Printf("%s\n", "false")
   }

}





Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
pebwindkraft
Sr. Member
****
Offline Offline

Activity: 257
Merit: 343


View Profile
August 12, 2018, 03:34:22 PM
Merited by Welsh (4)
 #2

an indirect answer:
I have quickly double checked your data with some of my scripts. The replacement of the transaction and the created double hash value seems to be correct. I am not understanding the pubkey you use in the function main().

When I am using the pubkey of the pubkey script you extracted (of course without the length field and without hex "ac" at the end), then it runs ok.

######################################################################
using the reference from here: http://bitcoin.stackexchange.com/questions/46455/ I get this result:  

pubkey in HEX: 04b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba6 68a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b
pubkey in PEM format:
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEsL1jQjSruxuh6YbohBhcYc9D4AH5E38j
wsQJJz6xbmU3pXZ4Lrpmin74vTs8+x7bcRerZRKbii5oHzweCQjvew==
-----END PUBLIC KEY-----

sha256: f27c6c3aa42563c958292922be1e53fe107f4db0dfadba11122f0b12bf77f3ab

ScriptSig:     3044022014d647cd08f1ea5b31d1e6539b6cbceb9182f6e7b2e29fb969354ef7e3434923022028b b4eda36af410149baa936322e7c0e46cc5540a3aa89c811bc3c360028bfd3

*** Signature Verified Successfully ***  Smiley
zhengjianxun (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
August 13, 2018, 12:01:03 AM
 #3

very thinks your work , so you make me know  the calculate hash is true、the public key is true, so the real problem is my go code about verify the signature!!

very thinks your patient, Grin Grin
zhengjianxun (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
August 13, 2018, 07:01:17 AM
 #4

an indirect answer:
I have quickly double checked your data with some of my scripts. The replacement of the transaction and the created double hash value seems to be correct. I am not understanding the pubkey you use in the function main().

When I am using the pubkey of the pubkey script you extracted (of course without the length field and without hex "ac" at the end), then it runs ok.

######################################################################
using the reference from here: http://bitcoin.stackexchange.com/questions/46455/ I get this result:  

pubkey in HEX: 04b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba6 68a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b
pubkey in PEM format:
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEsL1jQjSruxuh6YbohBhcYc9D4AH5E38j
wsQJJz6xbmU3pXZ4Lrpmin74vTs8+x7bcRerZRKbii5oHzweCQjvew==
-----END PUBLIC KEY-----

sha256: f27c6c3aa42563c958292922be1e53fe107f4db0dfadba11122f0b12bf77f3ab

ScriptSig:     3044022014d647cd08f1ea5b31d1e6539b6cbceb9182f6e7b2e29fb969354ef7e3434923022028b b4eda36af410149baa936322e7c0e46cc5540a3aa89c811bc3c360028bfd3

*** Signature Verified Successfully ***  Smiley

very thinks your work , so you make me know  the calculate hash is true、the public key is true, so the real problem is my go code about verify the signature!!
very thinks your patient, Grin Grin
but i also don't konw where my go code fault
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!