Tuesday, November 5, 2024

bitcoin core – Verifying a P2WSH by hand

To check my understanding of the signing and verifying course of i attempted to confirm some random Bitcoin transactions by hand. Sadly i obtained caught with a P2WSH transaction, i select the next transaction with Hash c53b99c9fdba60fd47c6026177d3f6e1ed6d3abde8f433364619aa7d437dad26

With the uncooked transaction:

010000000001012198e5bc0860a4fcf420e2b909fce47e746357457b060c63571e12bd84fec4a70100000000ffffffff0220120a000000000017a91417b9a9afddaae527d25788bce2202563d4ab0d058784ea110000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d0400473044022014cd600863ad3c9f6802383fe814a693a77144117cf7694f63b558b8c02d801c02201c3ad9901f659742668caf770f3d7f89a3633f9ccd2bfdd6a7c6f7529fe7b43101473044022047e4ad9788da6b764e723dd71d9fe07a217e48871129a672ef2788eb0d331a7a02206107b10c23e8720df9f1e5f609c471726066c5b72c56ee774615498f8fe62e8d016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000

I can deserialize this to:


TX model quantity = 00000001
Inputs depend = 01
TX from hash = a7c4fe84bd121e57630c067b455763747ee4fc09b9e220f4fca46008bce59821
TX outpoint Index = 00000001
Enter script =
Sequence quantity = ffffffff
Outputs depend = 02
Worth(base 10) = 660000
Output script = a91417b9a9afddaae527d25788bce2202563d4ab0d0587
Worth(base 10) = 1174148
Output script = 0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d
Witness 0 0 = 00
Witness 0 1 = 473044022014cd600863ad3c9f6802383fe814a693a77144117cf7694f63b558b8c02d801c02201c3ad9901f659742668caf770f3d7f89a3633f9ccd2bfdd6a7c6f7529fe7b43101
Witness 0 2 = 473044022047e4ad9788da6b764e723dd71d9fe07a217e48871129a672ef2788eb0d331a7a02206107b10c23e8720df9f1e5f609c471726066c5b72c56ee774615498f8fe62e8d01
Witness 0 3 = 6952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae
Lock time = 00000000


Now i attempt to compute the MessageHash that will get signed:

with:
hashPrevouts = sha256²(2198e5bc0860a4fcf420e2b909fce47e746357457b060c63571e12bd84fec4a701000000)
hashSequence = sha256²(ffffffff)
hashOutputs = sha256²(20120a0000000000a91417b9a9afddaae527d25788bce2202563d4ab0d058784ea1100000000000020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d)

Model: 01000000
hashPrevouts: 65aa319c96c046e8589c758adf7441d335682d3fc76df649180c4f94a1c4a731
hashSequence: 3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044
outPoint: 2198e5bc0860a4fcf420e2b909fce47e746357457b060c63571e12bd84fec4a701000000
scriptCode: 6952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae
worth: 345c1d0000000000
nSequence: ffffffff
hashOutputs: 58d6a86eb99a911735d2f262a9fc13fcf0f8422d75e25ba04db120f65cf573d6
nLocktime: 00000000
sighash: 01000000


This can give me the MessageHash = 8560e61d0167f784d0cdaf9d45ba0e1be752e94d30a34339d976b01e50f0e366

But when i attempt to confirm this MessageHash with the primary Signature(473044022014cd600863ad3c9f6802383fe814a693a77144117cf7694f63b558b8c02d801c02201c3ad9901f659742668caf770f3d7f89a3633f9ccd2bfdd6a7c6f7529fe7b43101), which has R = 14cd600863ad3c9f6802383fe814a693a77144117cf7694f63b558b8c02d801c and S = 1c3ad9901f659742668caf770f3d7f89a3633f9ccd2bfdd6a7c6f7529fe7b431 in opposition to any of the three PubKeys in Witness 0 3, i all the time get the the Signature just isn’t legitimate.

Can somebody inform me the place i obtained unsuitable ?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles