Skip to content

Commit eec4bd9

Browse files
committed
Expand utility of secondary shared secrets
When encrypting errors, we currently have the ability to use two shared secrets for Phantom Node payments. Trampoline also requires the re-encryption of encrypted errors, first using the Trampoline shared secret, and then using the outer one. Given these two cryptographically equivalent use cases, we're renaming the phantom_shared_secret parameter to secondary_shared_secret, and explaining the now two contexts in which it will be applicable.
1 parent a8ef833 commit eec4bd9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning/src/ln/onion_utils.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,17 @@ impl HTLCFailReason {
13291329
Self(HTLCFailReasonRepr::LightningError { err: msg.reason.clone() })
13301330
}
13311331

1332+
/// Encrypted a failure packet using a shared secret.
1333+
///
1334+
/// For phantom nodes or inner Trampoline onions, a secondary_shared_secret can be passed, which
1335+
/// will be used to encrypt the failure packet before applying the outer encryption step using
1336+
/// incoming_packet_shared_secret.
13321337
pub(super) fn get_encrypted_failure_packet(
1333-
&self, incoming_packet_shared_secret: &[u8; 32], phantom_shared_secret: &Option<[u8; 32]>,
1338+
&self, incoming_packet_shared_secret: &[u8; 32], secondary_shared_secret: &Option<[u8; 32]>,
13341339
) -> msgs::OnionErrorPacket {
13351340
match self.0 {
13361341
HTLCFailReasonRepr::Reason { ref failure_code, ref data } => {
1337-
if let Some(phantom_ss) = phantom_shared_secret {
1342+
if let Some(phantom_ss) = secondary_shared_secret {
13381343
let phantom_packet =
13391344
build_failure_packet(phantom_ss, *failure_code, &data[..]).encode();
13401345
let encrypted_phantom_packet =

0 commit comments

Comments
 (0)