diff --git a/coins/bitcoin/src/crypto.rs b/coins/bitcoin/src/crypto.rs index bcb73936..741a0289 100644 --- a/coins/bitcoin/src/crypto.rs +++ b/coins/bitcoin/src/crypto.rs @@ -37,8 +37,9 @@ pub fn x_only(key: &ProjectivePoint) -> XOnlyPublicKey { XOnlyPublicKey::from_slice(&x(key)).expect("x_only was passed a point which was infinity or odd") } -/// Make a point even by adding the generator until it is even. Returns the even point and the -/// amount of additions required. +/// Make a point even by adding the generator until it is even. +/// +/// Returns the even point and the amount of additions required. pub fn make_even(mut key: ProjectivePoint) -> (ProjectivePoint, u64) { let mut c = 0; while key.to_encoded_point(true).tag() == Tag::CompressedOddY { @@ -51,6 +52,8 @@ pub fn make_even(mut key: ProjectivePoint) -> (ProjectivePoint, u64) { /// A BIP-340 compatible HRAm for use with the modular-frost Schnorr Algorithm. /// /// If passed an odd nonce, it will have the generator added until it is even. +/// +/// If the key is odd, this will panic. #[derive(Clone, Copy, Debug)] pub struct Hram; diff --git a/coins/bitcoin/src/wallet/mod.rs b/coins/bitcoin/src/wallet/mod.rs index ea91d2ae..d3575df2 100644 --- a/coins/bitcoin/src/wallet/mod.rs +++ b/coins/bitcoin/src/wallet/mod.rs @@ -24,12 +24,17 @@ mod send; pub use send::*; /// Tweak keys to ensure they're usable with Bitcoin. +/// +/// Taproot keys, which these keys are used as, must be even. This offsets the keys until they're +/// even. pub fn tweak_keys(keys: &ThresholdKeys) -> ThresholdKeys { let (_, offset) = make_even(keys.group_key()); keys.offset(Scalar::from(offset)) } /// Return the Taproot address for a public key. +/// +/// If the key is odd, this will return None. pub fn address(network: Network, key: ProjectivePoint) -> Option
{ if key.to_encoded_point(true).tag() != Tag::CompressedEvenY { return None; diff --git a/coins/bitcoin/src/wallet/send.rs b/coins/bitcoin/src/wallet/send.rs index 7e245407..3d18c47c 100644 --- a/coins/bitcoin/src/wallet/send.rs +++ b/coins/bitcoin/src/wallet/send.rs @@ -245,7 +245,7 @@ impl SignableTransaction { /// A FROST signing machine to produce a Bitcoin transaction. /// /// This does not support caching its preprocess. When sign is called, the message must be empty. -/// This will panic if it isn't. +/// This will panic if either `cache` is called or the message isn't empty. pub struct TransactionMachine { tx: SignableTransaction, sigs: Vec>>,