swisspost-evoting-go-poc/pkg/party/phases.go
saymrwulf a443e44875 Voting phase: ballot submission with cross-party proof verification
Voters encrypt their selection under the election key, build the (sound)
exponentiation proof binding the ballot to their verification-card key, and
submit to the voting server. The server validates every group element on
receipt, routes the ballot to all four CCs for proof verification, and stores
it only on unanimous acceptance — persisting vcPK (finding F6) so the proof
statement is reconstructible by any party.

- voting.go: castBallot (voter), handleCastBallot (server), handleVerifyBallot
  (CC). The CC re-derives the proof statement and verifies it; a malformed proof
  or bad group element yields a clean reject, never a panic (the trust-boundary
  hardening deferred from the due-diligence pass).
- wire.go: exponentiation-proof DTO.

Tests: 4 ballots flow end-to-end and are stored with vcPK; a ballot with a
zeroed proof is rejected by the CCs and never stored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 15:19:07 +02:00

49 lines
1.5 KiB
Go

package party
import (
"fmt"
"github.com/user/evote/pkg/transport"
)
// Phase message handlers. These are filled in incrementally (setup, then
// voting, then tally). Until a phase is implemented its handler rejects unknown
// message types cleanly rather than panicking — the transport boundary must
// never crash on an unexpected message.
func (p *SetupComponent) handleSetupMsg(env *transport.Envelope) (*transport.Envelope, error) {
return nil, fmt.Errorf("%s: unhandled message type %q", p.id.Name, env.Type)
}
func (p *ControlComponent) handleCCMsg(env *transport.Envelope) (*transport.Envelope, error) {
switch env.Type {
case MsgGenCCKeys:
return p.handleGenCCKeys(env)
case MsgLongCodeShareReq:
return p.handleLongCodeShare(env)
case MsgVerifyBallot:
return p.handleVerifyBallot(env)
default:
return nil, fmt.Errorf("%s: unhandled message type %q", p.id.Name, env.Type)
}
}
func (p *ElectoralBoard) handleEBMsg(env *transport.Envelope) (*transport.Envelope, error) {
switch env.Type {
case MsgGenEBKey:
return p.handleGenEBKey(env)
default:
return nil, fmt.Errorf("%s: unhandled message type %q", p.id.Name, env.Type)
}
}
func (p *VotingServer) handleServerMsg(env *transport.Envelope) (*transport.Envelope, error) {
switch env.Type {
case MsgMappingTable:
return p.handleMappingTable(env)
case MsgCastBallot:
return p.handleCastBallot(env)
default:
return nil, fmt.Errorf("%s: unhandled message type %q", p.id.Name, env.Type)
}
}