~edwargix/tallyard

7030fa2f2d90ad1a627d7a71b540a1559286b6c1 — David Florness 2 years ago 19e636e
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.
1 files changed, 11 insertions(+), 3 deletions(-)

M election/msg.go
M election/msg.go => election/msg.go +11 -3
@@ 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])