Fix SbvBroadcast observer issue.

Make sure observers also try to output when receiving a `BVal` message.

Also, make sure `ThresholdDecryption` doesn't fail for observers without
a key share.
This commit is contained in:
Andreas Fackler 2018-10-28 15:55:07 +01:00
parent a331982fa6
commit dfdb1d8a65
2 changed files with 8 additions and 6 deletions

View File

@ -145,7 +145,7 @@ impl<N: NodeIdT> SbvBroadcast<N> {
/// Multicasts and handles a message. Does nothing if we are only an observer.
fn send(&mut self, msg: Message) -> Result<Step<N>> {
if !self.netinfo.is_validator() {
return Ok(Step::default());
return self.try_output();
}
let step: Step<_> = Target::All.message(msg.clone()).into();
let our_id = &self.our_id().clone();

View File

@ -94,6 +94,10 @@ impl<N: NodeIdT> ThresholdDecryption<N> {
if self.ciphertext.is_some() {
return Err(Error::MultipleInputs(Box::new(ct)));
}
if !self.netinfo.is_validator() {
self.ciphertext = Some(ct);
return Ok(self.try_output()?);
}
let share = match self.netinfo.secret_key_share().decrypt_share(&ct) {
None => return Err(Error::InvalidCiphertext(Box::new(ct))),
Some(share) => share,
@ -102,11 +106,9 @@ impl<N: NodeIdT> ThresholdDecryption<N> {
let our_id = self.our_id().clone();
let mut step = Step::default();
step.fault_log.extend(self.remove_invalid_shares());
if self.netinfo.is_validator() {
let msg = Target::All.message(Message(share.clone()));
step.messages.push(msg);
self.shares.insert(our_id, share);
}
let msg = Target::All.message(Message(share.clone()));
step.messages.push(msg);
self.shares.insert(our_id, share);
step.extend(self.try_output()?);
Ok(step)
}