~edwargix/tallyard

52d939a17c8b87b97b97a1a51e9ea2c35883f2e6 — David Florness 4 years ago 6a944b7
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.
3 files changed, 3 insertions(+), 10 deletions(-)

M cmd/tallyard/main.go
M election/map.go
M election/voter.go
M cmd/tallyard/main.go => cmd/tallyard/main.go +2 -8
@@ 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()
	}


M election/map.go => election/map.go +1 -1
@@ 38,7 38,7 @@ type ElectionsMap struct {
	Ltime      time.Time                   `json:"-"`
}

const electionsMapVersion = 4
const electionsMapVersion = 5

var electionsFname = xdg.DataHome() + "/tallyard/elections.json"


M election/voter.go => election/voter.go +0 -1
@@ 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"`
}