@@ -80,24 +80,20 @@ enum NoiseState {
80
80
}
81
81
82
82
pub struct PeerChannelEncryptor {
83
- secp_ctx : Secp256k1 < secp256k1:: SignOnly > ,
84
83
their_node_id : Option < PublicKey > , // filled in for outbound, or inbound after noise_state is Finished
85
84
86
85
noise_state : NoiseState ,
87
86
}
88
87
89
88
impl PeerChannelEncryptor {
90
89
pub fn new_outbound ( their_node_id : PublicKey , ephemeral_key : SecretKey ) -> PeerChannelEncryptor {
91
- let secp_ctx = Secp256k1 :: signing_only ( ) ;
92
-
93
90
let mut sha = Sha256 :: engine ( ) ;
94
91
sha. input ( & NOISE_H ) ;
95
92
sha. input ( & their_node_id. serialize ( ) [ ..] ) ;
96
93
let h = Sha256 :: from_engine ( sha) . into_inner ( ) ;
97
94
98
95
PeerChannelEncryptor {
99
96
their_node_id : Some ( their_node_id) ,
100
- secp_ctx,
101
97
noise_state : NoiseState :: InProgress {
102
98
state : NoiseStep :: PreActOne ,
103
99
directional_state : DirectionalNoiseState :: Outbound {
@@ -111,9 +107,7 @@ impl PeerChannelEncryptor {
111
107
}
112
108
}
113
109
114
- pub fn new_inbound ( our_node_secret : & SecretKey ) -> PeerChannelEncryptor {
115
- let secp_ctx = Secp256k1 :: signing_only ( ) ;
116
-
110
+ pub fn new_inbound < C : secp256k1:: Signing > ( our_node_secret : & SecretKey , secp_ctx : & Secp256k1 < C > ) -> PeerChannelEncryptor {
117
111
let mut sha = Sha256 :: engine ( ) ;
118
112
sha. input ( & NOISE_H ) ;
119
113
let our_node_id = PublicKey :: from_secret_key ( & secp_ctx, our_node_secret) ;
@@ -122,7 +116,6 @@ impl PeerChannelEncryptor {
122
116
123
117
PeerChannelEncryptor {
124
118
their_node_id : None ,
125
- secp_ctx,
126
119
noise_state : NoiseState :: InProgress {
127
120
state : NoiseStep :: PreActOne ,
128
121
directional_state : DirectionalNoiseState :: Inbound {
@@ -224,7 +217,7 @@ impl PeerChannelEncryptor {
224
217
Ok ( ( their_pub, temp_k) )
225
218
}
226
219
227
- pub fn get_act_one ( & mut self ) -> [ u8 ; 50 ] {
220
+ pub fn get_act_one < C : secp256k1 :: Signing > ( & mut self , secp_ctx : & Secp256k1 < C > ) -> [ u8 ; 50 ] {
228
221
match self . noise_state {
229
222
NoiseState :: InProgress { ref mut state, ref directional_state, ref mut bidirectional_state } =>
230
223
match directional_state {
@@ -233,7 +226,7 @@ impl PeerChannelEncryptor {
233
226
panic ! ( "Requested act at wrong step" ) ;
234
227
}
235
228
236
- let ( res, _) = PeerChannelEncryptor :: outbound_noise_act ( & self . secp_ctx , bidirectional_state, & ie, & self . their_node_id . unwrap ( ) ) ;
229
+ let ( res, _) = PeerChannelEncryptor :: outbound_noise_act ( secp_ctx, bidirectional_state, & ie, & self . their_node_id . unwrap ( ) ) ;
237
230
* state = NoiseStep :: PostActOne ;
238
231
res
239
232
} ,
@@ -243,7 +236,9 @@ impl PeerChannelEncryptor {
243
236
}
244
237
}
245
238
246
- pub fn process_act_one_with_keys ( & mut self , act_one : & [ u8 ] , our_node_secret : & SecretKey , our_ephemeral : SecretKey ) -> Result < [ u8 ; 50 ] , LightningError > {
239
+ pub fn process_act_one_with_keys < C : secp256k1:: Signing > (
240
+ & mut self , act_one : & [ u8 ] , our_node_secret : & SecretKey , our_ephemeral : SecretKey , secp_ctx : & Secp256k1 < C > )
241
+ -> Result < [ u8 ; 50 ] , LightningError > {
247
242
assert_eq ! ( act_one. len( ) , 50 ) ;
248
243
249
244
match self . noise_state {
@@ -259,7 +254,8 @@ impl PeerChannelEncryptor {
259
254
260
255
re. get_or_insert ( our_ephemeral) ;
261
256
262
- let ( res, temp_k) = PeerChannelEncryptor :: outbound_noise_act ( & self . secp_ctx , bidirectional_state, & re. unwrap ( ) , & ie. unwrap ( ) ) ;
257
+ let ( res, temp_k) =
258
+ PeerChannelEncryptor :: outbound_noise_act ( secp_ctx, bidirectional_state, & re. unwrap ( ) , & ie. unwrap ( ) ) ;
263
259
* temp_k2 = Some ( temp_k) ;
264
260
* state = NoiseStep :: PostActTwo ;
265
261
Ok ( res)
@@ -270,7 +266,9 @@ impl PeerChannelEncryptor {
270
266
}
271
267
}
272
268
273
- pub fn process_act_two ( & mut self , act_two : & [ u8 ] , our_node_secret : & SecretKey ) -> Result < ( [ u8 ; 66 ] , PublicKey ) , LightningError > {
269
+ pub fn process_act_two < C : secp256k1:: Signing > (
270
+ & mut self , act_two : & [ u8 ] , our_node_secret : & SecretKey , secp_ctx : & Secp256k1 < C > )
271
+ -> Result < ( [ u8 ; 66 ] , PublicKey ) , LightningError > {
274
272
assert_eq ! ( act_two. len( ) , 50 ) ;
275
273
276
274
let final_hkdf;
@@ -286,7 +284,7 @@ impl PeerChannelEncryptor {
286
284
let ( re, temp_k2) = PeerChannelEncryptor :: inbound_noise_act ( bidirectional_state, act_two, & ie) ?;
287
285
288
286
let mut res = [ 0 ; 66 ] ;
289
- let our_node_id = PublicKey :: from_secret_key ( & self . secp_ctx , & our_node_secret) ;
287
+ let our_node_id = PublicKey :: from_secret_key ( secp_ctx, & our_node_secret) ;
290
288
291
289
PeerChannelEncryptor :: encrypt_with_ad ( & mut res[ 1 ..50 ] , 1 , & temp_k2, & bidirectional_state. h , & our_node_id. serialize ( ) [ ..] ) ;
292
290
@@ -474,28 +472,31 @@ mod tests {
474
472
use super :: LN_MAX_MSG_LEN ;
475
473
476
474
use bitcoin:: secp256k1:: { PublicKey , SecretKey } ;
475
+ use bitcoin:: secp256k1:: Secp256k1 ;
477
476
478
477
use hex;
479
478
480
479
use ln:: peer_channel_encryptor:: { PeerChannelEncryptor , NoiseState } ;
481
480
482
481
fn get_outbound_peer_for_initiator_test_vectors ( ) -> PeerChannelEncryptor {
483
482
let their_node_id = PublicKey :: from_slice ( & hex:: decode ( "028d7500dd4c12685d1f568b4c2b5048e8534b873319f3a8daa612b469132ec7f7" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
483
+ let secp_ctx = Secp256k1 :: signing_only ( ) ;
484
484
485
485
let mut outbound_peer = PeerChannelEncryptor :: new_outbound ( their_node_id, SecretKey :: from_slice ( & hex:: decode ( "1212121212121212121212121212121212121212121212121212121212121212" ) . unwrap ( ) [ ..] ) . unwrap ( ) ) ;
486
- assert_eq ! ( outbound_peer. get_act_one( ) [ ..] , hex:: decode( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap( ) [ ..] ) ;
486
+ assert_eq ! ( outbound_peer. get_act_one( & secp_ctx ) [ ..] , hex:: decode( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap( ) [ ..] ) ;
487
487
outbound_peer
488
488
}
489
489
490
490
fn get_inbound_peer_for_test_vectors ( ) -> PeerChannelEncryptor {
491
491
// transport-responder successful handshake
492
492
let our_node_id = SecretKey :: from_slice ( & hex:: decode ( "2121212121212121212121212121212121212121212121212121212121212121" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
493
493
let our_ephemeral = SecretKey :: from_slice ( & hex:: decode ( "2222222222222222222222222222222222222222222222222222222222222222" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
494
+ let secp_ctx = Secp256k1 :: signing_only ( ) ;
494
495
495
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
496
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
496
497
497
498
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
498
- assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
499
+ assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
499
500
500
501
let act_three = hex:: decode ( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap ( ) . to_vec ( ) ;
501
502
// test vector doesn't specify the initiator static key, but it's the same as the one
@@ -520,13 +521,14 @@ mod tests {
520
521
#[ test]
521
522
fn noise_initiator_test_vectors ( ) {
522
523
let our_node_id = SecretKey :: from_slice ( & hex:: decode ( "1111111111111111111111111111111111111111111111111111111111111111" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
524
+ let secp_ctx = Secp256k1 :: signing_only ( ) ;
523
525
524
526
{
525
527
// transport-initiator successful handshake
526
528
let mut outbound_peer = get_outbound_peer_for_initiator_test_vectors ( ) ;
527
529
528
530
let act_two = hex:: decode ( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap ( ) . to_vec ( ) ;
529
- assert_eq ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id) . unwrap( ) . 0 [ ..] , hex:: decode( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap( ) [ ..] ) ;
531
+ assert_eq ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id, & secp_ctx ) . unwrap( ) . 0 [ ..] , hex:: decode( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap( ) [ ..] ) ;
530
532
531
533
match outbound_peer. noise_state {
532
534
NoiseState :: Finished { sk, sn, sck, rk, rn, rck } => {
@@ -549,30 +551,31 @@ mod tests {
549
551
let mut outbound_peer = get_outbound_peer_for_initiator_test_vectors ( ) ;
550
552
551
553
let act_two = hex:: decode ( "0102466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap ( ) . to_vec ( ) ;
552
- assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id) . is_err( ) ) ;
554
+ assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id, & secp_ctx ) . is_err( ) ) ;
553
555
}
554
556
555
557
{
556
558
// transport-initiator act2 bad key serialization test
557
559
let mut outbound_peer = get_outbound_peer_for_initiator_test_vectors ( ) ;
558
560
559
561
let act_two = hex:: decode ( "0004466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap ( ) . to_vec ( ) ;
560
- assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id) . is_err( ) ) ;
562
+ assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id, & secp_ctx ) . is_err( ) ) ;
561
563
}
562
564
563
565
{
564
566
// transport-initiator act2 bad MAC test
565
567
let mut outbound_peer = get_outbound_peer_for_initiator_test_vectors ( ) ;
566
568
567
569
let act_two = hex:: decode ( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730af" ) . unwrap ( ) . to_vec ( ) ;
568
- assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id) . is_err( ) ) ;
570
+ assert ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id, & secp_ctx ) . is_err( ) ) ;
569
571
}
570
572
}
571
573
572
574
#[ test]
573
575
fn noise_responder_test_vectors ( ) {
574
576
let our_node_id = SecretKey :: from_slice ( & hex:: decode ( "2121212121212121212121212121212121212121212121212121212121212121" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
575
577
let our_ephemeral = SecretKey :: from_slice ( & hex:: decode ( "2222222222222222222222222222222222222222222222222222222222222222" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
578
+ let secp_ctx = Secp256k1 :: signing_only ( ) ;
576
579
577
580
{
578
581
let _ = get_inbound_peer_for_test_vectors ( ) ;
@@ -583,31 +586,31 @@ mod tests {
583
586
}
584
587
{
585
588
// transport-responder act1 bad version test
586
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
589
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
587
590
588
591
let act_one = hex:: decode ( "01036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
589
- assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . is_err( ) ) ;
592
+ assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . is_err( ) ) ;
590
593
}
591
594
{
592
595
// transport-responder act1 bad key serialization test
593
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
596
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
594
597
595
598
let act_one =hex:: decode ( "00046360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
596
- assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . is_err( ) ) ;
599
+ assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . is_err( ) ) ;
597
600
}
598
601
{
599
602
// transport-responder act1 bad MAC test
600
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
603
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
601
604
602
605
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6b" ) . unwrap ( ) . to_vec ( ) ;
603
- assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . is_err( ) ) ;
606
+ assert ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . is_err( ) ) ;
604
607
}
605
608
{
606
609
// transport-responder act3 bad version test
607
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
610
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
608
611
609
612
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
610
- assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
613
+ assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
611
614
612
615
let act_three = hex:: decode ( "01b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap ( ) . to_vec ( ) ;
613
616
assert ! ( inbound_peer. process_act_three( & act_three[ ..] ) . is_err( ) ) ;
@@ -618,30 +621,30 @@ mod tests {
618
621
}
619
622
{
620
623
// transport-responder act3 bad MAC for ciphertext test
621
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
624
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
622
625
623
626
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
624
- assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
627
+ assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
625
628
626
629
let act_three = hex:: decode ( "00c9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap ( ) . to_vec ( ) ;
627
630
assert ! ( inbound_peer. process_act_three( & act_three[ ..] ) . is_err( ) ) ;
628
631
}
629
632
{
630
633
// transport-responder act3 bad rs test
631
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
634
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
632
635
633
636
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
634
- assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
637
+ assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
635
638
636
639
let act_three = hex:: decode ( "00bfe3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa2235536ad09a8ee351870c2bb7f78b754a26c6cef79a98d25139c856d7efd252c2ae73c" ) . unwrap ( ) . to_vec ( ) ;
637
640
assert ! ( inbound_peer. process_act_three( & act_three[ ..] ) . is_err( ) ) ;
638
641
}
639
642
{
640
643
// transport-responder act3 bad MAC test
641
- let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id) ;
644
+ let mut inbound_peer = PeerChannelEncryptor :: new_inbound ( & our_node_id, & secp_ctx ) ;
642
645
643
646
let act_one = hex:: decode ( "00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a" ) . unwrap ( ) . to_vec ( ) ;
644
- assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
647
+ assert_eq ! ( inbound_peer. process_act_one_with_keys( & act_one[ ..] , & our_node_id, our_ephemeral. clone( ) , & secp_ctx ) . unwrap( ) [ ..] , hex:: decode( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap( ) [ ..] ) ;
645
648
646
649
let act_three = hex:: decode ( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139bb" ) . unwrap ( ) . to_vec ( ) ;
647
650
assert ! ( inbound_peer. process_act_three( & act_three[ ..] ) . is_err( ) ) ;
@@ -654,12 +657,13 @@ mod tests {
654
657
// We use the same keys as the initiator and responder test vectors, so we copy those tests
655
658
// here and use them to encrypt.
656
659
let mut outbound_peer = get_outbound_peer_for_initiator_test_vectors ( ) ;
660
+ let secp_ctx = Secp256k1 :: signing_only ( ) ;
657
661
658
662
{
659
663
let our_node_id = SecretKey :: from_slice ( & hex:: decode ( "1111111111111111111111111111111111111111111111111111111111111111" ) . unwrap ( ) [ ..] ) . unwrap ( ) ;
660
664
661
665
let act_two = hex:: decode ( "0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae" ) . unwrap ( ) . to_vec ( ) ;
662
- assert_eq ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id) . unwrap( ) . 0 [ ..] , hex:: decode( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap( ) [ ..] ) ;
666
+ assert_eq ! ( outbound_peer. process_act_two( & act_two[ ..] , & our_node_id, & secp_ctx ) . unwrap( ) . 0 [ ..] , hex:: decode( "00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba" ) . unwrap( ) [ ..] ) ;
663
667
664
668
match outbound_peer. noise_state {
665
669
NoiseState :: Finished { sk, sn, sck, rk, rn, rck } => {
0 commit comments