INNER CODE UNIT · Go

sharedSecret

lightningnetwork/lightning-onion · crypto.go:289

func sharedSecret(priv SingleKeyECDH, pub *btcec.PublicKey) (Hash256, error) {
	var sharedSecret Hash256

	// Ensure that the public key is on our curve.
	if !pub.IsOnCurve() {
		return sharedSecret, ErrInvalidOnionKey
	}

	// Compute the shared secret.
	return priv.ECDH(pub)
}

// onionEncrypt obfuscates the data with compliance with BOLT#4. As we use a
// stream cipher, calling onionEncrypt on an already encrypted piece of data
// will decrypt it.
func onionEncrypt(sharedSecret *Hash256, data []byte) []byte {
	p := make([]byte, len(data))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…