X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Fmessenger.rs;h=1a6e2614b72910976e8aef5ff434dc10eff495bf;hb=d5925f210ed9820ace75c5c1af6c43473ec6892b;hp=a3613605cdebbd1ff71014d827b70782e043a160;hpb=0d3adb8fa08474b6d893a373b78e0195d061cfe6;p=rust-lightning diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index a3613605..1a6e2614 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -15,7 +15,9 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; -use crate::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs, utils}; +use crate::blinded_path::BlindedPath; +use crate::blinded_path::message::{advance_path_by_one, ForwardTlvs, ReceiveTlvs}; +use crate::blinded_path::utils; use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient}; use crate::events::OnionMessageProvider; use crate::ln::features::{InitFeatures, NodeFeatures}; @@ -297,7 +299,7 @@ where let our_node_id = self.node_signer.get_node_id(Recipient::Node) .map_err(|()| SendError::GetNodeIdFailed)?; if blinded_path.introduction_node_id == our_node_id { - blinded_path.advance_message_path_by_one(&self.node_signer, &self.secp_ctx) + advance_path_by_one(blinded_path, &self.node_signer, &self.secp_ctx) .map_err(|()| SendError::BlindedPathAdvanceFailed)?; } } @@ -490,7 +492,7 @@ where // unwrapping the onion layers to get to the final payload. Since we don't have the option // of creating blinded paths with dummy hops currently, we should be ok to not handle this // for now. - let new_pubkey = match onion_utils::next_hop_packet_pubkey(&self.secp_ctx, msg.onion_routing_packet.public_key, &onion_decode_ss) { + let new_pubkey = match onion_utils::next_hop_pubkey(&self.secp_ctx, msg.onion_routing_packet.public_key, &onion_decode_ss) { Ok(pk) => pk, Err(e) => { log_trace!(self.logger, "Failed to compute next hop packet pubkey: {}", e); @@ -507,21 +509,16 @@ where blinding_point: match next_blinding_override { Some(blinding_point) => blinding_point, None => { - let blinding_factor = { - let mut sha = Sha256::engine(); - sha.input(&msg.blinding_point.serialize()[..]); - sha.input(control_tlvs_ss.as_ref()); - Sha256::from_engine(sha).into_inner() - }; - let next_blinding_point = msg.blinding_point; - match next_blinding_point.mul_tweak(&self.secp_ctx, &Scalar::from_be_bytes(blinding_factor).unwrap()) { + match onion_utils::next_hop_pubkey( + &self.secp_ctx, msg.blinding_point, control_tlvs_ss.as_ref() + ) { Ok(bp) => bp, Err(e) => { log_trace!(self.logger, "Failed to compute next blinding point: {}", e); return } } - }, + } }, onion_routing_packet: outgoing_packet, }; @@ -653,46 +650,48 @@ fn packet_payloads_and_keys