Skip to content

Commit

Permalink
Use 64 byte preimage.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Jun 28, 2022
1 parent cdca052 commit 22ac083
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2738,9 +2738,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
pub fn send_probe_payment(&self, route: &Route) -> Result<(PaymentHash, PaymentId), PaymentSendFailure> {
let payment_id = PaymentId(self.keys_manager.get_secure_random_bytes());

let mut preimage = [0u8; 32];
preimage[..16].copy_from_slice(&self.probing_cookie_secret[..16]);
preimage[16..].copy_from_slice(&payment_id.0[..16]);
let mut preimage = [0u8; 64];
preimage[..32].copy_from_slice(&self.probing_cookie_secret);
preimage[32..].copy_from_slice(&payment_id.0);

let payment_hash = PaymentHash(Sha256::hash(&preimage).into_inner());

Expand All @@ -2759,9 +2759,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
/// payment probe.
pub fn payment_is_probe(&self, payment_hash: PaymentHash, payment_id: PaymentId) -> bool {
let mut preimage = [0u8; 32];
preimage[..16].copy_from_slice(&self.probing_cookie_secret[..16]);
preimage[16..].copy_from_slice(&payment_id.0[..16]);
let mut preimage = [0u8; 64];
preimage[..32].copy_from_slice(&self.probing_cookie_secret);
preimage[32..].copy_from_slice(&payment_id.0);
let target_payment_hash = PaymentHash(Sha256::hash(&preimage).into_inner());
target_payment_hash == payment_hash
}
Expand Down

0 comments on commit 22ac083

Please sign in to comment.