From 7030fa2f2d90ad1a627d7a71b540a1559286b6c1 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sat, 12 Mar 2022 22:06:33 -0500 Subject: [PATCH] Fix panic when our device doesn't have election private keys In cases where the user joins an election on another computer, we need to make sure we don't panic merely because our device doesn't have the private keys to fully verify sum+evals messages. This change simply marks the verification process of the election as failed. In the future we can use something like SSSS to share keys between tallyard devices. --- election/msg.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/election/msg.go b/election/msg.go index 49fad4c..d70f071 100644 --- a/election/msg.go +++ b/election/msg.go @@ -664,11 +664,11 @@ func (elections *ElectionsMap) onEvalsMessage(evt *event.Event) (success bool) { } voter.EvalsID = &evt.ID - // we're not participating in this election if el.LocalVoter == nil { - return true + debugf("our device is not a part of this election") + return } else if el.LocalVoter.JoinIDIndex == nil { - warnf("we didn't join the election in time (or the election creator excluded us)") + warnf("our device didn't join the election in time (or the election creator excluded us)") return } ourEval := content.Evals[*el.LocalVoter.JoinIDIndex] @@ -881,6 +881,14 @@ func (elections *ElectionsMap) onSumMessage(evt *event.Event) (success bool) { sum = new(fr.Element).SetBytes(sumBytes) } + if el.LocalVoter == nil { + debugf("our device is not a part of this election") + return + } else if el.LocalVoter.JoinIDIndex == nil { + warnf("our device didn't join the election in time (or the election creator excluded us)") + return + } + var proof groth16.Proof { encrypted, err := base64.StdEncoding.DecodeString(content.Proofs[*el.LocalVoter.JoinIDIndex]) -- 2.38.4