Documentation
¶
Index ¶
- func CiphervotesToPairs(ciphervotes []Ciphervote) (X [][]kyber.Point, Y [][]kyber.Point)
- func RandomID() (string, error)
- func RegisterCiphervoteFormat(f serde.Format, e serde.FormatEngine)
- func RegisterFormFormat(format serde.Format, engine serde.FormatEngine)
- func RegisterTransactionFormat(f serde.Format, e serde.FormatEngine)
- type Ballot
- type CancelForm
- type CastVote
- type Ciphervote
- type CiphervoteFactory
- type CiphervoteKey
- type CloseForm
- type CombineShares
- type Configuration
- type CreateForm
- type DeleteForm
- type EGPair
- type Form
- type FormFactory
- type FormIDs
- type FormKey
- type FormsMetadata
- type ID
- type OpenForm
- type Pubshare
- type PubsharesUnit
- type PubsharesUnits
- type Question
- type RandomVector
- type Rank
- type RegisterPubShares
- type Select
- type ShuffleBallots
- type ShuffleInstance
- type Status
- type Subject
- type Suffragia
- type Text
- type TransactionFactory
- type TransactionKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CiphervotesToPairs ¶
func CiphervotesToPairs(ciphervotes []Ciphervote) (X [][]kyber.Point, Y [][]kyber.Point)
CiphervotesToPairs converts a slice of ciphervote to X, Y
func RegisterCiphervoteFormat ¶
func RegisterCiphervoteFormat(f serde.Format, e serde.FormatEngine)
RegisterCiphervoteFormat registers the engine for the provided format
func RegisterFormFormat ¶
func RegisterFormFormat(format serde.Format, engine serde.FormatEngine)
RegisterFormFormat registers the engine for the provided format
func RegisterTransactionFormat ¶
func RegisterTransactionFormat(f serde.Format, e serde.FormatEngine)
RegisterTransactionFormat registers the engine for the provided format
Types ¶
type Ballot ¶
type Ballot struct {
// SelectResult contains the result of each Select question. The result of a
// select is a list of boolean that says for each choice if it has been
// selected or not. The ID slice is used to map a question ID to its index
// in the SelectResult slice
SelectResultIDs []ID
SelectResult [][]bool
// RankResult contains the result of each Rank question. The result of a
// rank question is the list of ranks for each choice. A choice that hasn't
// been ranked will have a value < 0. The ID slice is used to map a question
// ID to its index in the RankResult slice
RankResultIDs []ID
RankResult [][]int8
// TextResult contains the result of each Text question. The result of a
// text question is the list of text answer for each choice. The ID slice is
// used to map a question ID to its index in the TextResult slice
TextResultIDs []ID
TextResult [][]string
}
Ballot contains all information about a simple ballot
type CastVote ¶
type CastVote struct {
// FormID is hex-encoded
FormID string
UserID string
Ballot Ciphervote
}
CastVote defines the transaction to cast a vote
- implements serde.Message
type Ciphervote ¶
type Ciphervote []EGPair
Ciphervote represents an encrypted vote. It consists of a list of ElGamal pairs.
- implements serde.Message - implements serde.Fingerprinter
func CiphervotesFromPairs ¶
func CiphervotesFromPairs(X, Y [][]kyber.Point) ([]Ciphervote, error)
CiphervotesFromPairs transforms two parallel lists of EGPoints to a list of Ciphervotes.
func (Ciphervote) Equal ¶
func (c Ciphervote) Equal(other Ciphervote) bool
Equal returns if the other ciphervote is equal
func (Ciphervote) FingerPrint ¶
func (c Ciphervote) FingerPrint(writer io.Writer) error
FingerPrint implements serde.Fingerprinter
func (Ciphervote) GetElGPairs ¶
func (c Ciphervote) GetElGPairs() (ks []kyber.Point, cs []kyber.Point)
GetElGPairs returns corresponding kyber.Points from the ciphertexts
type CiphervoteFactory ¶
type CiphervoteFactory struct{}
CiphervoteFactory provides the mean to deserialize a ciphervote. It naturally uses the formFormat.
- implements serde.Factory
func (CiphervoteFactory) Deserialize ¶
Deserialize implements serde.Factory
type CombineShares ¶
type CombineShares struct {
// FormID is hex-encoded
}
CombineShares defines the transaction to decrypt the ballots by combining all the public shares.
- implements serde.Message
type Configuration ¶
Configuration contains the configuration of a new poll.
func (*Configuration) GetQuestion ¶
func (c *Configuration) GetQuestion(ID ID) Question
GetQuestion finds the question associated to a given ID and returns it. Returns nil if no question found.
func (*Configuration) IsValid ¶
func (c *Configuration) IsValid() bool
IsValid returns true if and only if the whole configuration is coherent and valid.
func (*Configuration) MaxBallotSize ¶
func (c *Configuration) MaxBallotSize() int
MaxBallotSize returns the maximum number of bytes required to store a ballot
type CreateForm ¶
type CreateForm struct {
Configuration Configuration
AdminID string
}
CreateForm defines the transaction to create a form
- implements serde.Message
type DeleteForm ¶
type DeleteForm struct {
// FormID is hex-encoded
FormID string
}
DeleteForm defines the transaction to delete the form
- implements serde.Message
type Form ¶
type Form struct {
Configuration Configuration
// FormID is the hex-encoded SHA256 of the transaction ID that creates
// the form
FormID string
Status Status
Pubkey kyber.Point
// BallotSize represents the total size in bytes of one ballot. It is used
// to pad smaller ballots such that all ballots cast have the same size
BallotSize int
// Suffragia is a map from User ID to their encrypted ballot
Suffragia Suffragia
// ShuffleInstances is all the shuffles, along with their proof and identity
// of shuffler.
ShuffleInstances []ShuffleInstance
// ShuffleThreshold is set based on the roster. We save it so we do not have
// to compute it based on the roster each time we need it.
ShuffleThreshold int
// Each node submits its share to its personal index from the DKG service.
PubsharesUnits PubsharesUnits
DecryptedBallots []Ballot
Roster authority.Authority
}
Form contains all information about a simple form
- implements serde.Message
func (*Form) ChunksPerBallot ¶
ChunksPerBallot returns the number of chunks of El Gamal pairs needed to represent an encrypted ballot, knowing that one chunk is 29 bytes at most.
type FormFactory ¶
type FormFactory struct {
// contains filtered or unexported fields
}
FormFactory provides the mean to deserialize a form. It naturally uses the formFormat.
- implements serde.Factory
func NewFormFactory ¶
func NewFormFactory(cf serde.Factory, rf authority.Factory) FormFactory
NewFormFactory creates a new Form factory
func (FormFactory) Deserialize ¶
Deserialize implements serde.Factory
type FormIDs ¶
type FormIDs []string
FormIDs is a slice of hex-encoded form IDs
type OpenForm ¶
type OpenForm struct {
// FormID is hex-encoded
FormID string
}
OpenForm defines the transaction to open a form
- implements serde.Message
type PubsharesUnit ¶
type PubsharesUnit [][]Pubshare
PubsharesUnit holds all the public shares produced by a given node, 1 for each ElGamal pair
func (PubsharesUnit) Fingerprint ¶
func (p PubsharesUnit) Fingerprint(writer io.Writer) error
Fingerprint implements serde.Fingerprinter
type PubsharesUnits ¶
type PubsharesUnits struct {
Pubshares []PubsharesUnit
// PubsharesUnit
PubKeys [][]byte
// PubsharesUnit
Indexes []int
}
PubsharesUnits contains the pubshares submitted in parallel with the necessary data to identify the nodes who submitted them and their index.
type Question ¶
Question is an offering the primitives all questions should have to verify the validity of an answer on a decrypted ballot.
type RandomVector ¶
type RandomVector [][]byte
RandomVector is a slice of kyber.Scalar (encoded) which is used to prove and verify the proof of a shuffle
func (*RandomVector) LoadFromScalars ¶
func (r *RandomVector) LoadFromScalars(e []kyber.Scalar) error
LoadFromScalars marshals a given vector of scalars into the current RandomVector
type Rank ¶
Rank describes a "rank" question, which requires the user to rank choices. implements Question
func (Rank) GetChoicesLength ¶
GetChoicesLength implements Question
type RegisterPubShares ¶
type RegisterPubShares struct {
Index int
// so that they can be used for decryption.
Pubshares PubsharesUnit
// private key corresponding to PublicKey
Signature []byte
PublicKey []byte
}
RegisterPubShares defines the transaction used by a node to send its pubshares on the chain.
- implements serde.Message
func (RegisterPubShares) Fingerprint ¶
func (rp RegisterPubShares) Fingerprint(writer io.Writer) error
Fingerprint implements serde.Fingerprinter
type Select ¶
Select describes a "select" question, which requires the user to select one or multiple choices. implements Question
func (Select) GetChoicesLength ¶
GetChoicesLength implements Question
type ShuffleBallots ¶
type ShuffleBallots struct {
FormID string
Round int
ShuffledBallots []Ciphervote
// RandomVector is the vector to be used to generate the proof of the next
// shuffle
RandomVector RandomVector
// Proof is the proof corresponding to the shuffle of this transaction
Proof []byte
// Signature is the signature of the result of HashShuffle() with the private
// key corresponding to PublicKey
Signature []byte
//PublicKey is the public key of the signer.
PublicKey []byte
}
ShuffleBallots defines the transaction to shuffle the ballots
- implements serde.Message - implements serde.Fingerprinter
func (ShuffleBallots) Fingerprint ¶
func (sb ShuffleBallots) Fingerprint(writer io.Writer) error
Fingerprint implements serde.Fingerprinter. If creates a fingerprint only based on the formID and the shuffled ballots.
type ShuffleInstance ¶
type ShuffleInstance struct {
// ShuffledBallots contains the list of shuffled ciphertext for this round
ShuffledBallots []Ciphervote
// ShuffleProofs is the proof of the shuffle for this round
ShuffleProofs []byte
// ShufflerPublicKey is the key of the node who made the given shuffle.
ShufflerPublicKey []byte
}
ShuffleInstance is an instance of a shuffle, it contains the shuffled ballots, the proofs and the identity of the shuffler.
type Status ¶
type Status uint16
Status defines the status of the form
const ( // DecryptedBallots = 4 // Initial is when the form has just been created Initial Status = 0 // Open is when the form is open, i.e. it fetched the public key Open Status = 1 // Closed is when no more users can cast ballots Closed Status = 2 // ShuffledBallots is when the ballots have been shuffled ShuffledBallots Status = 3 PubSharesSubmitted Status = 4 // ResultAvailable is when the ballots have been decrypted ResultAvailable Status = 5 // Canceled is when the form has been cancel Canceled Status = 6 )
type Subject ¶
type Subject struct {
ID ID
Title string
// Order defines the order of the different question, which all have a unique
// identifier. This is purely for display purpose.
Order []ID
Subjects []Subject
Selects []Select
Ranks []Rank
Texts []Text
}
Subject is a wrapper around multiple questions that can be of type "select", "rank", or "text".
func (*Subject) GetQuestion ¶
GetQuestion finds the question associated to a given ID and returns it Returns nil if no question found.
func (*Subject) MaxEncodedSize ¶
MaxEncodedSize returns the maximum amount of bytes taken to store the questions in this subject once encoded in a ballot
type Suffragia ¶
type Suffragia struct {
UserIDs []string
Ciphervotes []Ciphervote
}
func (*Suffragia) CastVote ¶
func (s *Suffragia) CastVote(userID string, ciphervote Ciphervote)
CastVote adds a new vote and its associated user or updates a user's vote.
type Text ¶
type Text struct {
ID ID
Title string
MaxN uint
MinN uint
MaxLength uint
Regex string
Choices []string
Hint string
}
Text describes a "text" question, which allows the user to enter free text. implements Question
func (Text) GetChoicesLength ¶
GetChoicesLength implements Question
type TransactionFactory ¶
type TransactionFactory struct {
// contains filtered or unexported fields
}
TransactionFactory provides the mean to deserialize a transaction.
- implements serde.Factory
func NewTransactionFactory ¶
func NewTransactionFactory(cf serde.Factory) TransactionFactory
NewTransactionFactory creates a new transaction factory
func (TransactionFactory) Deserialize ¶
Deserialize implements serde.Factory
type TransactionKey ¶
type TransactionKey struct{}
TransactionKey is the key for the transaction factory