voter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const HASH_NO = "85131057757245807317576516368191972321038229705283732634690444270750521936266"
View Source
const HASH_YES = "43379584054787486383572605962602545002668015983485933488536749112829893476306"
View Source
const TREE_LEVEL uint8 = 10

Variables

This section is empty.

Functions

func Verify

func Verify(vkString string, proof *goSnarkVerifier.CircomProof, publicSignal []string) bool

Verify : verify proof

func VerifyByFile

func VerifyByFile(vkPath string, pfPath string) bool

VerifyByFile : verify proof

Types

type IdentityPool

type IdentityPool struct {
	// contains filtered or unexported fields
}

IdentityPool ...

func NewIdentityPool

func NewIdentityPool() (*IdentityPool, error)

NewIdentityPool ...

func NewIdentityPoolWithTreeLevel

func NewIdentityPoolWithTreeLevel(treeLevel uint8) (*IdentityPool, error)

NewIdentityPoolWithTreeLevel ...

func (*IdentityPool) GetAllIds

func (i *IdentityPool) GetAllIds() []*IdPathElement

GetAllIds .

func (*IdentityPool) GetIdentityTreePath

func (i *IdentityPool) GetIdentityTreePath(value *IdPathElement) ([]*IdPathElement, []int, *IdPathElement)

GetIdentityTreePath .

func (*IdentityPool) GetIndex

func (i *IdentityPool) GetIndex(value *IdPathElement) int

GetIndex .

func (*IdentityPool) HasRegistered

func (i *IdentityPool) HasRegistered(idc *IdPathElement) bool

HasRegistered .

func (*IdentityPool) InsertIdc

func (i *IdentityPool) InsertIdc(idCommitment *IdPathElement) (int, error)

InsertIdc : register id

func (*IdentityPool) IsMember

func (i *IdentityPool) IsMember(root *IdPathElement) bool

IsMember : check if the merkle root is in the root list or not

func (*IdentityPool) OverwriteIdElements

func (i *IdentityPool) OverwriteIdElements(commitmentSet []*IdPathElement) (int, error)

OverwriteIds . return total len and error

func (*IdentityPool) Update

func (i *IdentityPool) Update(index uint, oldIDCommitment, newIDCommitment *IdPathElement) error

Update : update id

type Proposal

type Proposal struct {
	// contains filtered or unexported fields
}

Proposal ... TODO: Rename

func NewProposal

func NewProposal() (*Proposal, error)

NewProposal ...

func (*Proposal) Close

func (p *Proposal) Close(idx int)

Close : close a proposal which means can't vote anymore

func (*Proposal) GetBallots

func (p *Proposal) GetBallots() ba.Map

func (*Proposal) GetCurrentIdex

func (p *Proposal) GetCurrentIdex() int

GetCurrentIdex : get current index of whole questions

func (*Proposal) GetVotes

func (p *Proposal) GetVotes(idx int) (yes, no int)

GetVotes : get total votes

func (*Proposal) HasProposal

func (p *Proposal) HasProposal(q string) int

HasProposal : check proposal exists or not return : -1, not exists, proposal index otherwise

func (*Proposal) HasProposalByHash

func (p *Proposal) HasProposalByHash(hash *big.Int) int

HasProposalByHash : check proposal exists or not return : -1, not exists, proposal index otherwise

func (*Proposal) InsertBallot

func (p *Proposal) InsertBallot(ballot *ba.Ballot) error

InsertBallot ...

func (*Proposal) ProposeSubject

func (p *Proposal) ProposeSubject(subHash subject.HashHex) int

Propose : propose the hash of a question

func (*Proposal) Remove

func (p *Proposal) Remove(idx int)

Remove : remove a proposal from the list

func (*Proposal) VoteWithProof

func (p *Proposal) VoteWithProof(ballot *ba.Ballot, vkString string) error

VoteWithProof : vote with zk proof

type Voter

type Voter struct {
	*IdentityPool
	*Proposal

	*localContext.Context
	// contains filtered or unexported fields
}

Voter .

func NewVoter

func NewVoter(
	subject *subject.Subject,
	ps *pubsub.PubSub,
	lc *localContext.Context,
	verificationKey string,
) (*Voter, error)

NewVoter ...

func (*Voter) GetAllIdentities

func (v *Voter) GetAllIdentities() []id.Identity

GetAllIdentities .

func (*Voter) GetBallotMap

func (v *Voter) GetBallotMap() ba.Map

GetBallotMap ...

func (*Voter) GetIdentityIndex

func (v *Voter) GetIdentityIndex(identity id.Identity) int

GetIdentityIndex .

func (*Voter) GetIdentityPath

func (v *Voter) GetIdentityPath(identity id.Identity) ([]*id.IdPathElement, []int, *id.IdPathElement, error)

GetIdentityPath .

func (*Voter) GetIdentitySub

func (v *Voter) GetIdentitySub() *pubsub.Subscription

GetIdentitySub ...

func (*Voter) GetSubject

func (v *Voter) GetSubject() *subject.Subject

GetSubject .

func (*Voter) GetVoteSub

func (v *Voter) GetVoteSub() *pubsub.Subscription

GetVoteSub ...

func (*Voter) InsertIdentity

func (v *Voter) InsertIdentity(identity *id.Identity) (int, error)

InsertIdentity .

func (*Voter) Join

func (v *Voter) Join(identity *id.Identity) error

Join .

func (*Voter) Open

func (v *Voter) Open() (yes, no int)

Open .

func (*Voter) OverwriteIds

func (v *Voter) OverwriteIds(identities []*id.Identity) (int, error)

OverwriteIds .

func (*Voter) Propose

func (v *Voter) Propose() int

Propose .

func (*Voter) Vote

func (v *Voter) Vote(ballot *ba.Ballot, silent bool) error

Proposal

Vote .

Jump to

Keyboard shortcuts

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