Skip to content

Commit 5f247a6

Browse files
committed
Clean up full_stack_target InMemorySigner builder
The code was a bit too long to begin with, and rustfmt made a total mess of it, so instead we should be building with more intermediate variables.
1 parent 683e849 commit 5f247a6

File tree

1 file changed

+21
-77
lines changed

1 file changed

+21
-77
lines changed

fuzz/src/full_stack.rs

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -443,85 +443,29 @@ impl SignerProvider for KeyProvider {
443443
[ctr; 32]
444444
}
445445

446-
fn derive_channel_signer(&self, channel_keys_id: [u8; 32]) -> Self::EcdsaSigner {
446+
fn derive_channel_signer(&self, keys_id: [u8; 32]) -> Self::EcdsaSigner {
447447
let secp_ctx = Secp256k1::signing_only();
448-
let ctr = channel_keys_id[0];
448+
let ctr = keys_id[0];
449449
let (inbound, state) = self.signer_state.borrow().get(&ctr).unwrap().clone();
450-
TestChannelSigner::new_with_revoked(
451-
DynSigner::new(if inbound {
452-
InMemorySigner::new(
453-
&secp_ctx,
454-
SecretKey::from_slice(&[
455-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
456-
0, 0, 0, 0, 0, 1, ctr,
457-
])
458-
.unwrap(),
459-
SecretKey::from_slice(&[
460-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
461-
0, 0, 0, 0, 0, 2, ctr,
462-
])
463-
.unwrap(),
464-
SecretKey::from_slice(&[
465-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
466-
0, 0, 0, 0, 0, 3, ctr,
467-
])
468-
.unwrap(),
469-
SecretKey::from_slice(&[
470-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
471-
0, 0, 0, 0, 0, 4, ctr,
472-
])
473-
.unwrap(),
474-
SecretKey::from_slice(&[
475-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
476-
0, 0, 0, 0, 0, 5, ctr,
477-
])
478-
.unwrap(),
479-
[
480-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
481-
0, 0, 0, 0, 0, 6, ctr,
482-
],
483-
channel_keys_id,
484-
channel_keys_id,
485-
)
486-
} else {
487-
InMemorySigner::new(
488-
&secp_ctx,
489-
SecretKey::from_slice(&[
490-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
491-
0, 0, 0, 0, 0, 7, ctr,
492-
])
493-
.unwrap(),
494-
SecretKey::from_slice(&[
495-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
496-
0, 0, 0, 0, 0, 8, ctr,
497-
])
498-
.unwrap(),
499-
SecretKey::from_slice(&[
500-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
501-
0, 0, 0, 0, 0, 9, ctr,
502-
])
503-
.unwrap(),
504-
SecretKey::from_slice(&[
505-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
506-
0, 0, 0, 0, 0, 10, ctr,
507-
])
508-
.unwrap(),
509-
SecretKey::from_slice(&[
510-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
511-
0, 0, 0, 0, 0, 11, ctr,
512-
])
513-
.unwrap(),
514-
[
515-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
516-
0, 0, 0, 0, 0, 12, ctr,
517-
],
518-
channel_keys_id,
519-
channel_keys_id,
520-
)
521-
}),
522-
state,
523-
false,
524-
)
450+
451+
let (a, b, c, d, e, f);
452+
let mut key = [0; 32];
453+
key[31] = ctr;
454+
key[30] = 1 + if inbound { 0 } else { 6 };
455+
a = SecretKey::from_slice(&key).unwrap();
456+
key[30] = 2 + if inbound { 0 } else { 6 };
457+
b = SecretKey::from_slice(&key).unwrap();
458+
key[30] = 3 + if inbound { 0 } else { 6 };
459+
c = SecretKey::from_slice(&key).unwrap();
460+
key[30] = 4 + if inbound { 0 } else { 6 };
461+
d = SecretKey::from_slice(&key).unwrap();
462+
key[30] = 5 + if inbound { 0 } else { 6 };
463+
e = SecretKey::from_slice(&key).unwrap();
464+
key[30] = 6 + if inbound { 0 } else { 6 };
465+
f = key;
466+
let signer = InMemorySigner::new(&secp_ctx, a, b, c, d, e, f, keys_id, keys_id);
467+
468+
TestChannelSigner::new_with_revoked(DynSigner::new(signer), state, false)
525469
}
526470

527471
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {

0 commit comments

Comments
 (0)