diff --git a/processor/src/key_gen.rs b/processor/src/key_gen.rs index 6a9f692d..40a858b4 100644 --- a/processor/src/key_gen.rs +++ b/processor/src/key_gen.rs @@ -71,7 +71,7 @@ impl KeyGenDb { txn: &mut D::Transaction<'_>, id: &KeyGenId, substrate_keys: &ThresholdCore, - coin_keys: &ThresholdCore, + coin_keys: &ThresholdKeys, ) { let mut keys = substrate_keys.serialize(); keys.extend(coin_keys.serialize().iter()); @@ -108,6 +108,14 @@ impl KeyGenDb { txn, &Self::generated_keys_key(set, (key_pair.0.as_ref(), key_pair.1.as_ref())), ); + assert_eq!(key_pair.0 .0, keys.0.group_key().to_bytes()); + assert_eq!( + { + let coin_key: &[u8] = key_pair.1.as_ref(); + coin_key + }, + keys.1.group_key().to_bytes().as_ref(), + ); txn.put(Self::keys_key(&keys.1.group_key()), keys_vec); keys } @@ -115,7 +123,9 @@ impl KeyGenDb { getter: &G, key: &::G, ) -> (ThresholdKeys, ThresholdKeys) { - Self::read_keys(getter, &Self::keys_key(key)).1 + let res = Self::read_keys(getter, &Self::keys_key(key)).1; + assert_eq!(&res.1.group_key(), key); + res } } @@ -344,10 +354,11 @@ 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); - KeyGenDb::::save_keys(txn, &id, &substrate_keys, &coin_keys); - let mut coin_keys = ThresholdKeys::new(coin_keys); C::tweak_keys(&mut coin_keys); + + KeyGenDb::::save_keys(txn, &id, &substrate_keys, &coin_keys); + ProcessorMessage::GeneratedKeyPair { id, substrate_key: substrate_keys.group_key().to_bytes(),