Documentation ¶
Index ¶
- Variables
- func CalculateCommitment(prerequisiteEventContent ...event.Content) (string, error)
- func LogUpload(contentURI id.ContentURI)
- type Candidate
- type CreateElectionContent
- type CreateEvent
- type Election
- func (el *Election) GetHashSeed() string
- func (el *Election) JoinElection(client *mautrix.Client, eventStore *EventStore) error
- func (el *Election) PrintResults()
- func (el *Election) RedactEvents(client *mautrix.Client)
- func (el *Election) SendEvals(client *mautrix.Client, eventStore *EventStore) error
- func (el *Election) SendProvingKeys(client *mautrix.Client, eventStore *EventStore) error
- func (el *Election) SendSum(client *mautrix.Client, eventStore *EventStore) error
- func (el *Election) StartElection(client *mautrix.Client, eventStore *EventStore) error
- func (el *Election) UnmarshalJSON(b []byte) error
- type ElectionsMap
- func (em *ElectionsMap) AddElection(el *Election)
- func (elections *ElectionsMap) CreateElection(client *mautrix.Client, candidates []Candidate, title string, roomID id.RoomID) (*Election, error)
- func (em *ElectionsMap) GetElection(createID id.EventID) *Election
- func (em *ElectionsMap) Save()
- func (em *ElectionsMap) SetEventStore(eventStore *EventStore)
- func (elections *ElectionsMap) SetupEventHooks(client *mautrix.Client, syncer mautrix.ExtensibleSyncer)
- func (em *ElectionsMap) UnmarshalJSON(b []byte) error
- type Eval
- type EvalsEvent
- type EvalsMessageContent
- type EventStore
- func (store *EventStore) GetCreateEvent(roomID id.RoomID, createID id.EventID) *CreateEvent
- func (store *EventStore) GetEvalsEvent(roomID id.RoomID, evalsID id.EventID) *EvalsEvent
- func (store *EventStore) GetJoinEvent(roomID id.RoomID, joinID id.EventID) *JoinEvent
- func (store *EventStore) GetKeysEvent(roomID id.RoomID, keysID id.EventID) *KeysEvent
- func (store *EventStore) GetStartEvent(roomID id.RoomID, startID id.EventID) *StartEvent
- func (store *EventStore) GetSumEvent(roomID id.RoomID, sumID id.EventID) *SumEvent
- func (store *EventStore) UnmarshalJSON(b []byte) error
- type JoinElectionContent
- type JoinEvent
- type KeysEvent
- type KeysMessageContent
- type LocalVoter
- type ProvingKeyFile
- type Room
- type StartElectionContent
- type StartEvent
- type SumEvent
- type SumMessageContent
- type VerifyingKeyFile
- type Voter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // sent when user wants to create an election CreateElectionMessage = event.Type{ Type: "xyz.tallyard.new", Class: event.MessageEventType, } // sent when a user wants to join an election JoinElectionMessage = event.Type{ Type: "xyz.tallyard.join", Class: event.MessageEventType, } // sent when a user wants to start a previously-create election. The // user who sends this message must be the one who created the election StartElectionMessage = event.Type{ Type: "xyz.tallyard.start", Class: event.MessageEventType, } // contains keys needed to do zero knowledge proofs KeysMessage = event.Type{ Type: "xyz.tallyard.keys", Class: event.MessageEventType, } // indicate's user's evaluations of their polynomial using others' inputs EvalsMessage = event.Type{ Type: "xyz.tallyard.evals", Class: event.MessageEventType, } // indicates a user's individual summation SumMessage = event.Type{ Type: "xyz.tallyard.sum", Class: event.MessageEventType, } )
View Source
var SchemaVersionError error = errors.New("the stored elections schema version is incompitable with the latest schema version")
Functions ¶
func CalculateCommitment ¶ added in v0.4.0
func LogUpload ¶ added in v0.4.0
func LogUpload(contentURI id.ContentURI)
Types ¶
type CreateElectionContent ¶
type CreateEvent ¶
type CreateEvent struct { *event.Event *CreateElectionContent }
type Election ¶
type Election struct { sync.RWMutex Candidates []Candidate `json:"candidates"` CreateEvt event.Event `json:"create_evt"` FinalJoinIDs *[]id.EventID `json:"final_voters,omitempty"` Joins map[id.EventID]*Voter `json:"joins"` LocalVoter *LocalVoter `json:"local_voter,omitempty"` Result *[32]byte `json:"result,omitempty"` RoomID id.RoomID `json:"room_id"` StartID *id.EventID `json:"start_id,omitempty"` Title string `json:"title"` // Save election to disk. Set by the containing ElectionsMap at runtime Save func() `json:"-"` // contains filtered or unexported fields }
func NewElection ¶
func (*Election) GetHashSeed ¶ added in v0.4.0
func (*Election) JoinElection ¶
func (el *Election) JoinElection(client *mautrix.Client, eventStore *EventStore) error
func (*Election) PrintResults ¶
func (el *Election) PrintResults()
func (*Election) RedactEvents ¶ added in v0.4.0
func (*Election) SendEvals ¶
func (el *Election) SendEvals(client *mautrix.Client, eventStore *EventStore) error
func (*Election) SendProvingKeys ¶ added in v0.4.0
func (el *Election) SendProvingKeys(client *mautrix.Client, eventStore *EventStore) error
func (*Election) SendSum ¶
func (el *Election) SendSum(client *mautrix.Client, eventStore *EventStore) error
func (*Election) StartElection ¶
func (el *Election) StartElection(client *mautrix.Client, eventStore *EventStore) error
func (*Election) UnmarshalJSON ¶
type ElectionsMap ¶
type ElectionsMap struct { sync.RWMutex // The version of the elections map. If the version in the file doesn't // match the current version then we can give a clear error message // telling the user to update their file to the current version. The // version in the file should only be different if there has been a // breaking change to the elections map format. Version int `json:"version"` // Maps election create event IDs to the corresponding election. Elections map[id.EventID]*Election `json:"elections"` // See EventStore doc for explanation EventStore *EventStore `json:"event_store,omitempty"` // State store NextBatch string `json:"next_batch"` Rooms map[id.RoomID]*Room `json:"rooms"` UserID id.UserID `json:"user_id"` // contains filtered or unexported fields }
func NewElectionsMap ¶ added in v0.4.0
func NewElectionsMap(userID id.UserID, save func(*ElectionsMap)) *ElectionsMap
func UnmarshalElectionsMapFrom ¶ added in v0.4.2
func UnmarshalElectionsMapFrom(jsonBytes []byte, userID id.UserID, save func(*ElectionsMap)) (*ElectionsMap, error)
func (*ElectionsMap) AddElection ¶
func (em *ElectionsMap) AddElection(el *Election)
func (*ElectionsMap) CreateElection ¶
func (*ElectionsMap) GetElection ¶
func (em *ElectionsMap) GetElection(createID id.EventID) *Election
func (*ElectionsMap) Save ¶
func (em *ElectionsMap) Save()
func (*ElectionsMap) SetEventStore ¶
func (em *ElectionsMap) SetEventStore(eventStore *EventStore)
func (*ElectionsMap) SetupEventHooks ¶
func (elections *ElectionsMap) SetupEventHooks(client *mautrix.Client, syncer mautrix.ExtensibleSyncer)
func (*ElectionsMap) UnmarshalJSON ¶
func (em *ElectionsMap) UnmarshalJSON(b []byte) error
type EvalsEvent ¶
type EvalsEvent struct { *event.Event *EvalsMessageContent }
type EvalsMessageContent ¶
type EventStore ¶
type EventStore struct { sync.RWMutex Events map[id.EventID]*event.Event `json:"events"` Client *mautrix.Client `json:"-"` EventHandlers map[event.Type]func(*event.Event) bool `json:"-"` Processing map[id.EventID]<-chan struct{} `json:"-"` }
Used to store all relevant election Events that we've tried processing. A value of nil for a given event ID key in the Events map means that the corresponding event was processed unsuccessfully. Likewise, a non-nil value indicates that the event was processed successfully.
This EventStore also uses the provided Client to fetch missing events and pipe them through the corresponding EventHandlers when needed.
func NewEventStore ¶
func (*EventStore) GetCreateEvent ¶
func (store *EventStore) GetCreateEvent(roomID id.RoomID, createID id.EventID) *CreateEvent
func (*EventStore) GetEvalsEvent ¶
func (store *EventStore) GetEvalsEvent(roomID id.RoomID, evalsID id.EventID) *EvalsEvent
func (*EventStore) GetJoinEvent ¶
func (*EventStore) GetKeysEvent ¶ added in v0.4.0
func (*EventStore) GetStartEvent ¶
func (store *EventStore) GetStartEvent(roomID id.RoomID, startID id.EventID) *StartEvent
func (*EventStore) GetSumEvent ¶
func (*EventStore) UnmarshalJSON ¶
func (store *EventStore) UnmarshalJSON(b []byte) error
type JoinElectionContent ¶
type JoinEvent ¶
type JoinEvent struct { *event.Event *JoinElectionContent }
type KeysEvent ¶ added in v0.4.0
type KeysEvent struct { *event.Event *KeysMessageContent }
type KeysMessageContent ¶ added in v0.4.0
type KeysMessageContent struct { Version string `json:"version"` Commitment string `json:"commitment"` EvalProvingKeyURI id.ContentURI `json:"eval_proving_key_uri"` JoinID id.EventID `json:"join_id"` StartID id.EventID `json:"start_id"` SumProvingKeyURI id.ContentURI `json:"sum_proving_key_uri"` }
type LocalVoter ¶
type LocalVoter struct { *Voter PrivKey [32]byte `json:"priv_key"` EvalVerifyingKey *VerifyingKeyFile `json:"eval_verifying_key,omitempty"` Poly *math.Poly `json:"poly,omitempty"` SumVerifyingKey *VerifyingKeyFile `json:"sum_verifying_key,omitempty"` }
func NewLocalVoter ¶
func NewLocalVoter(voter *Voter, privKey *[32]byte) *LocalVoter
type ProvingKeyFile ¶ added in v0.4.2
type ProvingKeyFile struct { FileID string `json:"file_id"` // contains filtered or unexported fields }
func NewProvingKeyFile ¶ added in v0.4.2
func NewProvingKeyFile(fileID string, pk groth16.ProvingKey) *ProvingKeyFile
func (*ProvingKeyFile) Pk ¶ added in v0.4.2
func (provingKey *ProvingKeyFile) Pk() groth16.ProvingKey
type Room ¶ added in v0.4.0
func (*Room) GetElections ¶ added in v0.4.0
func (*Room) HasElections ¶ added in v0.4.0
type StartElectionContent ¶
type StartEvent ¶
type StartEvent struct { *event.Event *StartElectionContent }
type SumEvent ¶
type SumEvent struct { *event.Event *SumMessageContent }
type SumMessageContent ¶
type VerifyingKeyFile ¶ added in v0.4.2
type VerifyingKeyFile struct { FileID string `json:"file_id"` // contains filtered or unexported fields }
func NewVerifyingKeyFile ¶ added in v0.4.2
func NewVerifyingKeyFile(vk groth16.VerifyingKey) *VerifyingKeyFile
func (*VerifyingKeyFile) Vk ¶ added in v0.4.2
func (verifyingKey *VerifyingKeyFile) Vk() groth16.VerifyingKey
type Voter ¶
type Voter struct { Input fr.Element `json:"input"` JoinEvt event.Event `json:"join_evt"` PubKey [32]byte `json:"pub_key"` SeedPart []byte `json:"seed_part"` JoinIDIndex *uint `json:"join_id_index,omitempty"` Output *fr.Element `json:"output,omitempty"` OutputHashes *[][]byte `json:"output_hashes,omitempty"` KeysID *id.EventID `json:"keys_id,omitempty"` EvalsID *id.EventID `json:"evals_id,omitempty"` Sum *fr.Element `json:"sum,omitempty"` SumID *id.EventID `json:"sum_id,omitempty"` EvalProvingKey *ProvingKeyFile `json:"eval_proving_key,omitempty"` SumProvingKey *ProvingKeyFile `json:"sum_proving_key,omitempty"` }
Click to show internal directories.
Click to hide internal directories.