Skip to content

Commit b2bbdde

Browse files
committed
sphinx: adds ReconstructOnionPacket for deriving packets w/o replay check
1 parent fc276f4 commit b2bbdde

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sphinx.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,21 @@ func (r *Router) ProcessOnionPacket(onionPkt *OnionPacket,
707707
return packet, nil
708708
}
709709

710+
// ReconstructOnionPacket rederives the subsequent onion packet.
711+
// NOTE: This method does not do any sort of replay protection, and should only
712+
// be used to reconstruct packets that were successfully processed previously.
713+
func (r *Router) ReconstructOnionPacket(onionPkt *OnionPacket,
714+
assocData []byte) (*ProcessedPacket, error) {
715+
716+
// Compute the shared secret for this onion packet.
717+
sharedSecret, err := r.generateSharedSecret(onionPkt.EphemeralKey)
718+
if err != nil {
719+
return nil, err
720+
}
721+
722+
return processOnionPacket(onionPkt, &sharedSecret, assocData)
723+
}
724+
710725
// processOnionPacket performs the primary key derivation and handling of onion
711726
// packets. The processed packets returned from this method should only be used
712727
// if the packet was not flagged as a replayed packet.

0 commit comments

Comments
 (0)