Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register() (ed25519.PublicKey, ed25519.PrivateKey, error)
Register is a function that registers a new voter by generating and returning an ed25519 key pair
func SendVote ¶
SendVote is a function that sends a vote to the blockchain network and waits for it to be packed into a new block
func SignVote ¶
func SignVote(v *Vote, privateKey *ed25519.PrivateKey) (string, error)
SignVote is a function that signs a vote using ed25519 algorithm and private key
func VerifyVote ¶
VerifyVote is a function that verifies if a vote has been correctly recorded on the blockchain and matches with your intention
Types ¶
type Candidate ¶
type Candidate struct { Name string // The name of the candidate Party string // The party of the candidate Program string // The program of the candidate Image string // The image of the candidate }
Candidate is a struct that represents a candidate in the voting system
func (*Candidate) GetProgram ¶
GetProgram is a method that returns the program of the candidate
type Vote ¶
type Vote struct { Token string // The token of the voter, which is generated by ed25519 public key Candidate string // The name of the candidate that the voter wants to vote for Signature string // The signature of the vote, which is generated by ed25519 private key }
Vote is a struct that represents a vote in the voting system
type Voter ¶
type Voter struct { Token ed25519.PublicKey // The token of the voter Candidate string // The candidate that the voter voted for Signature []byte // The signature of the vote }
Voter is a struct that represents a voter in the voting system
func (*Voter) GetCandidate ¶
GetCandidate is a method that returns the candidate that the voter voted for
func (*Voter) GetSignature ¶
GetSignature is a method that returns the signature of the vote
func (*Voter) VerifyVote ¶
VerifyVote is a method that verifies if the vote is valid by checking the signature with the token