swisspost-evoting-go-poc/pkg/protocol/actors.go
saymrwulf e8b6f30871 Swiss Post E-Voting Go PoC
Proof-of-concept reimplementation of the Swiss Post e-voting
cryptographic protocol in Go. Single binary, 52 source files,
2 dependencies. Covers ElGamal encryption, Bayer-Groth verifiable
shuffles, zero-knowledge proofs, return codes, and a full
election ceremony demo.
2026-02-13 19:53:09 +01:00

39 lines
1.1 KiB
Go

package protocol
import (
"fmt"
"math/rand"
)
// RunDemoElection runs a complete election ceremony with the given parameters.
func RunDemoElection(numVoters, numOptions int) {
fmt.Println("========================================")
fmt.Println(" Swiss Post E-Voting Protocol PoC (Go)")
fmt.Println("========================================")
fmt.Printf(" Voters: %d, Options: %d, CCs: 4\n", numVoters, numOptions)
fmt.Println()
// Phase 1: Setup
fmt.Println("--- SETUP PHASE ---")
cfg := DefaultConfig(numVoters, numOptions)
fmt.Printf(" Group: %d-bit safe prime\n", cfg.Group.Q().BitLen())
event := Setup(cfg)
fmt.Printf(" Generated %d voting cards\n", numVoters)
fmt.Printf(" Mapping table: %d entries\n", event.MappingTable.Size())
fmt.Println(" Setup complete.")
// Phase 2: Voting
fmt.Println("\n--- VOTING PHASE ---")
for v := 0; v < numVoters; v++ {
// Randomly select 1 option for each voter
selected := []int{rand.Intn(numOptions)}
CastVote(event, v, selected)
}
fmt.Printf(" All %d votes cast.\n", numVoters)
// Phase 3: Tally
Tally(event)
// Phase 4: Verify
VerifyTally(event)
}