From 52d939a17c8b87b97b97a1a51e9ea2c35883f2e6 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sun, 14 Feb 2021 19:38:23 -0500 Subject: [PATCH] Don't store raw ballot in elections file Storing the random polynomial sufficies for incidents where an error occurs in the middle of an election. --- cmd/tallyard/main.go | 10 ++-------- election/map.go | 2 +- election/voter.go | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cmd/tallyard/main.go b/cmd/tallyard/main.go index efbb050..cdc9d88 100644 --- a/cmd/tallyard/main.go +++ b/cmd/tallyard/main.go @@ -129,16 +129,10 @@ func main() { // vote if we need to (user may have voted in previous tallyard // invocation) - if el.LocalVoter.Ballot == nil { + if el.LocalVoter.Poly == nil { candidates := el.Candidates ballot := ui.VoteTUI(candidates) - el.LocalVoter.Ballot = &ballot - el.Save() - } - - // set random poly with ballot if we haven't already - if el.LocalVoter.Poly == nil { - el.LocalVoter.Poly = math.NewRandomPoly(uint(len(*el.FinalJoinIDs)-1), 1024, *el.LocalVoter.Ballot) + el.LocalVoter.Poly = math.NewRandomPoly(uint(len(*el.FinalJoinIDs)-1), 1024, ballot) el.Save() } diff --git a/election/map.go b/election/map.go index e1327fe..6412f05 100644 --- a/election/map.go +++ b/election/map.go @@ -38,7 +38,7 @@ type ElectionsMap struct { Ltime time.Time `json:"-"` } -const electionsMapVersion = 4 +const electionsMapVersion = 5 var electionsFname = xdg.DataHome() + "/tallyard/elections.json" diff --git a/election/voter.go b/election/voter.go index 946f337..3dc6459 100644 --- a/election/voter.go +++ b/election/voter.go @@ -32,7 +32,6 @@ type Voter struct { type LocalVoter struct { *Voter - Ballot *[]byte `json:"ballot,omitempty"` Poly *math.Poly `json:"poly,omitempty"` PrivKey [32]byte `json:"priv_key"` } -- 2.38.4