INNER CODE UNIT · Go

blindBaseElement

lightningnetwork/lightning-onion · crypto.go:200

func blindBaseElement(blindingFactor btcec.ModNScalar) *btcec.PublicKey {
	// TODO(roasbeef): remove after btcec version bump to add alias for
	// this method
	priv := secp.NewPrivateKey(&blindingFactor)
	return priv.PubKey()
}

// chacha20polyEncrypt initialises the ChaCha20Poly1305 algorithm with the given
// key and uses it to encrypt the passed message. This uses an all-zero nonce as
// required by the route-blinding spec.
func chacha20polyEncrypt(key, plainTxt []byte) ([]byte, error) {
	aead, err := chacha20poly1305.New(key)
	if err != nil {
		return nil, err
	}

	return aead.Seal(plainTxt[:0], chaChaPolyZeroNonce[:], plainTxt, nil),
		nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…