You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html#impl-From%3C%26%27_%20bitcoin%3A%3Ahashes%3A%3Asha256d%3A%3AHash%3E">Message::from</a> method takes anything that implements the promises to be a thirty two byte hash i.e., 32 bytes that came from a cryptographically secure hashing algorithm.</p>
491
491
<p>We compute the signature <code>sig</code> by using the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Secp256k1.html#method.sign_ecdsa"><code>sign_ecdsa</code></a> method.
492
-
It takes a refence to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.SecretKey.html"><code>SecretKey</code></a> as arguments,
492
+
It takes a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.SecretKey.html"><code>SecretKey</code></a> as arguments,
493
493
and returns a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/ecdsa/struct.Signature.html"><code>Signature</code></a> type.</p>
494
494
<p>In the next step, we update the witness stack for the input we just signed by first converting the <code>sighash_cache</code> into a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a>
495
495
by using the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/struct.SighashCache.html#method.into_transaction"><code>into_transaction</code></a> method.
<p>We will be unwraping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
522
+
<p>We will be unwrapping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
In a real application these would be actual secrets<supclass="footnote-reference"><ahref="#secp">3</a></sup>.
582
581
We use the <code>SecretKey::new</code> method to generate a random private key <code>sk</code>.
583
-
We then use the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html#method.from_secret_key"><code>Keypair::from_secret_key</code></a> method to instatiate a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html"><code>Keypair</code></a> type,
582
+
We then use the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html#method.from_secret_key"><code>Keypair::from_secret_key</code></a> method to instantiate a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html"><code>Keypair</code></a> type,
584
583
which is a data structure that holds a keypair consisting of a secret and a public key.
585
584
Note that <code>senders_keys</code> is generic over the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/trait.Signing.html"><code>Signing</code></a> trait.
586
585
This is used to indicate that is an instance of <code>Secp256k1</code> and can be used for signing.</p>
<li><code>input_index</code> is the index of the input we are signing; it is a <ahref="https://doc.rust-lang.org/std/primitive.usize.html"><code>usize</code></a> type.
821
820
We are using <code>0</code> since we only have one input.</li>
822
-
<li><code>&prevouts</code> is a refence to the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/enum.Prevouts.html"><code>Prevouts</code></a> enum that we defined earlier.
821
+
<li><code>&prevouts</code> is a reference to the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/enum.Prevouts.html"><code>Prevouts</code></a> enum that we defined earlier.
823
822
This is used to reference the outputs of previous transactions and also used to calculate our transaction value.</li>
824
823
<li><code>annex</code> is an optional argument that is used to pass the annex data.
825
824
We are not using it, so we are passing <code>None</code>.</li>
The <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html#impl-From%3C%26%27_%20bitcoin%3A%3Ahashes%3A%3Asha256d%3A%3AHash%3E">Message::from</a> method takes anything that implements the promises to be a thirty two byte hash i.e., 32 bytes that came from a cryptographically secure hashing algorithm.</p>
837
836
<p>We compute the signature <code>sig</code> by using the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Secp256k1.html#method.sign_schnorr"><code>sign_schnorr</code></a> method.
838
-
It takes a refence to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Keypair.html"><code>Keypair</code></a> as arguments,
837
+
It takes a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Keypair.html"><code>Keypair</code></a> as arguments,
839
838
and returns a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/ecdsa/struct.Signature.html"><code>Signature</code></a> type.</p>
840
839
<p>In the next step, we update the witness stack for the input we just signed by first converting the <code>sighash_cache</code> into a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a>
841
840
by using the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/struct.SighashCache.html#method.into_transaction"><code>into_transaction</code></a> method.
<p>We will be unwraping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
854
+
<p>We will be unwrapping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
Copy file name to clipboardExpand all lines: book/tx_segwit-v0.html
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -446,7 +446,7 @@ <h1 id="constructing-and-signing-transactions---segwit-v0"><a class="header" hre
446
446
This is the message that we will sign.
447
447
The <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html#impl-From%3C%26%27_%20bitcoin%3A%3Ahashes%3A%3Asha256d%3A%3AHash%3E">Message::from</a> method takes anything that implements the promises to be a thirty two byte hash i.e., 32 bytes that came from a cryptographically secure hashing algorithm.</p>
448
448
<p>We compute the signature <code>sig</code> by using the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Secp256k1.html#method.sign_ecdsa"><code>sign_ecdsa</code></a> method.
449
-
It takes a refence to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.SecretKey.html"><code>SecretKey</code></a> as arguments,
449
+
It takes a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.SecretKey.html"><code>SecretKey</code></a> as arguments,
450
450
and returns a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/ecdsa/struct.Signature.html"><code>Signature</code></a> type.</p>
451
451
<p>In the next step, we update the witness stack for the input we just signed by first converting the <code>sighash_cache</code> into a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a>
452
452
by using the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/struct.SighashCache.html#method.into_transaction"><code>into_transaction</code></a> method.
@@ -476,7 +476,7 @@ <h1 id="constructing-and-signing-transactions---segwit-v0"><a class="header" hre
476
476
This is due to the fact that we need to pay a fee for the transaction.</p>
<p>We will be unwraping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
479
+
<p>We will be unwrapping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
In a real application these would be actual secrets<supclass="footnote-reference"><ahref="#secp">3</a></sup>.
223
223
We use the <code>SecretKey::new</code> method to generate a random private key <code>sk</code>.
224
-
We then use the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html#method.from_secret_key"><code>Keypair::from_secret_key</code></a> method to instatiate a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html"><code>Keypair</code></a> type,
224
+
We then use the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html#method.from_secret_key"><code>Keypair::from_secret_key</code></a> method to instantiate a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/key/struct.Keypair.html"><code>Keypair</code></a> type,
225
225
which is a data structure that holds a keypair consisting of a secret and a public key.
226
226
Note that <code>senders_keys</code> is generic over the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/trait.Signing.html"><code>Signing</code></a> trait.
227
227
This is used to indicate that is an instance of <code>Secp256k1</code> and can be used for signing.</p>
<li><code>input_index</code> is the index of the input we are signing; it is a <ahref="https://doc.rust-lang.org/std/primitive.usize.html"><code>usize</code></a> type.
462
462
We are using <code>0</code> since we only have one input.</li>
463
-
<li><code>&prevouts</code> is a refence to the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/enum.Prevouts.html"><code>Prevouts</code></a> enum that we defined earlier.
463
+
<li><code>&prevouts</code> is a reference to the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/enum.Prevouts.html"><code>Prevouts</code></a> enum that we defined earlier.
464
464
This is used to reference the outputs of previous transactions and also used to calculate our transaction value.</li>
465
465
<li><code>annex</code> is an optional argument that is used to pass the annex data.
466
466
We are not using it, so we are passing <code>None</code>.</li>
The <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html#impl-From%3C%26%27_%20bitcoin%3A%3Ahashes%3A%3Asha256d%3A%3AHash%3E">Message::from</a> method takes anything that implements the promises to be a thirty two byte hash i.e., 32 bytes that came from a cryptographically secure hashing algorithm.</p>
478
478
<p>We compute the signature <code>sig</code> by using the <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Secp256k1.html#method.sign_schnorr"><code>sign_schnorr</code></a> method.
479
-
It takes a refence to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Keypair.html"><code>Keypair</code></a> as arguments,
479
+
It takes a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Message.html"><code>Message</code></a> and a reference to a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/struct.Keypair.html"><code>Keypair</code></a> as arguments,
480
480
and returns a <ahref="https://docs.rs/secp256k1/0.29.0/secp256k1/ecdsa/struct.Signature.html"><code>Signature</code></a> type.</p>
481
481
<p>In the next step, we update the witness stack for the input we just signed by first converting the <code>sighash_cache</code> into a <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a>
482
482
by using the <ahref="https://docs.rs/bitcoin/0.32.0/bitcoin/sighash/struct.SighashCache.html#method.into_transaction"><code>into_transaction</code></a> method.
<p>We will be unwraping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
496
+
<p>We will be unwrapping any <ahref="https://doc.rust-lang.org/std/option"><code>Option<T></code></a>/<ahref="https://doc.rust-lang.org/std/result"><code>Result<T, E></code></a>
0 commit comments