INNER CODE UNIT · Go
func
lightningnetwork/lightning-onion · crypto.go:248
func (r *Router) generateSharedSecret(dhKey,
blindingPoint *btcec.PublicKey) (Hash256, error) {
// If no blinding point is provided, then the un-tweaked dhKey can
// be used to derive the shared secret
if blindingPoint == nil {
return sharedSecret(r.onionKey, dhKey)
}
// We use the blinding point to calculate the blinding factor that the
// receiver used with us so that we can use it to tweak our priv key.
// The sender would have created their shared secret with our blinded
// pub key.
// * ss_receiver = H(k * E_receiver)
ssReceiver, err := sharedSecret(r.onionKey, blindingPoint)
if err != nil {
return Hash256{}, err
}