@@ -30,7 +30,6 @@ use bitcoin::hash_types::{BlockHash, Txid};
3030
3131use bitcoin:: secp256k1:: { SecretKey , PublicKey } ;
3232use bitcoin:: secp256k1:: Secp256k1 ;
33- use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
3433use bitcoin:: { LockTime , secp256k1, Sequence } ;
3534
3635use crate :: chain;
@@ -2016,7 +2015,9 @@ where
20162015 return_malformed_err ! ( "invalid ephemeral pubkey" , 0x8000 | 0x4000 | 6 ) ;
20172016 }
20182017
2019- let shared_secret = SharedSecret :: new ( & msg. onion_routing_packet . public_key . unwrap ( ) , & self . our_network_key ) . secret_bytes ( ) ;
2018+ let shared_secret = self . node_signer . ecdh (
2019+ Recipient :: Node , & msg. onion_routing_packet . public_key . unwrap ( ) , None
2020+ ) . unwrap ( ) . secret_bytes ( ) ;
20202021
20212022 if msg. onion_routing_packet . version != 0 {
20222023 //TODO: Spec doesn't indicate if we should only hash hop_data here (and in other
@@ -2924,9 +2925,9 @@ where
29242925 }
29252926 }
29262927 if let PendingHTLCRouting :: Forward { onion_packet, .. } = routing {
2927- let phantom_secret_res = self . node_signer. get_node_secret ( Recipient :: PhantomNode ) ;
2928- if phantom_secret_res . is_ok( ) && fake_scid:: is_valid_phantom( & self . fake_scid_rand_bytes, short_chan_id, & self . genesis_hash) {
2929- let phantom_shared_secret = SharedSecret :: new ( & onion_packet. public_key. unwrap( ) , & phantom_secret_res . unwrap( ) ) . secret_bytes( ) ;
2928+ let phantom_pubkey_res = self . node_signer. get_node_id ( Recipient :: PhantomNode ) ;
2929+ if phantom_pubkey_res . is_ok( ) && fake_scid:: is_valid_phantom( & self . fake_scid_rand_bytes, short_chan_id, & self . genesis_hash) {
2930+ let phantom_shared_secret = self . node_signer . ecdh ( Recipient :: PhantomNode , & onion_packet. public_key. unwrap( ) , None ) . unwrap( ) . secret_bytes( ) ;
29302931 let next_hop = match onion_utils:: decode_next_payment_hop( phantom_shared_secret, & onion_packet. hop_data, onion_packet. hmac, payment_hash) {
29312932 Ok ( res) => res,
29322933 Err ( onion_utils:: OnionDecodeErr :: Malformed { err_msg, err_code } ) => {
0 commit comments