@@ -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 > {
@@ -519,8 +521,33 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
519
521
} else { unreachable ! ( ) ; }
520
522
}
521
523
522
- /// Data decrypted from the onion payload.
523
- pub ( crate ) enum Hop {
524
+ /// Used in the decoding of inbound payments' and onion messages' routing packets. This enum allows
525
+ /// us to use `decode_next_hop` to return the payloads and next hop packet bytes of both payments
526
+ /// and onion messages.
527
+ enum Payload {
528
+ /// This payload was for an incoming payment.
529
+ Payment ( PaymentPayload ) ,
530
+ /// This payload was for an incoming onion message.
531
+ Message ( MessagePayload ) ,
532
+ }
533
+
534
+ /// Data decrypted from the onion message's onion payload.
535
+ pub ( crate ) enum MessagePayload {
536
+ /// This onion payload was for us, not for forwarding to a next-hop.
537
+ Receive ( onion_message:: Payload ) ,
538
+ /// This onion payload needs to be forwarded to a next-hop.
539
+ Forward {
540
+ /// Onion payload data used in forwarding the onion message.
541
+ next_hop_data : onion_message:: Payload ,
542
+ /// HMAC of the next hop's onion packet.
543
+ next_hop_hmac : [ u8 ; 32 ] ,
544
+ /// Bytes of the onion packet we're forwarding.
545
+ new_packet_bytes : [ u8 ; 20 * 65 ] ,
546
+ } ,
547
+ }
548
+
549
+ /// Data decrypted from the payment's onion payload.
550
+ pub ( crate ) enum PaymentPayload {
524
551
/// This onion payload was for us, not for forwarding to a next-hop. Contains information for
525
552
/// verifying the incoming payment.
526
553
Receive ( msgs:: OnionHopData ) ,
@@ -549,7 +576,11 @@ pub(crate) enum OnionDecodeErr {
549
576
} ,
550
577
}
551
578
552
- pub ( crate ) fn decode_next_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , payment_hash : PaymentHash ) -> Result < Hop , OnionDecodeErr > {
579
+ pub ( crate ) fn decode_next_payment_hop ( shared_secret : [ u8 ; 32 ] , hop_data : & [ u8 ] , hmac_bytes : [ u8 ; 32 ] , payment_hash : PaymentHash ) -> Result < PaymentPayload , OnionDecodeErr > { }
580
+
581
+ 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 > { }
582
+
583
+ 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 > {
553
584
let ( rho, mu) = gen_rho_mu_from_shared_secret ( & shared_secret) ;
554
585
let mut hmac = HmacEngine :: < Sha256 > :: new ( & mu) ;
555
586
hmac. input ( hop_data) ;
0 commit comments