swisspost-evoting-go-poc/pkg/party/state.go
saymrwulf d2cfbf291f Ballot carries E2 + plaintext-equality proof, CC-verified
The voter now also submits E2 = Enc(vote, returnCodesPK[0]) and a plaintext-
equality proof that E2 and the ballot's slot 0 encrypt the SAME vote. Every CC
verifies this proof during ballot verification. This is the soundness link that
makes the return code cast-as-intended: a client that encrypts one vote for the
tally and a different one for the return-code channel is rejected, so the code
the CCs compute from E2 necessarily reflects the tallied vote.

- transcript: publish the combined return-codes public key.
- voter stores returnCodePK from the (confidential) card delivery.
- wire: plaintext-equality proof DTO.

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

80 lines
2.3 KiB
Go

package party
import (
"math/big"
"github.com/user/evote/pkg/elgamal"
emath "github.com/user/evote/pkg/math"
"github.com/user/evote/pkg/mixnet"
"github.com/user/evote/pkg/returncodes"
"github.com/user/evote/pkg/zkp"
)
// The state structs below hold each party's PRIVATE state. Nothing here may be
// read by another party except through an explicit signed message.
// setupState is the setup component's working store while assembling cards.
type setupState struct {
primes []*big.Int
votingCards []*votingCard
mappingTable *returncodes.MappingTable
electionPK elgamal.PublicKey
returnCodePK elgamal.PublicKey
}
// ccState is a control component's private key material and mix state.
type ccState struct {
keyPair elgamal.KeyPair
returnCodeSecret emath.ZqElement
schnorrProofs []zkp.SchnorrProof
// Tally working state.
shuffle mixnet.VerifiableShuffle
decProofs []zkp.DecryptionProof
shuffleIn *elgamal.CiphertextVector
shuffleOut *elgamal.CiphertextVector
}
// ebState is the electoral board's private key material.
type ebState struct {
passwords []string
keyPair elgamal.KeyPair
}
// serverState is the voting server / ballot box.
type serverState struct {
mappingTable *returncodes.MappingTable
ballotBox []encryptedBallot
electionPK elgamal.PublicKey
returnCodePK elgamal.PublicKey
primes []*big.Int
}
// voterState is a voter client's private card and ballot secrets.
type voterState struct {
card *votingCard
electionPK elgamal.PublicKey
returnCodePK elgamal.PublicKey
primes []*big.Int
vcSK emath.ZqElement
selected []int
}
// votingCard is a voter's credential bundle (private to the voter, produced by
// the setup component and delivered over a confidential channel).
type votingCard struct {
VoterID string `json:"voter_id"`
VerificationCardID string `json:"vc_id"`
StartVotingKey string `json:"svk"`
ChoiceReturnCodes []string `json:"choice_return_codes"`
VoteConfirmCode string `json:"vote_confirm_code"`
BallotCastingKey string `json:"bck"`
}
// encryptedBallot is a ballot as stored in the ballot box.
type encryptedBallot struct {
VoterID string
VerificationCardID string
Ciphertext elgamal.Ciphertext
VcPK emath.GqElement
}