Пример #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)
}
Пример #2
0
// Does not check keySignature
func ValidateSignatureRequest(m *msgs.SignatureRequest) error {
	newBlindedBallot := m.BlindedBallot
	newSig := m.VoterSignature
	key := keys.UnpackKey(m.VoterPublicKey)
	if !sign.CheckSig(key, newBlindedBallot, newSig) {
		return fmt.Errorf("SignatureRequest's VoterSignature Signature is invalid")
	}
	return nil
}
Пример #3
0
func CheckKeySig(privateInfo *msgs.VoterData) SignatureStatus {
	if privateInfo.KeySignature == nil {
		return Missing
	}
	config := config.Unpack(privateInfo.ElectionConfig)
	voterListKey := keys.UnpackKey(config.VoterListServer.Key)
	publicKey := PublicKey(privateInfo)
	if sign.CheckSig(voterListKey, publicKey, privateInfo.KeySignature) {
		return Valid
	}
	return Invalid
}
Пример #4
0
func init() {
	votePrivateKey = keys.UnpackPrivateKey(config.LoadServerKey("voteKey"))
	config := config.Load()
	ballotKey = keys.UnpackKey(config.BallotServer.Key)
}
Пример #5
0
func init() {
	ballotPrivateKey = keys.UnpackPrivateKey(config.LoadServerKey("ballotKey"))
	config := config.Load()
	voterListKey = keys.UnpackKey(config.VoterListServer.Key)
}