@@ -163,11 +163,30 @@ func (i *HopInfo) Encrypt(sharedSecret Hash256) (*BlindedHopInfo, error) {
163163 }, nil
164164}
165165
166+ // BlindedPathInfo holds a BlindedPath and any other items that a path
167+ // constructor may find useful.
168+ type BlindedPathInfo struct {
169+ // Path holds the constructed BlindedPath which holds all info about a
170+ // blinded path that must be communicated to a potential path user.
171+ Path * BlindedPath
172+
173+ // SessionKey holds the private key that was used as the session key
174+ // of the path. This is the private key for the first ephemeral blinding
175+ // key of the path.
176+ SessionKey * btcec.PrivateKey
177+
178+ // LastEphemeralKey is the very last ephemeral blinding key used on the
179+ // path. This may be useful to the path creator as they can use this
180+ // key to uniquely identify the path that was used for an incoming
181+ // payment.
182+ LastEphemeralKey * btcec.PublicKey
183+ }
184+
166185// BuildBlindedPath creates a new BlindedPath from a session key along with a
167186// list of HopInfo representing the nodes in the blinded path. The first hop in
168187// paymentPath is expected to be the introduction node.
169188func BuildBlindedPath (sessionKey * btcec.PrivateKey ,
170- paymentPath []* HopInfo ) (* BlindedPath , error ) {
189+ paymentPath []* HopInfo ) (* BlindedPathInfo , error ) {
171190
172191 if len (paymentPath ) < 1 {
173192 return nil , errors .New ("at least 1 hop is required to create " +
@@ -185,7 +204,9 @@ func BuildBlindedPath(sessionKey *btcec.PrivateKey,
185204 keys [i ] = p .NodePub
186205 }
187206
188- hopSharedSecrets , err := generateSharedSecrets (keys , sessionKey )
207+ hopSharedSecrets , lastEphem , err := generateSharedSecrets (
208+ keys , sessionKey ,
209+ )
189210 if err != nil {
190211 return nil , fmt .Errorf ("error generating shared secret: %v" ,
191212 err )
@@ -200,7 +221,11 @@ func BuildBlindedPath(sessionKey *btcec.PrivateKey,
200221 bp .BlindedHops [i ] = blindedInfo
201222 }
202223
203- return bp , nil
224+ return & BlindedPathInfo {
225+ Path : bp ,
226+ SessionKey : sessionKey ,
227+ LastEphemeralKey : lastEphem ,
228+ }, nil
204229}
205230
206231// blindNodeID blinds the given public key using the provided shared secret.
0 commit comments