Skip to content

Commit

Permalink
Remove entropy slice
Browse files Browse the repository at this point in the history
  • Loading branch information
rustaceanrob committed Apr 17, 2024
1 parent 4de1214 commit 51f8f6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
16 changes: 1 addition & 15 deletions crates/bdk/src/wallet/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ impl InputSigner for SignerWrapper<PrivateKey> {
hash,
hash_ty,
secp,
sign_options.aux_rand,
);
}
}
Expand Down Expand Up @@ -507,7 +506,6 @@ impl InputSigner for SignerWrapper<PrivateKey> {
hash,
hash_ty,
secp,
sign_options.aux_rand,
);
}
}
Expand Down Expand Up @@ -577,7 +575,6 @@ fn sign_psbt_schnorr(
hash: TapSighash,
hash_ty: TapSighashType,
secp: &SecpCtx,
aux_rand: Option<[u8; 32]>,
) {
let keypair = secp256k1::Keypair::from_seckey_slice(secp, secret_key.as_ref()).unwrap();
let keypair = match leaf_hash {
Expand All @@ -588,10 +585,7 @@ fn sign_psbt_schnorr(
};

let msg = &Message::from(hash);
let sig = match aux_rand {
Some(rand) => secp.sign_schnorr_with_aux_rand(msg, &keypair, &rand),
None => secp.sign_schnorr_no_aux_rand(msg, &keypair),
};
let sig = secp.sign_schnorr_no_aux_rand(msg, &keypair);
secp.verify_schnorr(&sig, msg, &XOnlyPublicKey::from_keypair(&keypair).0)
.expect("invalid or corrupted schnorr signature");

Expand Down Expand Up @@ -818,13 +812,6 @@ pub struct SignOptions {
/// or not.
/// Defaults to `true`, i.e., we always grind ECDSA signature to sign with low r.
pub allow_grinding: bool,

/// Add additional entropy to the signature using a random array of bytes.
///
/// Defaults to `None`. While recommended, additional entropy is not required.
///
/// See [`BIP 340`](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) for more details.
pub aux_rand: Option<[u8; 32]>,
}

/// Customize which taproot script-path leaves the signer should sign.
Expand Down Expand Up @@ -854,7 +841,6 @@ impl Default for SignOptions {
tap_leaves_options: TapLeavesOptions::default(),
sign_with_tap_internal_key: true,
allow_grinding: true,
aux_rand: None,
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/bdk/src/wallet/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ pub enum TxOrdering {
/// The custom function to order the inputs of the transaction
input_ordering: Box<dyn Fn(&TxIn, &TxIn) -> core::cmp::Ordering>,
/// The custom function to order the outputs of the transaction
output_ordering: Box<dyn Fn(&TxOut, &TxOut) -> core::cmp::Ordering>,
}
output_ordering: Box<dyn Fn(&TxOut, &TxOut) -> core::cmp::Ordering>,
},
}

impl TxOrdering {
Expand All @@ -855,7 +855,10 @@ impl TxOrdering {
tx.output
.sort_unstable_by_key(|txout| (txout.value, txout.script_pubkey.clone()));
}
TxOrdering::Custom { input_ordering, output_ordering } => {
TxOrdering::Custom {
input_ordering,
output_ordering,
} => {
tx.input.sort_unstable_by(input_ordering);
tx.output.sort_unstable_by(output_ordering);
}
Expand Down

0 comments on commit 51f8f6e

Please sign in to comment.