use crate::onion_message::ControlTlvs;
use crate::ln::msgs::DecodeError;
use crate::ln::onion_utils;
-use crate::util::chacha20poly1305rfc::{ChaChaPolyReadAdapter, ChaChaPolyWriteAdapter};
-use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, VecWriter, Writeable, Writer};
+use crate::util::chacha20poly1305rfc::ChaChaPolyReadAdapter;
+use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeable, Writer};
use core::mem;
use core::ops::Deref;
};
blinded_hops.push(BlindedHop {
blinded_node_id: prev_blinded_node_id,
- encrypted_payload: encrypt_payload(payload, prev_ss),
+ encrypted_payload: utils::encrypt_payload(payload, prev_ss),
});
} else { debug_assert!(false); }
}
let final_payload = ReceiveTlvs { path_id: None };
blinded_hops.push(BlindedHop {
blinded_node_id: final_blinded_node_id,
- encrypted_payload: encrypt_payload(final_payload, final_ss),
+ encrypted_payload: utils::encrypt_payload(final_payload, final_ss),
});
} else { debug_assert!(false) }
Ok(blinded_hops)
}
-/// Encrypt TLV payload to be used as a [`BlindedHop::encrypted_payload`].
-fn encrypt_payload<P: Writeable>(payload: P, encrypted_tlvs_ss: [u8; 32]) -> Vec<u8> {
- let mut writer = VecWriter(Vec::new());
- let write_adapter = ChaChaPolyWriteAdapter::new(encrypted_tlvs_ss, &payload);
- write_adapter.write(&mut writer).expect("In-memory writes cannot fail");
- writer.0
-}
-
impl Writeable for BlindedPath {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
self.introduction_node_id.write(w)?;
use super::BlindedPath;
use crate::ln::onion_utils;
use crate::onion_message::Destination;
+use crate::util::chacha20poly1305rfc::ChaChaPolyWriteAdapter;
+use crate::util::ser::{VecWriter, Writeable};
use crate::prelude::*;
}
Ok(())
}
+
+/// Encrypt TLV payload to be used as a [`crate::blinded_path::BlindedHop::encrypted_payload`].
+pub(super) fn encrypt_payload<P: Writeable>(payload: P, encrypted_tlvs_ss: [u8; 32]) -> Vec<u8> {
+ let mut writer = VecWriter(Vec::new());
+ let write_adapter = ChaChaPolyWriteAdapter::new(encrypted_tlvs_ss, &payload);
+ write_adapter.write(&mut writer).expect("In-memory writes cannot fail");
+ writer.0
+}
+