Transactions

兩個相同的 R 值從兩個事務中找到 z 值

  • February 13, 2020

TX1

從我得到的 trans1

輸入腳本

30450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a6917101       
046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4

R = 262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b

S2 = bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a69171

tx1 原始反式

01000000012eb64643254262722e33e72cb2ad67fecb6ae2fd812d2f2bff217458715e11a0000000008b4830450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a691710141046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4ffffffff02a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88aca0252600000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88ac00000000

計算 z2

用相應的輸出腳本替換輸入

01000000012eb64643254262722e33e72cb2ad67fecb6ae2fd812d2f2bff217458715e11a0000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88acffffffff02a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88aca0252600000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88ac0000000001000000

然後做 sha256(sha256(修改過的交易))

Z2 = e2b8acb01c0ea6a2a1273fc9dbbe3cdd58c68afb54e240e1f51abcc652468204

TX2

從 TX2

輸入腳本

30450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d1901      
046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4

S1 = d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d19

tx2 原始反式

010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000008b4830450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d190141046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4ffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac00000000

計算 z1

用相應的輸出腳本替換輸入

010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88acffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac0000000001000000

然後做 sha256(sha256(修改過的交易))

我得到 Z1 = f62dab861eb451dad7cc74fa9f754e4d233b5fb80b1327fd623f5617e1f46d21

但正確的 z1 值是

z1 = 66042ab1a1befe137de5328ff1d4b263604824fe33c739d3a80565afdd94b34d

計算有什麼問題

計算 z1

用相應的輸出腳本替換輸入

這是您犯了一個小錯誤的步驟。

花費的 UTXO 來自txid 9312ccafb8aa624afe7fb7b4201a0ccc2a14ca2b8b8a3253093b975a6a85a280,其中包含兩個 txout。當您進行腳本替換時,您選擇了 txout #0(hash160 為 cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d),但被簽名的 tx 花費了 txout #1(hash160 為 09a4cb092dc30da1354369fc78f482365ce2767a)。

使用正確的 txout 腳本進行替換會導致這種情況,它會散列到您期望的 z1 值:

010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88acffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac0000000001000000

引用自:https://bitcoin.stackexchange.com/questions/37674