1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
use std::io;

use ring::digest::{digest, SHA256};
use serde::{Deserialize, Serialize};

use crate::{avax, codec, ids, key, secp256k1fx};

/// ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#Tx
/// ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#UnsignedCreateChainTx
/// ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#UnsignedTx
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
pub struct Tx {
    /// The transaction ID is empty for unsigned tx
    /// as long as "avax.BaseTx.Metadata" is "None".
    /// Once Metadata is updated with signing and "Tx.Initialize",
    /// Tx.ID() is non-empty.
    pub unsigned_tx: avax::BaseTx,
    pub subnet_id: ids::Id,
    pub chain_name: String,
    pub vm_id: ids::Id,
    pub fx_ids: Option<Vec<ids::Id>>,
    pub genesis_data: Vec<u8>,
    pub subnet_auth: secp256k1fx::Input,
    pub creds: Vec<secp256k1fx::Credential>,
}

impl Default for Tx {
    fn default() -> Self {
        Self::default()
    }
}

impl Tx {
    pub fn default() -> Self {
        Self {
            unsigned_tx: avax::BaseTx::default(),
            subnet_id: ids::Id::empty(),
            chain_name: String::new(),
            vm_id: ids::Id::empty(),
            fx_ids: None,
            genesis_data: Vec::new(),
            subnet_auth: secp256k1fx::Input::default(),
            creds: Vec::new(),
        }
    }

    pub fn new(unsigned_tx: avax::BaseTx) -> Self {
        Self {
            unsigned_tx,
            ..Self::default()
        }
    }

    /// Returns the transaction ID.
    /// Only non-empty if the embedded metadata is updated
    /// with the signing process.
    pub fn tx_id(&self) -> ids::Id {
        if self.unsigned_tx.metadata.is_some() {
            let m = self.unsigned_tx.metadata.clone().unwrap();
            m.id
        } else {
            ids::Id::default()
        }
    }

    pub fn type_name() -> String {
        "platformvm.UnsignedCreateChainTx".to_string()
    }

    pub fn type_id() -> u32 {
        *(codec::P_TYPES.get(&Self::type_name()).unwrap()) as u32
    }

    /// ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#Tx.Sign
    /// ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/crypto#PrivateKeyED25519.SignHash
    /// TODO: support ledger signing
    pub fn sign<T: key::SignOnly>(&mut self, signers: Vec<Vec<T>>) -> io::Result<()> {
        // marshal "unsigned tx" with the codec version
        let type_id = Self::type_id();
        let packer = self.unsigned_tx.pack(codec::VERSION, type_id)?;

        // "avalanchego" marshals the whole struct again for signed bytes
        // even when the underlying "unsigned_tx" is already once marshaled
        // ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#Tx.Sign
        //
        // reuse the underlying packer to avoid marshaling the unsigned tx twice
        // just marshal the next fields in the struct and pack them all together
        // in the existing packer
        let unsigned_tx_bytes = packer.take_bytes();
        packer.set_bytes(&unsigned_tx_bytes);

        // pack the second field "subnet_id" in the struct
        packer.pack_bytes(self.subnet_id.as_ref())?;

        // pack the third field "chain_name" in the struct
        packer.pack_str(&self.chain_name)?;

        // pack the fourth field "vm_id" in the struct
        packer.pack_bytes(self.vm_id.as_ref())?;

        // pack the fifth field "fx_ids" in the struct
        if self.fx_ids.is_some() {
            let fx_ids = self.fx_ids.as_ref().unwrap();
            packer.pack_u32(fx_ids.len() as u32)?;
            for fx_id in fx_ids.iter() {
                packer.pack_bytes(fx_id.as_ref())?;
            }
        } else {
            packer.pack_u32(0_u32)?;
        }

        // pack the sixth field "genesis_data" in the struct
        // []byte is reflected as "reflect.Slice" in avalanchego
        // thus encode its length
        packer.pack_u32(self.genesis_data.len() as u32)?;
        packer.pack_bytes(&self.genesis_data)?;

        // pack the seventh field "subnet_auth" in the struct
        let subnet_auth_type_id = secp256k1fx::Input::type_id();
        packer.pack_u32(subnet_auth_type_id)?;
        packer.pack_u32(self.subnet_auth.sig_indices.len() as u32)?;
        for sig_idx in self.subnet_auth.sig_indices.iter() {
            packer.pack_u32(*sig_idx)?;
        }

        // take bytes just for hashing computation
        let unsigned_tx_bytes = packer.take_bytes();
        packer.set_bytes(&unsigned_tx_bytes);

        // compute sha256 for marshaled "unsigned tx" bytes
        // IMPORTANT: take the hash only for the type "platformvm.UnsignedAddValidatorTx" unsigned tx
        // not other fields -- only hash "platformvm.UnsignedAddValidatorTx.*" but not "platformvm.Tx.Creds"
        // ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/vms/platformvm#UnsignedAddValidatorTx
        let hash: Vec<u8> = digest(&SHA256, &unsigned_tx_bytes).as_ref().into();

        // number of of credentials
        let creds_len = signers.len() as u32;
        // pack the fourth field in the struct
        packer.pack_u32(creds_len)?;

        // sign the hash with the signers (in case of multi-sig)
        // and combine all signatures into a secp256k1fx credential
        self.creds = Vec::new();
        for keys in signers.iter() {
            let mut sigs: Vec<Vec<u8>> = Vec::new();
            for k in keys.iter() {
                let sig = k.sign_ecdsa_recoverable(&hash);
                sigs.push(sig);
            }

            let mut cred = secp256k1fx::Credential::default();
            cred.signatures = sigs;

            // add a new credential to "Tx"
            self.creds.push(cred);
        }
        if creds_len > 0 {
            // pack each "cred" which is "secp256k1fx.Credential"
            // marshal type ID for "secp256k1fx.Credential"
            let cred_type_id = secp256k1fx::Credential::type_id();
            for cred in self.creds.iter() {
                // marshal type ID for "secp256k1fx.Credential"
                packer.pack_u32(cred_type_id)?;

                // marshal fields for "secp256k1fx.Credential"
                packer.pack_u32(cred.signatures.len() as u32)?;
                for sig in cred.signatures.iter() {
                    packer.pack_bytes(sig)?;
                }
            }
        }
        let signed_tx_bytes = packer.take_bytes();
        let tx_id: Vec<u8> = digest(&SHA256, &signed_tx_bytes).as_ref().into();

        // update "BaseTx.Metadata" with id/unsigned bytes/bytes
        // ref. "avalanchego/vms/platformvm.Tx.Sign"
        // ref. "avalanchego/vms/components/avax.BaseTx.Metadata.Initialize"
        self.unsigned_tx.metadata = Some(avax::Metadata {
            id: ids::Id::from_slice(&tx_id),
            unsigned_bytes: unsigned_tx_bytes.to_vec(),
            bytes: signed_tx_bytes.to_vec(),
        });

        Ok(())
    }
}

