Example #1
0
func main() {
	name := "TestVoter1"
	config, privateInfo := load(name)
	configHash := ConfigHash(privateInfo)
	fmt.Printf("Loaded election config with hash: %s\n", base64.StdEncoding.EncodeToString(configHash))

	ballotKey = keys.UnpackKey(config.BallotServer.Key)
	voteKey = keys.UnpackKey(config.VoteServer.Key)

	voterKey := keys.UnpackPrivateKey(privateInfo.Key)

	fillInfo(privateInfo)
	//var err error
	//privateInfo.KeySignature, err = GetKeySig(PublicKey(privateInfo))
	//if err != nil {
	//	panic(err)
	//}

	// Construct ballot
	// TODO: prompt user or read from file
	ballot := PrefixBallot([]byte("ballot!!"))

	ballotSig, err := GetBallotSig(voterKey, privateInfo.KeySignature, ballot)
	if err != nil {
		panic(err)
	}

	vote, err := SubmitBallot(ballot, ballotSig)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Cast ballot '%s' as %s\n", ballot, vote)
}
Example #2
0
func init() {

	// Load the singing key
	// TODO: load from election config file
	voterListKey := keys.UnpackPrivateKey(config.LoadServerKey("voterListKey"))
	config := config.Load()
	for _, voter := range config.Voters {
		voterKey, err := proto.Marshal(voter.Key)
		if err != nil {
			panic(err)
		}
		sig, err := sign.Sign(voterListKey, voterKey)
		if err != nil {
			panic(err)
		}
		voterKeys[string(voterKey)] = sig
		fmt.Printf("Added voter %s.\n", *voter.Name)
	}
}
Example #3
0
func init() {
	votePrivateKey = keys.UnpackPrivateKey(config.LoadServerKey("voteKey"))
	config := config.Load()
	ballotKey = keys.UnpackKey(config.BallotServer.Key)
}
Example #4
0
func init() {
	ballotPrivateKey = keys.UnpackPrivateKey(config.LoadServerKey("ballotKey"))
	config := config.Load()
	voterListKey = keys.UnpackKey(config.VoterListServer.Key)
}