@@ -61,8 +61,8 @@ func (p *PrivKeyECDH) PubKey() *btcec.PublicKey {
6161// k is our private key, and P is the public key, we perform the following
6262// operation:
6363//
64- // sx := k*P
65- // s := sha256(sx.SerializeCompressed())
64+ // sx := k*P
65+ // s := sha256(sx.SerializeCompressed())
6666//
6767// NOTE: This is part of the SingleKeyECDH interface.
6868func (p * PrivKeyECDH ) ECDH (pub * btcec.PublicKey ) ([32 ]byte , error ) {
@@ -235,10 +235,14 @@ func onionEncrypt(sharedSecret *Hash256, data []byte) []byte {
235235 return p
236236}
237237
238- // minOnionErrorLength is the minimally expected length of the onion error
239- // message. Including padding, all messages on the wire should be at least 256
240- // bytes. We then add the size of the sha256 HMAC as well.
241- const minOnionErrorLength = 2 + 2 + 256 + sha256 .Size
238+ // minPaddedOnionErrorLength is the minimally expected length of the padded
239+ // onion error message including two uint16s for the length of the message and
240+ // the length of the padding.
241+ const minPaddedOnionErrorLength = 2 + 2 + 256
242+
243+ // minOnionErrorLength is the minimally expected length of the complete onion
244+ // error message including the HMAC.
245+ const minOnionErrorLength = minPaddedOnionErrorLength + sha256 .Size
242246
243247// DecryptError attempts to decrypt the passed encrypted error response. The
244248// onion failure is encrypted in backward manner, starting from the node where
0 commit comments