@@ -73,6 +73,8 @@ pub(super) fn gen_ammag_from_shared_secret(shared_secret: &[u8]) -> [u8; 32] {
73
73
Hmac :: from_engine ( hmac) . into_inner ( )
74
74
}
75
75
76
+ pub ( super ) fn next_hop_packet_pubkey ( packet_pubkey : & PublicKey , packet_shared_secret : & SharedSecret ) -> Result < PublicKey , secp256k1:: Error > { }
77
+
76
78
// can only fail if an intermediary hop has an invalid public key or session_priv is invalid
77
79
#[ inline]
78
80
pub ( super ) fn construct_onion_keys_callback < T : secp256k1:: Signing , FType : FnMut ( SharedSecret , [ u8 ; 32 ] , PublicKey , & RouteHop , usize ) > ( secp_ctx : & Secp256k1 < T > , path : & Vec < RouteHop > , session_priv : & SecretKey , mut callback : FType ) -> Result < ( ) , secp256k1:: Error > {
@@ -515,8 +517,33 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
515
517
} else { unreachable ! ( ) ; }
516
518
}
517
519
518
- /// Data decrypted from the onion payload.
519
- pub ( crate ) enum Hop {
520
+ /// Used in the decoding of inbound payments' and onion messages' routing packets. This enum allows
521
+ /// us to use `decode_next_hop` to return the payloads and next hop packet bytes of both payments
522
+ /// and onion messages.
523
+ enum Payload {
524
+ /// This payload was for an incoming payment.
525
+ Payment ( PaymentPayload ) ,
526
+ /// This payload was for an incoming onion message.
527
+ Message ( MessagePayload ) ,
528
+ }
529
+
530
+ /// Data decrypted from the onion message's onion payload.
531
+ pub ( crate ) enum MessagePayload {
532
+ /// This onion payload was for us, not for forwarding to a next-hop.
533
+ Receive ( onion_message:: Payload ) ,
534
+ /// This onion payload needs to be forwarded to a next-hop.
535
+ Forward {
536
+ /// Onion payload data used in forwarding the onion message.
537
+ next_hop_data : onion_message:: Payload ,
538
+ /// HMAC of the next hop's onion packet.
539
+ next_hop_hmac : [ u8 ; 32 ] ,
540
+ /// Bytes of the onion packet we're forwarding.
541
+ new_packet_bytes : [ u8 ; 20 * 65 ] ,
542
+ } ,
543
+ }
544
+
545
+ /// Data decrypted from the payment's onion payload.
546
+ pub ( crate ) enum PaymentPayload {
520
547
/// This onion payload was for us, not for forwarding to a next-hop. Contains information for
521
548
/// verifying the incoming payment.
522
549
Receive ( msgs:: OnionHopData ) ,
@@ -545,7 +572,11 @@ pub(crate) enum OnionDecodeErr {
545
572
} ,
546
573
}
547
574
548
- pub ( crate ) fn decode_next_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , payment_hash : PaymentHash ) -> Result < Hop , OnionDecodeErr > {
575
+ pub ( crate ) fn decode_next_payment_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , payment_hash : PaymentHash ) -> Result < PaymentPayload , OnionDecodeErr > { }
576
+
577
+ pub ( crate ) fn decode_next_message_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , encrypted_tlvs_ss : SharedSecret ) -> Result < MessagePayload , OnionDecodeErr > { }
578
+
579
+ fn decode_next_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , payment_hash : Option < PaymentHash > , encrypted_tlvs_ss : Option < SharedSecret > ) -> Result < ( Payload , Option < ( [ u8 ; 32 ] , [ u8 ; 20 * 65 ] ) > ) , OnionDecodeErr > {
549
580
let ( rho, mu) = gen_rho_mu_from_shared_secret ( & shared_secret) ;
550
581
let mut hmac = HmacEngine :: < Sha256 > :: new ( & mu) ;
551
582
hmac. input ( hop_data) ;
0 commit comments