diff --git a/processor/src/key_gen.rs b/processor/src/key_gen.rs index 40a858b4..ce670db4 100644 --- a/processor/src/key_gen.rs +++ b/processor/src/key_gen.rs @@ -267,6 +267,12 @@ impl KeyGen { let (coin_machine, coin_shares) = handle_machine(&mut rng, params, machines.1, &mut commitments_ref); + for (_, commitments) in commitments_ref { + if !commitments.is_empty() { + todo!("malicious signer: extra bytes"); + } + } + self.active_share.insert(id.set, (substrate_machine, coin_machine)); let mut shares: HashMap<_, _> = @@ -354,6 +360,12 @@ impl KeyGen { let substrate_keys = handle_machine(&mut rng, params, machines.0, &mut shares_ref); let coin_keys = handle_machine(&mut rng, params, machines.1, &mut shares_ref); + for (_, shares) in shares_ref { + if !shares.is_empty() { + todo!("malicious signer: extra bytes"); + } + } + let mut coin_keys = ThresholdKeys::new(coin_keys); C::tweak_keys(&mut coin_keys); diff --git a/processor/src/signer.rs b/processor/src/signer.rs index 3e6fb41a..85804fa5 100644 --- a/processor/src/signer.rs +++ b/processor/src/signer.rs @@ -374,9 +374,14 @@ impl Signer { let preprocesses = match preprocesses .drain() .map(|(l, preprocess)| { - machine - .read_preprocess::<&[u8]>(&mut preprocess.as_ref()) - .map(|preprocess| (l, preprocess)) + let mut preprocess_ref = preprocess.as_ref(); + let res = machine + .read_preprocess::<&[u8]>(&mut preprocess_ref) + .map(|preprocess| (l, preprocess)); + if !preprocess_ref.is_empty() { + todo!("malicious signer: extra bytes"); + } + res }) .collect::>() { @@ -424,7 +429,12 @@ impl Signer { let shares = match shares .drain() .map(|(l, share)| { - machine.read_share::<&[u8]>(&mut share.as_ref()).map(|share| (l, share)) + let mut share_ref = share.as_ref(); + let res = machine.read_share::<&[u8]>(&mut share_ref).map(|share| (l, share)); + if !share_ref.is_empty() { + todo!("malicious signer: extra bytes"); + } + res }) .collect::>() {