@@ -11,14 +11,14 @@ import (
11
11
"github.com/stretchr/testify/require"
12
12
)
13
13
14
- var fatErrorTestStructure = & FatErrorStructure {
15
- MaxHops : 27 ,
16
- MaxPayloadSize : 8 ,
14
+ var attributableErrorTestStructure = & AttributableErrorStructure {
15
+ HopCount : 27 ,
16
+ FixedPayloadLen : 8 ,
17
17
}
18
18
19
- // TestFatOnionFailure checks the ability of sender of payment to decode the
20
- // obfuscated onion error.
21
- func TestFatOnionFailure (t * testing.T ) {
19
+ // TestAttributableOnionFailure checks the ability of sender of payment to
20
+ // decode the obfuscated onion error.
21
+ func TestAttributableOnionFailure (t * testing.T ) {
22
22
t .Parallel ()
23
23
24
24
// Create numHops random sphinx paymentPath.
@@ -33,8 +33,8 @@ func TestFatOnionFailure(t *testing.T) {
33
33
require .NoError (t , err )
34
34
35
35
// Emulate creation of the obfuscator on node where error have occurred.
36
- obfuscator := NewOnionFatErrorEncrypter (
37
- sharedSecrets [len (errorPath )- 1 ], fatErrorTestStructure ,
36
+ obfuscator := NewOnionAttributableErrorEncrypter (
37
+ sharedSecrets [len (errorPath )- 1 ], attributableErrorTestStructure ,
38
38
)
39
39
40
40
// Emulate the situation when last hop creates the onion failure
@@ -50,8 +50,8 @@ func TestFatOnionFailure(t *testing.T) {
50
50
for i := len (errorPath ) - 2 ; i >= 0 ; i -- {
51
51
// Emulate creation of the obfuscator on forwarding node which
52
52
// propagates the onion failure.
53
- obfuscator = NewOnionFatErrorEncrypter (
54
- sharedSecrets [i ], fatErrorTestStructure ,
53
+ obfuscator = NewOnionAttributableErrorEncrypter (
54
+ sharedSecrets [i ], attributableErrorTestStructure ,
55
55
)
56
56
57
57
intermediatePayload := [8 ]byte {byte (100 + i )}
@@ -64,10 +64,10 @@ func TestFatOnionFailure(t *testing.T) {
64
64
}
65
65
66
66
// Emulate creation of the deobfuscator on the receiving onion error side.
67
- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
67
+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
68
68
SessionKey : sessionKey ,
69
69
PaymentPath : paymentPath ,
70
- }, fatErrorTestStructure )
70
+ }, attributableErrorTestStructure )
71
71
72
72
// Emulate that sender node receive the failure message and trying to
73
73
// unwrap it, by applying obfuscation and checking the hmac.
@@ -103,22 +103,24 @@ func TestOnionFailureCorruption(t *testing.T) {
103
103
require .NoError (t , err )
104
104
105
105
// Emulate creation of the obfuscator on node where error have occurred.
106
- obfuscator := NewOnionFatErrorEncrypter (
107
- sharedSecrets [len (errorPath )- 1 ], fatErrorTestStructure ,
106
+ obfuscator := NewOnionAttributableErrorEncrypter (
107
+ sharedSecrets [len (errorPath )- 1 ], attributableErrorTestStructure ,
108
108
)
109
109
110
110
// Emulate the situation when last hop creates the onion failure
111
111
// message and send it back.
112
112
payload := [8 ]byte {1 }
113
- obfuscatedData , err := obfuscator .EncryptError (true , failureData , payload [:])
113
+ obfuscatedData , err := obfuscator .EncryptError (
114
+ true , failureData , payload [:],
115
+ )
114
116
require .NoError (t , err )
115
117
116
118
// Emulate that failure message is backward obfuscated on every hop.
117
119
for i := len (errorPath ) - 2 ; i >= 0 ; i -- {
118
120
// Emulate creation of the obfuscator on forwarding node which
119
121
// propagates the onion failure.
120
- obfuscator = NewOnionFatErrorEncrypter (
121
- sharedSecrets [i ], fatErrorTestStructure ,
122
+ obfuscator = NewOnionAttributableErrorEncrypter (
123
+ sharedSecrets [i ], attributableErrorTestStructure ,
122
124
)
123
125
124
126
payload := [8 ]byte {byte (100 + i )}
@@ -135,10 +137,10 @@ func TestOnionFailureCorruption(t *testing.T) {
135
137
}
136
138
137
139
// Emulate creation of the deobfuscator on the receiving onion error side.
138
- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
140
+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
139
141
SessionKey : sessionKey ,
140
142
PaymentPath : paymentPath ,
141
- }, fatErrorTestStructure )
143
+ }, attributableErrorTestStructure )
142
144
143
145
// Emulate that sender node receive the failure message and trying to
144
146
// unwrap it, by applying obfuscation and checking the hmac.
@@ -163,10 +165,10 @@ type specVector struct {
163
165
164
166
// TestOnionFailureSpecVector checks that onion error corresponds to the
165
167
// specification.
166
- func TestFatOnionFailureSpecVector (t * testing.T ) {
168
+ func TestAttributableFailureSpecVector (t * testing.T ) {
167
169
t .Parallel ()
168
170
169
- vectorBytes , err := os .ReadFile ("testdata/fat_error .json" )
171
+ vectorBytes , err := os .ReadFile ("testdata/attributable_error .json" )
170
172
require .NoError (t , err )
171
173
172
174
var vector specVector
@@ -191,8 +193,9 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
191
193
expectedSharedSecret , err := hex .DecodeString (test .SharedSecret )
192
194
require .NoError (t , err )
193
195
194
- obfuscator := NewOnionFatErrorEncrypter (
195
- sharedSecrets [len (sharedSecrets )- 1 - i ], fatErrorTestStructure ,
196
+ obfuscator := NewOnionAttributableErrorEncrypter (
197
+ sharedSecrets [len (sharedSecrets )- 1 - i ],
198
+ attributableErrorTestStructure ,
196
199
)
197
200
198
201
require .Equal (t , expectedSharedSecret , obfuscator .sharedSecret [:])
@@ -222,10 +225,10 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
222
225
require .Equal (t , expectedEncryptErrorData , obfuscatedData )
223
226
}
224
227
225
- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
228
+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
226
229
SessionKey : sessionKey ,
227
230
PaymentPath : paymentPath ,
228
- }, fatErrorTestStructure )
231
+ }, attributableErrorTestStructure )
229
232
230
233
// Emulate that sender node receives the failure message and trying to
231
234
// unwrap it, by applying obfuscation and checking the hmac.
@@ -244,19 +247,19 @@ func TestFatOnionFailureSpecVector(t *testing.T) {
244
247
require .Equal (t , len (paymentPath ), decryptedError .SenderIdx )
245
248
}
246
249
247
- // TestFatOnionFailureZeroesMessage checks that a garbage failure is attributed
248
- // to the first hop.
249
- func TestFatOnionFailureZeroesMessage (t * testing.T ) {
250
+ // TestAttributableOnionFailureZeroesMessage checks that a garbage failure is
251
+ // attributed to the first hop.
252
+ func TestAttributableOnionFailureZeroesMessage (t * testing.T ) {
250
253
t .Parallel ()
251
254
252
255
// Create numHops random sphinx paymentPath.
253
256
sessionKey , paymentPath := generateRandomPath (t )
254
257
255
258
// Emulate creation of the deobfuscator on the receiving onion error side.
256
- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
259
+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
257
260
SessionKey : sessionKey ,
258
261
PaymentPath : paymentPath ,
259
- }, fatErrorTestStructure )
262
+ }, attributableErrorTestStructure )
260
263
261
264
// Emulate that sender node receive the failure message and trying to
262
265
// unwrap it, by applying obfuscation and checking the hmac.
@@ -268,19 +271,19 @@ func TestFatOnionFailureZeroesMessage(t *testing.T) {
268
271
require .Equal (t , 1 , decryptedError .SenderIdx )
269
272
}
270
273
271
- // TestFatOnionFailureShortMessage checks that too short failure is attributed
272
- // to the first hop.
273
- func TestFatOnionFailureShortMessage (t * testing.T ) {
274
+ // TestAttributableOnionFailureShortMessage checks that too short failure is
275
+ // attributed to the first hop.
276
+ func TestAttributableOnionFailureShortMessage (t * testing.T ) {
274
277
t .Parallel ()
275
278
276
279
// Create numHops random sphinx paymentPath.
277
280
sessionKey , paymentPath := generateRandomPath (t )
278
281
279
282
// Emulate creation of the deobfuscator on the receiving onion error side.
280
- deobfuscator := NewOnionFatErrorDecrypter (& Circuit {
283
+ deobfuscator := NewOnionAttributableErrorDecrypter (& Circuit {
281
284
SessionKey : sessionKey ,
282
285
PaymentPath : paymentPath ,
283
- }, fatErrorTestStructure )
286
+ }, attributableErrorTestStructure )
284
287
285
288
// Emulate that sender node receive the failure message and trying to
286
289
// unwrap it, by applying obfuscation and checking the hmac.
0 commit comments