/// RUST_LOG=debug cargo test --package avalanche-types --lib -- platformvm::create_chain::test_create_chain_tx_serialization_with_one_signer --exact --show-output
#[test]
fn test_create_chain_tx_serialization_with_one_signer() {
    use crate::{ids::short, key::hot};
    use avalanche_utils::cmp;

    let mut tx = Tx {
        unsigned_tx: avax::BaseTx {
            network_id: 1000000,
            transferable_outputs: Some(vec![avax::TransferableOutput {
                asset_id: ids::Id::from_slice(&<Vec<u8>>::from([
                    0x88, 0xee, 0xc2, 0xe0, 0x99, 0xc6, 0xa5, 0x28, //
                    0xe6, 0x89, 0x61, 0x8e, 0x87, 0x21, 0xe0, 0x4a, //
                    0xe8, 0x5e, 0xa5, 0x74, 0xc7, 0xa1, 0x5a, 0x79, //
                    0x68, 0x64, 0x4d, 0x14, 0xd5, 0x47, 0x80, 0x14, //
                ])),
                transfer_output: Some(secp256k1fx::TransferOutput {
                    amount: 0x2c6874d5c56f500,
                    output_owners: secp256k1fx::OutputOwners {
                        locktime: 0x00,
                        threshold: 0x01,
                        addrs: vec![short::Id::from_slice(&<Vec<u8>>::from([
                            0x65, 0x84, 0x4a, 0x05, 0x40, 0x5f, 0x36, 0x62, 0xc1, 0x92, //
                            0x81, 0x42, 0xc6, 0xc2, 0xa7, 0x83, 0xef, 0x87, 0x1d, 0xe9, //
                        ]))],
                    },
                }),
                ..avax::TransferableOutput::default()
            }]),
            transferable_inputs: Some(vec![avax::TransferableInput {
                utxo_id: avax::UtxoId {
                    tx_id: ids::Id::from_slice(&<Vec<u8>>::from([
                        0x4e, 0x02, 0x63, 0x73, 0xef, 0x9f, 0x0f, 0xaf, 0xf6, 0x24, //
                        0x11, 0xc7, 0x15, 0x80, 0x8b, 0x28, 0x00, 0x60, 0x32, 0xce, //
                        0x82, 0x9e, 0x1c, 0xb5, 0xb0, 0x46, 0xb9, 0xc8, 0x83, 0xae, //
                        0xfb, 0xbc,
                    ])),
                    output_index: 0,
                    ..avax::UtxoId::default()
                },
                asset_id: ids::Id::from_slice(&<Vec<u8>>::from([
                    0x88, 0xee, 0xc2, 0xe0, 0x99, 0xc6, 0xa5, 0x28, //
                    0xe6, 0x89, 0x61, 0x8e, 0x87, 0x21, 0xe0, 0x4a, //
                    0xe8, 0x5e, 0xa5, 0x74, 0xc7, 0xa1, 0x5a, 0x79, //
                    0x68, 0x64, 0x4d, 0x14, 0xd5, 0x47, 0x80, 0x14, //
                ])),
                transfer_input: Some(secp256k1fx::TransferInput {
                    amount: 0x2c6874d624cd600,
                    sig_indices: vec![0],
                }),
                ..avax::TransferableInput::default()
            }]),
            ..avax::BaseTx::default()
        },
        subnet_id: ids::Id::from_slice(&<Vec<u8>>::from([
            0xda, 0x77, 0x6a, 0xb0, 0xf6, 0x10, 0x01, 0x8e, 0x60, 0xa5, //
            0x0a, 0xc5, 0xb1, 0x48, 0x9a, 0x4d, 0xcd, 0xe0, 0x25, 0xf1, //
            0xf4, 0xa5, 0x62, 0x60, 0xc4, 0x4b, 0x86, 0x19, 0x46, 0x05, //
            0x0f, 0x11,
        ])),
        chain_name: String::from("subnetevm"),
        vm_id: ids::Id::from_slice(&<Vec<u8>>::from([
            0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x65, 0x76, 0x6d, 0x00, //
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
            0x00, 0x00, //
        ])),
        genesis_data: <Vec<u8>>::from([
            0x7b, 0x22, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a, 0x7b, 0x22, 0x63, 0x68,
            0x61, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x3a, 0x32, 0x30, 0x30, 0x30, 0x37, 0x37, 0x37,
            0x2c, 0x22, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f,
            0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x30, 0x42,
            0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35,
            0x30, 0x48, 0x61, 0x73, 0x68, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x32, 0x30, 0x38, 0x36,
            0x37, 0x39, 0x39, 0x61, 0x65, 0x65, 0x62, 0x65, 0x61, 0x65, 0x31, 0x33, 0x35, 0x63,
            0x32, 0x34, 0x36, 0x63, 0x36, 0x35, 0x30, 0x32, 0x31, 0x63, 0x38, 0x32, 0x62, 0x34,
            0x65, 0x31, 0x35, 0x61, 0x32, 0x63, 0x34, 0x35, 0x31, 0x33, 0x34, 0x30, 0x39, 0x39,
            0x33, 0x61, 0x61, 0x63, 0x66, 0x64, 0x32, 0x37, 0x35, 0x31, 0x38, 0x38, 0x36, 0x35,
            0x31, 0x34, 0x66, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x35, 0x42,
            0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35,
            0x38, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x62, 0x79, 0x7a,
            0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30,
            0x2c, 0x22, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70,
            0x6c, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x70, 0x65,
            0x74, 0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22,
            0x3a, 0x30, 0x2c, 0x22, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x42, 0x6c,
            0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6d, 0x75, 0x69, 0x72, 0x47, 0x6c,
            0x61, 0x63, 0x69, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c,
            0x22, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x45, 0x56, 0x4d, 0x54, 0x69, 0x6d, 0x65,
            0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x43,
            0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a, 0x7b, 0x22, 0x67, 0x61, 0x73, 0x4c, 0x69,
            0x6d, 0x69, 0x74, 0x22, 0x3a, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2c,
            0x22, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x61,
            0x74, 0x65, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6d, 0x69, 0x6e, 0x42, 0x61, 0x73, 0x65,
            0x46, 0x65, 0x65, 0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x2c, 0x22, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x61, 0x73, 0x22, 0x3a,
            0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2c, 0x22, 0x62, 0x61, 0x73,
            0x65, 0x46, 0x65, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x65, 0x6e, 0x6f,
            0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x3a, 0x34, 0x38, 0x2c, 0x22, 0x6d,
            0x69, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74,
            0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47,
            0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x2c, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x43, 0x6f,
            0x73, 0x74, 0x53, 0x74, 0x65, 0x70, 0x22, 0x3a, 0x35, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x7d, 0x2c, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x44, 0x65, 0x70,
            0x6c, 0x6f, 0x79, 0x65, 0x72, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74,
            0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x6c, 0x6f, 0x63,
            0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3a, 0x30, 0x2c,
            0x22, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65,
            0x73, 0x22, 0x3a, 0x5b, 0x22, 0x30, 0x78, 0x38, 0x64, 0x62, 0x39, 0x37, 0x43, 0x37,
            0x63, 0x45, 0x63, 0x45, 0x32, 0x34, 0x39, 0x63, 0x32, 0x62, 0x39, 0x38, 0x62, 0x44,
            0x43, 0x30, 0x32, 0x32, 0x36, 0x43, 0x63, 0x34, 0x43, 0x32, 0x41, 0x35, 0x37, 0x42,
            0x46, 0x35, 0x32, 0x46, 0x43, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x36, 0x31, 0x33, 0x30,
            0x34, 0x30, 0x61, 0x32, 0x33, 0x39, 0x42, 0x44, 0x66, 0x43, 0x46, 0x31, 0x31, 0x30,
            0x39, 0x36, 0x39, 0x66, 0x65, 0x63, 0x42, 0x34, 0x31, 0x63, 0x36, 0x66, 0x39, 0x32,
            0x45, 0x41, 0x33, 0x35, 0x31, 0x35, 0x43, 0x30, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x30,
            0x61, 0x36, 0x33, 0x61, 0x43, 0x43, 0x33, 0x37, 0x33, 0x35, 0x65, 0x38, 0x32, 0x35,
            0x44, 0x37, 0x44, 0x31, 0x33, 0x32, 0x34, 0x33, 0x46, 0x44, 0x37, 0x36, 0x62, 0x41,
            0x64, 0x34, 0x39, 0x33, 0x33, 0x31, 0x62, 0x61, 0x45, 0x30, 0x45, 0x22, 0x2c, 0x22,
            0x30, 0x78, 0x32, 0x66, 0x63, 0x39, 0x32, 0x32, 0x42, 0x65, 0x65, 0x39, 0x30, 0x32,
            0x35, 0x32, 0x30, 0x63, 0x34, 0x36, 0x38, 0x31, 0x63, 0x35, 0x62, 0x62, 0x64, 0x39,
            0x37, 0x39, 0x30, 0x38, 0x43, 0x37, 0x32, 0x37, 0x36, 0x36, 0x34, 0x65, 0x35, 0x36,
            0x22, 0x2c, 0x22, 0x30, 0x78, 0x30, 0x43, 0x38, 0x35, 0x66, 0x32, 0x37, 0x35, 0x35,
            0x30, 0x63, 0x61, 0x62, 0x33, 0x31, 0x32, 0x37, 0x46, 0x42, 0x36, 0x44, 0x61, 0x38,
            0x34, 0x45, 0x36, 0x44, 0x44, 0x63, 0x65, 0x43, 0x66, 0x33, 0x34, 0x32, 0x37, 0x32,
            0x66, 0x44, 0x30, 0x22, 0x5d, 0x7d, 0x7d, 0x2c, 0x22, 0x6e, 0x6f, 0x6e, 0x63, 0x65,
            0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22, 0x74, 0x69, 0x6d, 0x65, 0x73,
            0x74, 0x61, 0x6d, 0x70, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22, 0x65,
            0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30,
            0x30, 0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3a,
            0x22, 0x30, 0x78, 0x31, 0x33, 0x31, 0x32, 0x64, 0x30, 0x30, 0x22, 0x2c, 0x22, 0x64,
            0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0x3a, 0x22, 0x30, 0x78,
            0x30, 0x22, 0x2c, 0x22, 0x6d, 0x69, 0x78, 0x48, 0x61, 0x73, 0x68, 0x22, 0x3a, 0x22,
            0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x22, 0x63,
            0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x22, 0x61,
            0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x43, 0x38, 0x35, 0x66, 0x32,
            0x37, 0x35, 0x35, 0x30, 0x63, 0x61, 0x62, 0x33, 0x31, 0x32, 0x37, 0x46, 0x42, 0x36,
            0x44, 0x61, 0x38, 0x34, 0x45, 0x36, 0x44, 0x44, 0x63, 0x65, 0x43, 0x66, 0x33, 0x34,
            0x32, 0x37, 0x32, 0x66, 0x44, 0x30, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61,
            0x6e, 0x63, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32,
            0x64, 0x63, 0x63, 0x38, 0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22, 0x30, 0x61, 0x36, 0x33, 0x61, 0x43, 0x43, 0x33,
            0x37, 0x33, 0x35, 0x65, 0x38, 0x32, 0x35, 0x44, 0x37, 0x44, 0x31, 0x33, 0x32, 0x34,
            0x33, 0x46, 0x44, 0x37, 0x36, 0x62, 0x41, 0x64, 0x34, 0x39, 0x33, 0x33, 0x31, 0x62,
            0x61, 0x45, 0x30, 0x45, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63,
            0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63,
            0x63, 0x38, 0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x22, 0x7d, 0x2c, 0x22, 0x32, 0x66, 0x63, 0x39, 0x32, 0x32, 0x42, 0x65, 0x65, 0x39,
            0x30, 0x32, 0x35, 0x32, 0x30, 0x63, 0x34, 0x36, 0x38, 0x31, 0x63, 0x35, 0x62, 0x62,
            0x64, 0x39, 0x37, 0x39, 0x30, 0x38, 0x43, 0x37, 0x32, 0x37, 0x36, 0x36, 0x34, 0x65,
            0x35, 0x36, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22,
            0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38,
            0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d,
            0x2c, 0x22, 0x36, 0x31, 0x33, 0x30, 0x34, 0x30, 0x61, 0x32, 0x33, 0x39, 0x42, 0x44,
            0x66, 0x43, 0x46, 0x31, 0x31, 0x30, 0x39, 0x36, 0x39, 0x66, 0x65, 0x63, 0x42, 0x34,
            0x31, 0x63, 0x36, 0x66, 0x39, 0x32, 0x45, 0x41, 0x33, 0x35, 0x31, 0x35, 0x43, 0x30,
            0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x22,
            0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30, 0x63,
            0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22,
            0x38, 0x64, 0x62, 0x39, 0x37, 0x43, 0x37, 0x63, 0x45, 0x63, 0x45, 0x32, 0x34, 0x39,
            0x63, 0x32, 0x62, 0x39, 0x38, 0x62, 0x44, 0x43, 0x30, 0x32, 0x32, 0x36, 0x43, 0x63,
            0x34, 0x43, 0x32, 0x41, 0x35, 0x37, 0x42, 0x46, 0x35, 0x32, 0x46, 0x43, 0x22, 0x3a,
            0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78,
            0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30, 0x63, 0x64, 0x32,
            0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x7d, 0x2c, 0x22, 0x6e,
            0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22,
            0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22,
            0x2c, 0x22, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x22, 0x3a,
            0x22, 0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d,
        ]),
        subnet_auth: secp256k1fx::Input {
            sig_indices: vec![0],
        },
        ..Tx::default()
    };

    let test_key =
        hot::Key::from_private_key("PrivateKey-2kqWNDaqUKQyE4ZsV5GLCGeizE6sHAJVyjnfjXoXrtcZpK9M67")
            .expect("failed to load private key");
    let keys1: Vec<hot::Key> = vec![test_key.clone()];
    let keys2: Vec<hot::Key> = vec![test_key];
    let signers: Vec<Vec<hot::Key>> = vec![keys1, keys2];
    tx.sign(signers).expect("failed to sign");
    let tx_metadata = tx.unsigned_tx.metadata.clone().unwrap();
    let signed_bytes = tx_metadata.bytes;
    assert_eq!(
        tx.tx_id().to_string(),
        "2nWs4EB5gmBz99pn4Vck3dBjnPysv44HRiXvNQNpQUonfTNsTf"
    );

    let expected_signed_bytes: &[u8] = &[
        // codec version
        0x00, 0x00, //
        //
        // platformvm.UnsignedCreateChainTx type ID
        0x00, 0x00, 0x00, 0x0f, //
        //
        // network id
        0x00, 0x0f, 0x42, 0x40, //
        //
        // blockchain id
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        0x00, 0x00, //
        //
        // outs.len()
        0x00, 0x00, 0x00, 0x01, //
        //
        // "outs[0]" TransferableOutput.asset_id
        0x88, 0xee, 0xc2, 0xe0, 0x99, 0xc6, 0xa5, 0x28, 0xe6, 0x89, 0x61, 0x8e, 0x87, 0x21, 0xe0,
        0x4a, 0xe8, 0x5e, 0xa5, 0x74, 0xc7, 0xa1, 0x5a, 0x79, 0x68, 0x64, 0x4d, 0x14, 0xd5, 0x47,
        0x80, 0x14, //
        //
        // NOTE: fx_id is serialize:"false"
        //
        // "outs[0]" secp256k1fx.TransferOutput type ID
        0x00, 0x00, 0x00, 0x07, //
        //
        // "outs[0]" TransferableOutput.out.secp256k1fx::TransferOutput.amount
        0x02, 0xc6, 0x87, 0x4d, 0x5c, 0x56, 0xf5, 0x00, //
        //
        // "outs[0]" TransferableOutput.out.secp256k1fx::TransferOutput.output_owners.locktime
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        //
        // "outs[0]" TransferableOutput.out.secp256k1fx::TransferOutput.output_owners.threshold
        0x00, 0x00, 0x00, 0x01, //
        //
        // "outs[0]" TransferableOutput.out.secp256k1fx::TransferOutput.output_owners.addrs.len()
        0x00, 0x00, 0x00, 0x01, //
        //
        // "outs[0]" TransferableOutput.out.secp256k1fx::TransferOutput.output_owners.addrs[0]
        0x65, 0x84, 0x4a, 0x05, 0x40, 0x5f, 0x36, 0x62, 0xc1, 0x92, 0x81, 0x42, 0xc6, 0xc2, 0xa7,
        0x83, 0xef, 0x87, 0x1d, 0xe9, //
        //
        // ins.len()
        0x00, 0x00, 0x00, 0x01, //
        //
        // "ins[0]" TransferableInput.utxo_id.tx_id
        0x4e, 0x02, 0x63, 0x73, 0xef, 0x9f, 0x0f, 0xaf, 0xf6, 0x24, //
        0x11, 0xc7, 0x15, 0x80, 0x8b, 0x28, 0x00, 0x60, 0x32, 0xce, //
        0x82, 0x9e, 0x1c, 0xb5, 0xb0, 0x46, 0xb9, 0xc8, 0x83, 0xae, //
        0xfb, 0xbc, //
        //
        // "ins[0]" TransferableInput.utxo_id.output_index
        0x00, 0x00, 0x00, 0x00, //
        //
        // "ins[0]" TransferableInput.asset_id
        0x88, 0xee, 0xc2, 0xe0, 0x99, 0xc6, 0xa5, 0x28, 0xe6, 0x89, //
        0x61, 0x8e, 0x87, 0x21, 0xe0, 0x4a, 0xe8, 0x5e, 0xa5, 0x74, //
        0xc7, 0xa1, 0x5a, 0x79, 0x68, 0x64, 0x4d, 0x14, 0xd5, 0x47, //
        0x80, 0x14, //
        //
        // "ins[0]" secp256k1fx.TransferInput type ID
        0x00, 0x00, 0x00, 0x05, //
        //
        // "ins[0]" TransferableInput.input.secp256k1fx::TransferInput.amount
        0x02, 0xc6, 0x87, 0x4d, 0x62, 0x4c, 0xd6, 0x00, //
        //
        // "ins[0]" TransferableInput.input.secp256k1fx::TransferInput.sig_indices.len()
        0x00, 0x00, 0x00, 0x01, //
        //
        // "ins[0]" TransferableInput.input.secp256k1fx::TransferInput.sig_indices[0]
        0x00, 0x00, 0x00, 0x00, //
        //
        // memo.len()
        0x00, 0x00, 0x00, 0x00, //
        //
        // subnet_id
        0xda, 0x77, 0x6a, 0xb0, 0xf6, 0x10, 0x01, 0x8e, 0x60, 0xa5, //
        0x0a, 0xc5, 0xb1, 0x48, 0x9a, 0x4d, 0xcd, 0xe0, 0x25, 0xf1, //
        0xf4, 0xa5, 0x62, 0x60, 0xc4, 0x4b, 0x86, 0x19, 0x46, 0x05, //
        0x0f, 0x11, //
        //
        // chain name "length"
        0x00, 0x09, //
        //
        // chain name
        0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x65, 0x76, 0x6d, //
        //
        // vm id
        0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x65, 0x76, 0x6d, 0x00, //
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
        0x00, 0x00, //
        //
        // fx_ids.len()
        0x00, 0x00, 0x00, 0x00, //
        //
        // genesis_data.len()
        0x00, 0x00, 0x06, 0x1f, //
        //
        // genesis
        0x7b, 0x22, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a, 0x7b, 0x22, 0x63, 0x68, 0x61,
        0x69, 0x6e, 0x49, 0x64, 0x22, 0x3a, 0x32, 0x30, 0x30, 0x30, 0x37, 0x37, 0x37, 0x2c, 0x22,
        0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22,
        0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x30, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
        0x22, 0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x30, 0x48, 0x61, 0x73, 0x68,
        0x22, 0x3a, 0x22, 0x30, 0x78, 0x32, 0x30, 0x38, 0x36, 0x37, 0x39, 0x39, 0x61, 0x65, 0x65,
        0x62, 0x65, 0x61, 0x65, 0x31, 0x33, 0x35, 0x63, 0x32, 0x34, 0x36, 0x63, 0x36, 0x35, 0x30,
        0x32, 0x31, 0x63, 0x38, 0x32, 0x62, 0x34, 0x65, 0x31, 0x35, 0x61, 0x32, 0x63, 0x34, 0x35,
        0x31, 0x33, 0x34, 0x30, 0x39, 0x39, 0x33, 0x61, 0x61, 0x63, 0x66, 0x64, 0x32, 0x37, 0x35,
        0x31, 0x38, 0x38, 0x36, 0x35, 0x31, 0x34, 0x66, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x69, 0x70,
        0x31, 0x35, 0x35, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x65, 0x69,
        0x70, 0x31, 0x35, 0x38, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x62,
        0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a,
        0x30, 0x2c, 0x22, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70,
        0x6c, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x70, 0x65, 0x74,
        0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30,
        0x2c, 0x22, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
        0x22, 0x3a, 0x30, 0x2c, 0x22, 0x6d, 0x75, 0x69, 0x72, 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65,
        0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x73, 0x75, 0x62, 0x6e,
        0x65, 0x74, 0x45, 0x56, 0x4d, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22,
        0x3a, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a,
        0x7b, 0x22, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3a, 0x32, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x2c, 0x22, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c,
        0x6f, 0x63, 0x6b, 0x52, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x32, 0x2c, 0x22, 0x6d, 0x69, 0x6e,
        0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x2c, 0x22, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x61, 0x73,
        0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2c, 0x22, 0x62, 0x61,
        0x73, 0x65, 0x46, 0x65, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x65, 0x6e, 0x6f,
        0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x3a, 0x34, 0x38, 0x2c, 0x22, 0x6d, 0x69,
        0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x3a,
        0x30, 0x2c, 0x22, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x43,
        0x6f, 0x73, 0x74, 0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2c, 0x22,
        0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x47, 0x61, 0x73, 0x43, 0x6f, 0x73, 0x74, 0x53, 0x74, 0x65,
        0x70, 0x22, 0x3a, 0x35, 0x30, 0x30, 0x30, 0x30, 0x30, 0x7d, 0x2c, 0x22, 0x63, 0x6f, 0x6e,
        0x74, 0x72, 0x61, 0x63, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x72, 0x41, 0x6c,
        0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3a,
        0x7b, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
        0x70, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72,
        0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x30, 0x78, 0x38, 0x64, 0x62, 0x39,
        0x37, 0x43, 0x37, 0x63, 0x45, 0x63, 0x45, 0x32, 0x34, 0x39, 0x63, 0x32, 0x62, 0x39, 0x38,
        0x62, 0x44, 0x43, 0x30, 0x32, 0x32, 0x36, 0x43, 0x63, 0x34, 0x43, 0x32, 0x41, 0x35, 0x37,
        0x42, 0x46, 0x35, 0x32, 0x46, 0x43, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x36, 0x31, 0x33, 0x30,
        0x34, 0x30, 0x61, 0x32, 0x33, 0x39, 0x42, 0x44, 0x66, 0x43, 0x46, 0x31, 0x31, 0x30, 0x39,
        0x36, 0x39, 0x66, 0x65, 0x63, 0x42, 0x34, 0x31, 0x63, 0x36, 0x66, 0x39, 0x32, 0x45, 0x41,
        0x33, 0x35, 0x31, 0x35, 0x43, 0x30, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x30, 0x61, 0x36, 0x33,
        0x61, 0x43, 0x43, 0x33, 0x37, 0x33, 0x35, 0x65, 0x38, 0x32, 0x35, 0x44, 0x37, 0x44, 0x31,
        0x33, 0x32, 0x34, 0x33, 0x46, 0x44, 0x37, 0x36, 0x62, 0x41, 0x64, 0x34, 0x39, 0x33, 0x33,
        0x31, 0x62, 0x61, 0x45, 0x30, 0x45, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x32, 0x66, 0x63, 0x39,
        0x32, 0x32, 0x42, 0x65, 0x65, 0x39, 0x30, 0x32, 0x35, 0x32, 0x30, 0x63, 0x34, 0x36, 0x38,
        0x31, 0x63, 0x35, 0x62, 0x62, 0x64, 0x39, 0x37, 0x39, 0x30, 0x38, 0x43, 0x37, 0x32, 0x37,
        0x36, 0x36, 0x34, 0x65, 0x35, 0x36, 0x22, 0x2c, 0x22, 0x30, 0x78, 0x30, 0x43, 0x38, 0x35,
        0x66, 0x32, 0x37, 0x35, 0x35, 0x30, 0x63, 0x61, 0x62, 0x33, 0x31, 0x32, 0x37, 0x46, 0x42,
        0x36, 0x44, 0x61, 0x38, 0x34, 0x45, 0x36, 0x44, 0x44, 0x63, 0x65, 0x43, 0x66, 0x33, 0x34,
        0x32, 0x37, 0x32, 0x66, 0x44, 0x30, 0x22, 0x5d, 0x7d, 0x7d, 0x2c, 0x22, 0x6e, 0x6f, 0x6e,
        0x63, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22, 0x74, 0x69, 0x6d, 0x65,
        0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22, 0x65,
        0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30,
        0x22, 0x2c, 0x22, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3a, 0x22, 0x30,
        0x78, 0x31, 0x33, 0x31, 0x32, 0x64, 0x30, 0x30, 0x22, 0x2c, 0x22, 0x64, 0x69, 0x66, 0x66,
        0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22,
        0x6d, 0x69, 0x78, 0x48, 0x61, 0x73, 0x68, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x22, 0x2c, 0x22, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3a, 0x22,
        0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x22,
        0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x43, 0x38, 0x35, 0x66, 0x32,
        0x37, 0x35, 0x35, 0x30, 0x63, 0x61, 0x62, 0x33, 0x31, 0x32, 0x37, 0x46, 0x42, 0x36, 0x44,
        0x61, 0x38, 0x34, 0x45, 0x36, 0x44, 0x44, 0x63, 0x65, 0x43, 0x66, 0x33, 0x34, 0x32, 0x37,
        0x32, 0x66, 0x44, 0x30, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65,
        0x22, 0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38,
        0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x2c,
        0x22, 0x30, 0x61, 0x36, 0x33, 0x61, 0x43, 0x43, 0x33, 0x37, 0x33, 0x35, 0x65, 0x38, 0x32,
        0x35, 0x44, 0x37, 0x44, 0x31, 0x33, 0x32, 0x34, 0x33, 0x46, 0x44, 0x37, 0x36, 0x62, 0x41,
        0x64, 0x34, 0x39, 0x33, 0x33, 0x31, 0x62, 0x61, 0x45, 0x30, 0x45, 0x22, 0x3a, 0x7b, 0x22,
        0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62,
        0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22, 0x32, 0x66, 0x63, 0x39, 0x32, 0x32, 0x42,
        0x65, 0x65, 0x39, 0x30, 0x32, 0x35, 0x32, 0x30, 0x63, 0x34, 0x36, 0x38, 0x31, 0x63, 0x35,
        0x62, 0x62, 0x64, 0x39, 0x37, 0x39, 0x30, 0x38, 0x43, 0x37, 0x32, 0x37, 0x36, 0x36, 0x34,
        0x65, 0x35, 0x36, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22,
        0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30,
        0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22,
        0x36, 0x31, 0x33, 0x30, 0x34, 0x30, 0x61, 0x32, 0x33, 0x39, 0x42, 0x44, 0x66, 0x43, 0x46,
        0x31, 0x31, 0x30, 0x39, 0x36, 0x39, 0x66, 0x65, 0x63, 0x42, 0x34, 0x31, 0x63, 0x36, 0x66,
        0x39, 0x32, 0x45, 0x41, 0x33, 0x35, 0x31, 0x35, 0x43, 0x30, 0x22, 0x3a, 0x7b, 0x22, 0x62,
        0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37,
        0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30, 0x63, 0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x22, 0x7d, 0x2c, 0x22, 0x38, 0x64, 0x62, 0x39, 0x37, 0x43, 0x37, 0x63,
        0x45, 0x63, 0x45, 0x32, 0x34, 0x39, 0x63, 0x32, 0x62, 0x39, 0x38, 0x62, 0x44, 0x43, 0x30,
        0x32, 0x32, 0x36, 0x43, 0x63, 0x34, 0x43, 0x32, 0x41, 0x35, 0x37, 0x42, 0x46, 0x35, 0x32,
        0x46, 0x43, 0x22, 0x3a, 0x7b, 0x22, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x3a,
        0x22, 0x30, 0x78, 0x35, 0x32, 0x62, 0x37, 0x64, 0x32, 0x64, 0x63, 0x63, 0x38, 0x30, 0x63,
        0x64, 0x32, 0x65, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, 0x7d, 0x2c, 0x22,
        0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c, 0x22,
        0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x22, 0x2c,
        0x22, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x22, 0x3a, 0x22, 0x30,
        0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
        0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d, //
        //
        // "secp256k1fx.Input" type id
        0x00, 0x00, 0x00, 0x0a, //
        //
        // secp256k1fx.Input.sig_indices.len()
        0x00, 0x00, 0x00, 0x01, //
        //
        // secp256k1fx.Input.sig_indices[0]
        0x00, 0x00, 0x00, 0x00, //
        //
        // number of credentials
        0x00, 0x00, 0x00, 0x02, //
        //
        // struct field type ID "fx::Credential.cred"
        // "secp256k1fx.Credential" type ID
        0x00, 0x00, 0x00, 0x09, //
        //
        // number of signers ("fx::Credential.cred.sigs.len()")
        0x00, 0x00, 0x00, 0x01, //
        //
        // first 65-byte signature
        0x02, 0x4d, 0xc2, 0x09, 0xa2, 0x56, 0x39, 0x8f, 0x13, 0x63, //
        0xb0, 0xb6, 0xd4, 0x67, 0x0e, 0xec, 0xac, 0x21, 0x46, 0x7f, //
        0xa5, 0xe1, 0x66, 0x12, 0xe6, 0x04, 0x5b, 0x68, 0x88, 0x1a, //
        0x6d, 0x26, 0x58, 0x04, 0x33, 0x80, 0x93, 0xa2, 0x5d, 0x8f, //
        0x2e, 0x72, 0xfa, 0x01, 0x73, 0x4f, 0x31, 0x94, 0x0c, 0x17, //
        0xc3, 0x8a, 0x55, 0xbf, 0x0b, 0x30, 0x03, 0xcf, 0xb4, 0x5a, //
        0x43, 0x93, 0xeb, 0xbe, 0x01, //
        //
        // struct field type ID "fx::Credential.cred"
        // "secp256k1fx.Credential" type ID
        0x00, 0x00, 0x00, 0x09, //
        //
        // number of signers ("fx::Credential.cred.sigs.len()")
        0x00, 0x00, 0x00, 0x01, //
        //
        // first 65-byte signature
        0x02, 0x4d, 0xc2, 0x09, 0xa2, 0x56, 0x39, 0x8f, 0x13, 0x63, //
        0xb0, 0xb6, 0xd4, 0x67, 0x0e, 0xec, 0xac, 0x21, 0x46, 0x7f, //
        0xa5, 0xe1, 0x66, 0x12, 0xe6, 0x04, 0x5b, 0x68, 0x88, 0x1a, //
        0x6d, 0x26, 0x58, 0x04, 0x33, 0x80, 0x93, 0xa2, 0x5d, 0x8f, //
        0x2e, 0x72, 0xfa, 0x01, 0x73, 0x4f, 0x31, 0x94, 0x0c, 0x17, //
        0xc3, 0x8a, 0x55, 0xbf, 0x0b, 0x30, 0x03, 0xcf, 0xb4, 0x5a, //
        0x43, 0x93, 0xeb, 0xbe, 0x01, //
    ];
    assert!(cmp::eq_vectors(expected_signed_bytes, &signed_bytes));
}