From 23d9514259d0e9f8d9caecd96c0818674aaf7d92 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 19 Apr 2024 00:28:09 +0000 Subject: [PATCH] Simplify and clarify `derive_add_tweak` documentation --- lightning/src/ln/channel_keys.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lightning/src/ln/channel_keys.rs b/lightning/src/ln/channel_keys.rs index 423d41074..76dc1e42b 100644 --- a/lightning/src/ln/channel_keys.rs +++ b/lightning/src/ln/channel_keys.rs @@ -38,13 +38,13 @@ macro_rules! basepoint_impl { self.0 } - /// Derives a per-commitment-transaction (eg an htlc key or delayed_payment key) private key addition tweak - /// from a basepoint and a per_commitment_point: + /// Derives the "tweak" used to calculate the per-commitment private key. + /// + /// The per-commitment private key is calculates a private key as: /// `privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)` - /// This calculates the hash part in the tweak derivation process, which is used to ensure - /// that each key is unique and cannot be guessed by an external party. It is equivalent - /// to the `from_basepoint` method, but without the addition operation, providing just the - /// tweak from the hash of the per_commitment_point and the basepoint. + /// + /// This calculates the hash part in the tweak derivation process, which is used to + /// ensure that each key is unique and cannot be guessed by an external party. pub fn derive_add_tweak(&self, per_commitment_point: &PublicKey) -> [u8; 32] { let mut sha = Sha256::engine(); sha.input(&per_commitment_point.serialize()); -- 2.39.5