@@ -41,26 +41,16 @@ const (
41
41
LegacyHopDataSize = (RealmByteSize + AddressSize + AmtForwardSize +
42
42
OutgoingCLTVSize + NumPaddingBytes + HMACSize )
43
43
44
- // MaxPayloadSize is the maximum size an `update_add_htlc` payload for a
45
- // single hop can be. This is the worst case scenario of a single hop,
46
- // consuming all available space. We need to know this in order to
47
- // generate a sufficiently long stream of pseudo-random bytes when
48
- // encrypting/decrypting the payload. This field is here for backwards
49
- // compatibility. Throughout the code we use StandardRoutingInfoSize
50
- // because of the more apt naming.
51
- MaxPayloadSize = standardRoutingInfoSize
52
- StandardRoutingInfoSize = standardRoutingInfoSize
53
-
54
- // standardRoutingInfoSize is the fixed size of the the routing info. This
55
- // consists of an addressSize byte address and a HMACSize byte HMAC for
56
- // each hop of the route, the first pair in cleartext and the following
57
- // pairs increasingly obfuscated. If not all space is used up, the
58
- // remainder is padded with null-bytes, also obfuscated.
59
- standardRoutingInfoSize = 1300
60
-
61
- // JumboRoutingInfoSize is the size of the routing info for a jumbo
62
- // onion packet.
63
- JumboRoutingInfoSize = 32768
44
+ // MaxRoutingPayloadSize is the maximum size an `update_add_htlc`
45
+ // payload for a single hop can be. This is the worst case scenario of a
46
+ // single hop, consuming all available space. We need to know this in
47
+ // order to generate a sufficiently long stream of pseudo-random bytes
48
+ // when encrypting/decrypting the payload.
49
+ MaxRoutingPayloadSize = 1300
50
+
51
+ // MaxOnionMessagePayloadSize is the size of the routing info for a
52
+ // onion messaging jumbo onion packet.
53
+ MaxOnionMessagePayloadSize = 32768
64
54
65
55
// keyLen is the length of the keys used to generate cipher streams and
66
56
// encrypt payloads. Since we use SHA256 to generate the keys, the
@@ -73,13 +63,13 @@ const (
73
63
74
64
var (
75
65
ErrStandardRoutingPayloadSizeExceeded = fmt .Errorf (
76
- "max routing info size of %v bytes exceeded" ,
77
- StandardRoutingInfoSize ,
66
+ "max routing payload size of %v bytes exceeded" ,
67
+ MaxRoutingPayloadSize ,
78
68
)
79
69
80
70
ErrMessageRoutingPayloadSizeExceeded = fmt .Errorf (
81
- "max onion message routing info size of %v bytes exceeded" ,
82
- JumboRoutingInfoSize ,
71
+ "max onion message routing payload size of %v bytes exceeded" ,
72
+ MaxOnionMessagePayloadSize ,
83
73
)
84
74
)
85
75
@@ -235,16 +225,16 @@ func NewOnionPacket(paymentPath *PaymentPath, sessionKey *btcec.PrivateKey,
235
225
236
226
totalPayloadSize := paymentPath .TotalPayloadSize ()
237
227
238
- routingInfoLen := StandardRoutingInfoSize
239
- maxRoutingInfoErr := ErrStandardRoutingPayloadSizeExceeded
240
- if cfg .isOnionMessage && totalPayloadSize > StandardRoutingInfoSize {
241
- routingInfoLen = JumboRoutingInfoSize
242
- maxRoutingInfoErr = ErrMessageRoutingPayloadSizeExceeded
228
+ routingPayloadLen := MaxRoutingPayloadSize
229
+ maxRoutingPayloadErr := ErrStandardRoutingPayloadSizeExceeded
230
+ if cfg .isOnionMessage && totalPayloadSize > MaxRoutingPayloadSize {
231
+ routingPayloadLen = MaxOnionMessagePayloadSize
232
+ maxRoutingPayloadErr = ErrMessageRoutingPayloadSizeExceeded
243
233
}
244
234
245
235
// Check whether total payload size doesn't exceed the hard maximum.
246
- if totalPayloadSize > routingInfoLen {
247
- return nil , maxRoutingInfoErr
236
+ if totalPayloadSize > routingPayloadLen {
237
+ return nil , maxRoutingPayloadErr
248
238
}
249
239
250
240
// Before we proceed, we'll check that the payload types of each hop
@@ -277,13 +267,13 @@ func NewOnionPacket(paymentPath *PaymentPath, sessionKey *btcec.PrivateKey,
277
267
278
268
// Generate the padding, called "filler strings" in the paper.
279
269
filler := generateHeaderPadding (
280
- "rho" , paymentPath , hopSharedSecrets , routingInfoLen ,
270
+ "rho" , paymentPath , hopSharedSecrets , routingPayloadLen ,
281
271
)
282
272
283
273
// Allocate zero'd out byte slices to store the final mix header packet
284
274
// and the hmac for each hop.
285
275
var (
286
- mixHeader = make ([]byte , routingInfoLen )
276
+ mixHeader = make ([]byte , routingPayloadLen )
287
277
nextHmac [HMACSize ]byte
288
278
hopPayloadBuf bytes.Buffer
289
279
)
@@ -310,7 +300,7 @@ func NewOnionPacket(paymentPath *PaymentPath, sessionKey *btcec.PrivateKey,
310
300
// Next, using the key dedicated for our stream cipher, we'll
311
301
// generate enough bytes to obfuscate this layer of the onion
312
302
// packet.
313
- streamBytes := generateCipherStream (rhoKey , uint (routingInfoLen ))
303
+ streamBytes := generateCipherStream (rhoKey , uint (routingPayloadLen ))
314
304
payload := paymentPath [i ].HopPayload
315
305
316
306
// Before we assemble the packet, we'll shift the current
0 commit comments