From: Matt Corallo Date: Mon, 27 Nov 2023 18:18:04 +0000 (+0000) Subject: Change `RevocationKey` args to make clear one side is a countersig X-Git-Tag: v0.0.120~14^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e4f690cd4c58050b982a24fc9a600dd922d299e7;p=rust-lightning Change `RevocationKey` args to make clear one side is a countersig 935a716cc6c4fada075e2b740a70bb1b7b349d49 changed the parameter names to `RevocationKey` derivation to remove the naming which made clear one of the two parameters is a countersignatory key, which is restored here. --- diff --git a/lightning/src/ln/channel_keys.rs b/lightning/src/ln/channel_keys.rs index 19b7b84c5..3ea9ac01a 100644 --- a/lightning/src/ln/channel_keys.rs +++ b/lightning/src/ln/channel_keys.rs @@ -194,12 +194,12 @@ impl RevocationKey { /// [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key pub fn from_basepoint( secp_ctx: &Secp256k1, - basepoint: &RevocationBasepoint, + countersignatory_basepoint: &RevocationBasepoint, per_commitment_point: &PublicKey, ) -> Self { let rev_append_commit_hash_key = { let mut sha = Sha256::engine(); - sha.input(&basepoint.to_public_key().serialize()); + sha.input(&countersignatory_basepoint.to_public_key().serialize()); sha.input(&per_commitment_point.serialize()); Sha256::from_engine(sha).to_byte_array() @@ -207,12 +207,12 @@ impl RevocationKey { let commit_append_rev_hash_key = { let mut sha = Sha256::engine(); sha.input(&per_commitment_point.serialize()); - sha.input(&basepoint.to_public_key().serialize()); + sha.input(&countersignatory_basepoint.to_public_key().serialize()); Sha256::from_engine(sha).to_byte_array() }; - let countersignatory_contrib = basepoint.to_public_key().mul_tweak(&secp_ctx, &Scalar::from_be_bytes(rev_append_commit_hash_key).unwrap()) + let countersignatory_contrib = countersignatory_basepoint.to_public_key().mul_tweak(&secp_ctx, &Scalar::from_be_bytes(rev_append_commit_hash_key).unwrap()) .expect("Multiplying a valid public key by a hash is expected to never fail per secp256k1 docs"); let broadcaster_contrib = (&per_commitment_point).mul_tweak(&secp_ctx, &Scalar::from_be_bytes(commit_append_rev_hash_key).unwrap()) .expect("Multiplying a valid public key by a hash is expected to never fail per secp256k1 docs"); @@ -229,7 +229,6 @@ impl RevocationKey { key_read_write!(RevocationKey); - #[cfg(test)] mod test { use bitcoin::secp256k1::{Secp256k1, SecretKey, PublicKey};