~edwargix/tallyard

f0a7f2b39525f0a90492c54e2927245f167643ed — David Florness 4 years ago 81a358e
Don't set LocalVoter's eval until after potential error
1 files changed, 3 insertions(+), 3 deletions(-)

M election/voter.go
M election/voter.go => election/voter.go +3 -3
@@ 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)
	}