Skip to content

Commit a9003c6

Browse files
committed
Split up generic parameters that used to comprise KeysInterface in blinded_path.rs and inbound_payment.rs.
1 parent e1cb71c commit a9003c6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lightning/src/ln/inbound_payment.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use bitcoin::hashes::{Hash, HashEngine};
1414
use bitcoin::hashes::cmp::fixed_time_eq;
1515
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
1616
use bitcoin::hashes::sha256::Hash as Sha256;
17-
use crate::chain::keysinterface::{KeyMaterial, KeysInterface, EntropySource};
17+
use crate::chain::keysinterface::{KeyMaterial, EntropySource};
1818
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1919
use crate::ln::msgs;
2020
use crate::ln::msgs::MAX_VALUE_MSAT;
@@ -92,13 +92,13 @@ impl Method {
9292
///
9393
/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
9494
/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material
95-
pub fn create<K: Deref>(keys: &ExpandedKey, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, keys_manager: &K, current_time: u64) -> Result<(PaymentHash, PaymentSecret), ()>
96-
where K::Target: KeysInterface
95+
pub fn create<ES: Deref>(keys: &ExpandedKey, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, entropy_source: &ES, current_time: u64) -> Result<(PaymentHash, PaymentSecret), ()>
96+
where ES::Target: EntropySource
9797
{
9898
let metadata_bytes = construct_metadata_bytes(min_value_msat, Method::LdkPaymentHash, invoice_expiry_delta_secs, current_time)?;
9999

100100
let mut iv_bytes = [0 as u8; IV_LEN];
101-
let rand_bytes = keys_manager.get_secure_random_bytes();
101+
let rand_bytes = entropy_source.get_secure_random_bytes();
102102
iv_bytes.copy_from_slice(&rand_bytes[..IV_LEN]);
103103

104104
let mut hmac = HmacEngine::<Sha256>::new(&keys.ldk_pmt_hash_key);

lightning/src/onion_message/blinded_path.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bitcoin::hashes::{Hash, HashEngine};
1313
use bitcoin::hashes::sha256::Hash as Sha256;
1414
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
1515

16-
use crate::chain::keysinterface::{KeysInterface, NodeSigner, Recipient};
16+
use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
1717
use super::packet::ControlTlvs;
1818
use super::utils;
1919
use crate::ln::msgs::DecodeError;
@@ -63,11 +63,11 @@ impl BlindedPath {
6363
///
6464
/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
6565
// TODO: make all payloads the same size with padding + add dummy hops
66-
pub fn new<K: KeysInterface, T: secp256k1::Signing + secp256k1::Verification>
67-
(node_pks: &[PublicKey], keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<Self, ()>
66+
pub fn new<ES: EntropySource, T: secp256k1::Signing + secp256k1::Verification>
67+
(node_pks: &[PublicKey], entropy_source: &ES, secp_ctx: &Secp256k1<T>) -> Result<Self, ()>
6868
{
6969
if node_pks.len() < 2 { return Err(()) }
70-
let blinding_secret_bytes = keys_manager.get_secure_random_bytes();
70+
let blinding_secret_bytes = entropy_source.get_secure_random_bytes();
7171
let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted");
7272
let introduction_node_id = node_pks[0];
7373

@@ -79,11 +79,11 @@ impl BlindedPath {
7979
}
8080

8181
// Advance the blinded path by one hop, so make the second hop into the new introduction node.
82-
pub(super) fn advance_by_one<K: Deref, T: secp256k1::Signing + secp256k1::Verification>
83-
(&mut self, keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<(), ()>
84-
where K::Target: KeysInterface
82+
pub(super) fn advance_by_one<NS: Deref, T: secp256k1::Signing + secp256k1::Verification>
83+
(&mut self, node_signer: &NS, secp_ctx: &Secp256k1<T>) -> Result<(), ()>
84+
where NS::Target: NodeSigner
8585
{
86-
let control_tlvs_ss = keys_manager.ecdh(Recipient::Node, &self.blinding_point, None)?;
86+
let control_tlvs_ss = node_signer.ecdh(Recipient::Node, &self.blinding_point, None)?;
8787
let rho = onion_utils::gen_rho_from_shared_secret(&control_tlvs_ss.secret_bytes());
8888
let encrypted_control_tlvs = self.blinded_hops.remove(0).encrypted_payload;
8989
let mut s = Cursor::new(&encrypted_control_tlvs);

0 commit comments

Comments
 (0)