From f0a7f2b39525f0a90492c54e2927245f167643ed Mon Sep 17 00:00:00 2001 From: David Florness Date: Tue, 19 Jan 2021 19:18:00 -0500 Subject: [PATCH] Don't set LocalVoter's eval until after potential error --- election/voter.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/election/voter.go b/election/voter.go index 5012cd5..78e26b1 100644 --- a/election/voter.go +++ b/election/voter.go @@ -191,13 +191,13 @@ func (el *Election) SendEvals(client *mautrix.Client) error { for _, voterJoinId := range *el.FinalVoters { voter := el.Joins[voterJoinId] output := el.LocalVoter.Poly.Eval(&voter.Input) - if voter.JoinEvt.ID == el.LocalVoter.JoinEvt.ID { - el.LocalVoter.Eval = output - } var nonce [24]byte if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil { return err } + if voter.JoinEvt.ID == el.LocalVoter.JoinEvt.ID { + el.LocalVoter.Eval = output + } encrypted := box.Seal(nonce[:], output.Bytes(), &nonce, &voter.PubKey, &el.LocalVoter.PrivKey) content.Outputs[voter.JoinEvt.ID] = base64.StdEncoding.EncodeToString(encrypted) } -- 2.38.4