Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoin::Protocol::Tx#verify_input_signature に渡す引数 #2

Closed
cleemy-desu-wayo opened this issue Oct 4, 2022 · 2 comments
Closed

Comments

@cleemy-desu-wayo
Copy link

Chapter06の Bitcoin::Protocol::Tx#verify_input_signature を使用している箇所(書籍ではP.158)で

#0番目のアウトプットについて署名を検証

とあるのですが、こちらは「UTXOが含まれるトランザクション」においてではなく新しく生成したトランザクション(これから署名しようとしているトランザクション)においては、「0番目のインプットについて署名を検証」という理解であってますでしょうか?

bitcoin-rubyのソースでは、#verify_input_signature に渡す最初の引数をインデックスとして @ in という Array を参照しているようです。
https://github.com/lian/bitcoin-ruby/blob/0a90a568bfb791c3a437da3a7a99a90a319f4e46/lib/bitcoin/protocol/tx.rb#L315
ちなみに @ in の各要素は Bitcoin::Protocol::TxIn のインスタンスで、TxIn には prev_out_index というアクセサがあるようです。
https://github.com/lian/bitcoin-ruby/blob/0a90a568bfb791c3a437da3a7a99a90a319f4e46/lib/bitcoin/protocol/txin.rb#L15

@azuchi
Copy link

azuchi commented Oct 4, 2022

「0番目のインプットについて署名を検証」という理解であってますでしょうか?

はい。合ってます。UTXOを使用するトランザクション、つまりそのUTXOをインプットとして作られたトランザクションの署名を検証します。

@cleemy-desu-wayo
Copy link
Author

ありがとうございます。

ところで

(これから署名しようとしているトランザクション)

という言い方は変でしたね。
「署名したばかりのトランザクション(を複製したもの)」であると同時に「これからブロードキャストする予定のトランザクション(を複製したもの)」ですね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants