From: Matt Corallo Date: Fri, 19 Apr 2024 00:28:09 +0000 (+0000) Subject: Simplify and clarify `derive_add_tweak` documentation X-Git-Tag: v0.0.123-rc1~5^2~5 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=23d9514259d0e9f8d9caecd96c0818674aaf7d92;p=rust-lightning Simplify and clarify `derive_add_tweak` documentation --- 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());