|
12 | 12 | pub(crate) mod message; |
13 | 13 | pub(crate) mod utils; |
14 | 14 |
|
15 | | -use bitcoin::hashes::{Hash, HashEngine}; |
16 | | -use bitcoin::hashes::sha256::Hash as Sha256; |
17 | | -use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; |
| 15 | +use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey}; |
18 | 16 |
|
19 | | -use crate::sign::{EntropySource, NodeSigner, Recipient}; |
20 | | -use crate::onion_message::ControlTlvs; |
| 17 | +use crate::sign::EntropySource; |
21 | 18 | use crate::ln::msgs::DecodeError; |
22 | | -use crate::ln::onion_utils; |
23 | | -use crate::util::chacha20poly1305rfc::ChaChaPolyReadAdapter; |
24 | | -use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeable, Writer}; |
| 19 | +use crate::util::ser::{Readable, Writeable, Writer}; |
25 | 20 |
|
26 | | -use core::mem; |
27 | | -use core::ops::Deref; |
28 | | -use crate::io::{self, Cursor}; |
| 21 | +use crate::io; |
29 | 22 | use crate::prelude::*; |
30 | 23 |
|
31 | 24 | /// Onion messages and payments can be sent and received to blinded paths, which serve to hide the |
@@ -79,42 +72,6 @@ impl BlindedPath { |
79 | 72 | blinded_hops: message::blinded_hops(secp_ctx, node_pks, &blinding_secret).map_err(|_| ())?, |
80 | 73 | }) |
81 | 74 | } |
82 | | - |
83 | | - // Advance the blinded onion message path by one hop, so make the second hop into the new |
84 | | - // introduction node. |
85 | | - pub(super) fn advance_message_path_by_one<NS: Deref, T: secp256k1::Signing + secp256k1::Verification> |
86 | | - (&mut self, node_signer: &NS, secp_ctx: &Secp256k1<T>) -> Result<(), ()> |
87 | | - where NS::Target: NodeSigner |
88 | | - { |
89 | | - let control_tlvs_ss = node_signer.ecdh(Recipient::Node, &self.blinding_point, None)?; |
90 | | - let rho = onion_utils::gen_rho_from_shared_secret(&control_tlvs_ss.secret_bytes()); |
91 | | - let encrypted_control_tlvs = self.blinded_hops.remove(0).encrypted_payload; |
92 | | - let mut s = Cursor::new(&encrypted_control_tlvs); |
93 | | - let mut reader = FixedLengthReader::new(&mut s, encrypted_control_tlvs.len() as u64); |
94 | | - match ChaChaPolyReadAdapter::read(&mut reader, rho) { |
95 | | - Ok(ChaChaPolyReadAdapter { readable: ControlTlvs::Forward(message::ForwardTlvs { |
96 | | - mut next_node_id, next_blinding_override, |
97 | | - })}) => { |
98 | | - let mut new_blinding_point = match next_blinding_override { |
99 | | - Some(blinding_point) => blinding_point, |
100 | | - None => { |
101 | | - let blinding_factor = { |
102 | | - let mut sha = Sha256::engine(); |
103 | | - sha.input(&self.blinding_point.serialize()[..]); |
104 | | - sha.input(control_tlvs_ss.as_ref()); |
105 | | - Sha256::from_engine(sha).into_inner() |
106 | | - }; |
107 | | - self.blinding_point.mul_tweak(secp_ctx, &Scalar::from_be_bytes(blinding_factor).unwrap()) |
108 | | - .map_err(|_| ())? |
109 | | - } |
110 | | - }; |
111 | | - mem::swap(&mut self.blinding_point, &mut new_blinding_point); |
112 | | - mem::swap(&mut self.introduction_node_id, &mut next_node_id); |
113 | | - Ok(()) |
114 | | - }, |
115 | | - _ => Err(()) |
116 | | - } |
117 | | - } |
118 | 75 | } |
119 | 76 |
|
120 | 77 | impl Writeable for BlindedPath { |
|
0 commit comments