multi: pass blinding point through to reconstruction

This commit is contained in:
Carla Kirk-Cohen
2023-11-06 15:45:27 -05:00
parent 7265e4c9b0
commit 4a93f4d8d3
4 changed files with 28 additions and 7 deletions

View File

@@ -150,20 +150,27 @@ func (p *OnionProcessor) Stop() error {
// ReconstructHopIterator attempts to decode a valid sphinx packet from the passed io.Reader
// instance using the rHash as the associated data when checking the relevant
// MACs during the decoding process.
func (p *OnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte) (
Iterator, error) {
func (p *OnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte,
blindingPoint *btcec.PublicKey) (Iterator, error) {
onionPkt := &sphinx.OnionPacket{}
if err := onionPkt.Decode(r); err != nil {
return nil, err
}
var opts []sphinx.ProcessOnionOpt
if blindingPoint != nil {
opts = append(opts, sphinx.WithBlindingPoint(blindingPoint))
}
// Attempt to process the Sphinx packet. We include the payment hash of
// the HTLC as it's authenticated within the Sphinx packet itself as
// associated data in order to thwart attempts a replay attacks. In the
// case of a replay, an attacker is *forced* to use the same payment
// hash twice, thereby losing their money entirely.
sphinxPacket, err := p.router.ReconstructOnionPacket(onionPkt, rHash)
sphinxPacket, err := p.router.ReconstructOnionPacket(
onionPkt, rHash, opts...,
)
if err != nil {
return nil, err
}