voting

package
v0.0.0-...-405ef9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 4 Imported by: 0

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

func SendVote(v *Vote) error

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

func VerifyVote(v *Vote) bool

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) GetImage

func (c *Candidate) GetImage() string

GetImage is a method that returns the image of the candidate

func (*Candidate) GetName

func (c *Candidate) GetName() string

GetName is a method that returns the name of the candidate

func (*Candidate) GetParty

func (c *Candidate) GetParty() string

GetParty is a method that returns the party of the candidate

func (*Candidate) GetProgram

func (c *Candidate) GetProgram() string

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

func (v *Voter) GetCandidate() string

GetCandidate is a method that returns the candidate that the voter voted for

func (*Voter) GetSignature

func (v *Voter) GetSignature() []byte

GetSignature is a method that returns the signature of the vote

func (*Voter) GetToken

func (v *Voter) GetToken() ed25519.PublicKey

GetToken is a method that returns the token of the voter

func (*Voter) VerifyVote

func (v *Voter) VerifyVote() bool

VerifyVote is a method that verifies if the vote is valid by checking the signature with the token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL