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
Generate local signatures with additional randomness
Previously, our local signatures would always be deterministic, whether
we'd grind for low R value signatures or not. For peers supporting
SegWit, Bitcoin Core will generally use a transaction's witness-txid, as
opposed to its txid, to advertise transactions. Therefore, to ensure a
transaction has the best chance to propagate across node mempools in the
network, each of its broadcast attempts should have a unique/distinct
witness-txid, which we can achieve by introducing random nonce data when
generating local signatures, such that they are no longer deterministic.
let witness_script = bitcoin::Address::p2pkh(&::bitcoin::PublicKey{compressed:true,inner: remotepubkey},Network::Testnet).script_pubkey();
715
715
let sighash = hash_to_message!(&sighash::SighashCache::new(spend_tx).segwit_signature_hash(input_idx,&witness_script, descriptor.output.value,EcdsaSighashType::All).unwrap()[..]);
716
-
let remotesig = sign(secp_ctx,&sighash,&self.payment_key);
716
+
let remotesig = sign_with_aux_rand(secp_ctx,&sighash,&self.payment_key,&self);
717
717
let payment_script = bitcoin::Address::p2wpkh(&::bitcoin::PublicKey{compressed:true,inner: remotepubkey},Network::Bitcoin).unwrap().script_pubkey();
718
718
719
719
if payment_script != descriptor.output.script_pubkey{returnErr(());}
@@ -749,7 +749,7 @@ impl InMemorySigner {
749
749
let delayed_payment_pubkey = PublicKey::from_secret_key(&secp_ctx,&delayed_payment_key);
750
750
let witness_script = chan_utils::get_revokeable_redeemscript(&descriptor.revocation_pubkey, descriptor.to_self_delay,&delayed_payment_pubkey);
751
751
let sighash = hash_to_message!(&sighash::SighashCache::new(spend_tx).segwit_signature_hash(input_idx,&witness_script, descriptor.output.value,EcdsaSighashType::All).unwrap()[..]);
752
-
let local_delayedsig = sign(secp_ctx,&sighash,&delayed_payment_key);
752
+
let local_delayedsig = sign_with_aux_rand(secp_ctx,&sighash,&delayed_payment_key,&self);
753
753
let payment_script = bitcoin::Address::p2wsh(&witness_script,Network::Bitcoin).script_pubkey();
754
754
755
755
if descriptor.output.script_pubkey != payment_script {returnErr(());}
@@ -810,7 +810,7 @@ impl EcdsaChannelSigner for InMemorySigner {
810
810
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey,&self.counterparty_pubkeys().funding_pubkey);
811
811
812
812
let built_tx = trusted_tx.built_transaction();
813
-
let commitment_sig = built_tx.sign(&self.funding_key,&channel_funding_redeemscript,self.channel_value_satoshis, secp_ctx);
813
+
let commitment_sig = built_tx.sign_counterparty_commitment(&self.funding_key,&channel_funding_redeemscript,self.channel_value_satoshis, secp_ctx);
@@ -905,7 +905,7 @@ impl EcdsaChannelSigner for InMemorySigner {
905
905
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc,self.opt_anchors(),&counterparty_htlcpubkey,&htlcpubkey,&revocation_pubkey);
if payment_script != output.script_pubkey{returnErr(());};
1274
1274
1275
1275
let sighash = hash_to_message!(&sighash::SighashCache::new(&spend_tx).segwit_signature_hash(input_idx,&witness_script, output.value,EcdsaSighashType::All).unwrap()[..]);
1276
-
let sig = sign(secp_ctx,&sighash,&secret.private_key);
1276
+
let sig = sign_with_aux_rand(secp_ctx,&sighash,&secret.private_key,&self);
let htlc_redeemscript = get_htlc_redeemscript_with_explicit_keys(&this_htlc,self.opt_anchors(),&keys.broadcaster_htlc_key,&keys.countersignatory_htlc_key,&keys.revocation_key);
1578
1590
1579
1591
let sighash = hash_to_message!(&sighash::SighashCache::new(&htlc_tx).segwit_signature_hash(0,&htlc_redeemscript, this_htlc.amount_msat / 1000,EcdsaSighashType::All).unwrap()[..]);
0 commit comments