Example #1
0
func HandelSignatureRequest(data []byte, c net.Conn) {
	var r msgs.SignatureRequest
	err := proto.Unmarshal(data, &r)
	if err != nil {
		fmt.Println("server error reading SignatureRequest:", err)
		server.ConnectionError(c)
		return
	}

	err = msg.ValidateSignatureRequest(&r)
	if err != nil {
		fmt.Println(err)
		return
	}

	keyString := keys.StringKey(r.VoterPublicKey)

	if !sign.CheckSig(voterListKey, []byte(keyString), r.KeySignature) {
		fmt.Println("SignatureRequest's KeySignature Signature is invalid")
		server.ConnectionError(c)
		return
	}

	responseData := getResponse(keyString, &r)

	server.SendBlock(msg.SignatureResponse, responseData, c)
}
Example #2
0
func PublicKey(privateInfo *msgs.VoterData) []byte {
	return []byte(keys.StringKey(privateInfo.Key.PublicKey))
}