@@ -30,7 +30,6 @@ use bitcoin::hash_types::{BlockHash, Txid};
30
30
31
31
use bitcoin:: secp256k1:: { SecretKey , PublicKey } ;
32
32
use bitcoin:: secp256k1:: Secp256k1 ;
33
- use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
34
33
use bitcoin:: { LockTime , secp256k1, Sequence } ;
35
34
36
35
use crate :: chain;
@@ -2016,7 +2015,9 @@ where
2016
2015
return_malformed_err ! ( "invalid ephemeral pubkey" , 0x8000 | 0x4000 | 6 ) ;
2017
2016
}
2018
2017
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 ( ) ;
2020
2021
2021
2022
if msg. onion_routing_packet . version != 0 {
2022
2023
//TODO: Spec doesn't indicate if we should only hash hop_data here (and in other
@@ -2924,9 +2925,9 @@ where
2924
2925
}
2925
2926
}
2926
2927
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( ) ;
2930
2931
let next_hop = match onion_utils:: decode_next_payment_hop( phantom_shared_secret, & onion_packet. hop_data, onion_packet. hmac, payment_hash) {
2931
2932
Ok ( res) => res,
2932
2933
Err ( onion_utils:: OnionDecodeErr :: Malformed { err_msg, err_code } ) => {
0 commit comments