Skip to content

Commit a800c9f

Browse files
committed
sphinx: add route blinding helper methods to Router
In this commit, DecryptBlindHopData and NextEphemeral methods are added to Router which makes use of the Router's onion key in order to unblind blinded data and compute the next ephermal key respectively.
1 parent b1469b8 commit a800c9f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sphinx.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,22 @@ func (r *Router) ReconstructOnionPacket(onionPkt *OnionPacket, assocData []byte,
611611
return processOnionPacket(onionPkt, &sharedSecret, assocData)
612612
}
613613

614+
// DecryptBlindedHopData uses the router's private key to decrypt data encrypted
615+
// by the creator of the blinded route.
616+
func (r *Router) DecryptBlindedHopData(ephemPub *btcec.PublicKey,
617+
encryptedData []byte) ([]byte, error) {
618+
619+
return decryptBlindedHopData(r.onionKey, ephemPub, encryptedData)
620+
}
621+
622+
// NextEphemeral computes the next ephemeral key given the current ephemeral
623+
// key and the router's private key.
624+
func (r *Router) NextEphemeral(ephemPub *btcec.PublicKey) (*btcec.PublicKey,
625+
error) {
626+
627+
return NextEphemeral(r.onionKey, ephemPub)
628+
}
629+
614630
// unwrapPacket wraps a layer of the passed onion packet using the specified
615631
// shared secret and associated data. The associated data will be used to check
616632
// the HMAC at each hop to ensure the same data is passed along with the onion

0 commit comments

Comments
 (0)