@@ -164,6 +164,41 @@ func TestDerivableKeyRelativePathDerivation(t *testing.T) {
164
164
err : nil ,
165
165
expectedKey : _bigIntFromSkHex ("aaa63a09aa2c0ce6a2a29940df8981eeefac0ea193bf90f2e06edd41356054f2907bc2e1eb5aaa4097361841914cd274" ),
166
166
},
167
+ {
168
+ name : "Base account derivation (too big index)" ,
169
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
170
+ path : "/1000/0" , // after basePath
171
+ err : nil ,
172
+ expectedKey : _bigIntFromSkHex ("843e5a2e02693309cc14de8ee6b616bffc7a1aa16d670ff906a39bd3792630917b325669b1c9057d4209bf153e7ba7b5" ),
173
+ },
174
+ {
175
+ name : "Base account derivation (too big index) in second position" ,
176
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
177
+ path : "/0/1000" , // after basePath
178
+ err : nil ,
179
+ expectedKey : _bigIntFromSkHex ("870d7a7eade91784962604e141bc5072a6ba485c873b4934b197afba02cf56625fbbf5e98b278acc17bd040268f8c326" ),
180
+ },
181
+ {
182
+ name : "Large Number in First Position" ,
183
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
184
+ path : "/1000/0/0" ,
185
+ err : nil ,
186
+ expectedKey : _bigIntFromSkHex ("b3befa8735a59a2371dc0db8c82738715bd8fb887ad245a5042396773dd08208e45b1067df61e02e9cfe6dddc5116c9f" ),
187
+ },
188
+ {
189
+ name : "Large Number in Second Position" ,
190
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
191
+ path : "/0/1000/0" ,
192
+ err : nil ,
193
+ expectedKey : _bigIntFromSkHex ("ac65c29d1c94a4fd9a58a625ada6fe8587c85f963f6ff01bf8040108c0acb7f1334e1db9ce389c6da64bca8ab3061cbc" ),
194
+ },
195
+ {
196
+ name : "Large Number in Third Position" ,
197
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
198
+ path : "/0/0/1000" ,
199
+ err : nil ,
200
+ expectedKey : _bigIntFromSkHex ("8ed2b33e1550274715e371cd6134cda81545e36d1b39ede4e3ac6b25728a1575464a985ac01e4b11553f2ef26f1269fb" ),
201
+ },
167
202
{
168
203
name : "bad path" ,
169
204
seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
@@ -172,9 +207,23 @@ func TestDerivableKeyRelativePathDerivation(t *testing.T) {
172
207
expectedKey : nil ,
173
208
},
174
209
{
175
- name : "too large of an index, bad path" ,
210
+ name : "bad path (too long) " ,
176
211
seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
177
- path : "/1000/0" , // after basePath
212
+ path : "0/0/0/0" , // after basePath
213
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
214
+ expectedKey : nil ,
215
+ },
216
+ {
217
+ name : "bad path (too short)" ,
218
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
219
+ path : "0" , // after basePath
220
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
221
+ expectedKey : nil ,
222
+ },
223
+ {
224
+ name : "bad path (too short 2)" ,
225
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
226
+ path : "/0/9/" , // after basePath
178
227
err : errors .New ("invalid relative path. Example: /1/2/3" ),
179
228
expectedKey : nil ,
180
229
},
@@ -185,6 +234,48 @@ func TestDerivableKeyRelativePathDerivation(t *testing.T) {
185
234
err : errors .New ("invalid relative path. Example: /1/2/3" ),
186
235
expectedKey : nil ,
187
236
},
237
+ {
238
+ name : "Negative Index Handling" ,
239
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
240
+ path : "/-1/0/0" ,
241
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
242
+ expectedKey : nil ,
243
+ },
244
+ {
245
+ name : "Negative Index Handling" ,
246
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
247
+ path : "/0/-1/0" ,
248
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
249
+ expectedKey : nil ,
250
+ },
251
+ {
252
+ name : "Negative Index Handling" ,
253
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
254
+ path : "/0/0/-1" ,
255
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
256
+ expectedKey : nil ,
257
+ },
258
+ {
259
+ name : "Empty String Path" ,
260
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
261
+ path : "" ,
262
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
263
+ expectedKey : nil ,
264
+ },
265
+ {
266
+ name : "Only Slashes in Path" ,
267
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
268
+ path : "///" ,
269
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
270
+ expectedKey : nil ,
271
+ },
272
+ {
273
+ name : "Minimum Group Path" ,
274
+ seed : _byteArray ("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff" ),
275
+ path : "/0" ,
276
+ err : errors .New ("invalid relative path. Example: /1/2/3" ),
277
+ expectedKey : nil ,
278
+ },
188
279
}
189
280
190
281
for _ , test := range tests {
0 commit comments