Documentation ¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func ValidateType(t string) string
- type AdminTx
- type CancelProcessTx
- type CensusDump
- type Connection
- type DataStore
- type GenesisAppState
- type Key
- type Message
- type MessageContext
- type MetaRequest
- type MetaResponse
- type NewProcessTx
- type Process
- type QueryData
- type RequestMessage
- type ResponseMessage
- type ScrutinizerOnProcessData
- type Tx
- type Vote
- type VotePackage
- type VotePackageStruct
- type VoteProof
- type VoteTx
Constants ¶
const ( ProcessIDsize = 32 // size of eth addr EntityIDsize = 20 // legacy: in the past we used hash(addr) // this is a temporal work around to support both EntityIDsizeV2 = 32 VoteNullifierSize = 32 KeyIndexSeparator = ":" EthereumConfirmationsThreshold = 6 EntityResolverDomain = "entity-resolver.vocdoni.eth" EntityMetaKey = "vnd.vocdoni.meta" EthereumReadTimeout = 1 * time.Minute EthereumWriteTimeout = 1 * time.Minute // ScrutinizerLiveProcessPrefix is used for sotring temporary results on live ScrutinizerLiveProcessPrefix = "p_" // ScrutinizerEntityPrefix is the prefix for the storage entity keys ScrutinizerEntityPrefix = "e_" // ScrutinizerEntityProcessSeparator char for spliting process ID's in the scrutinizer entities ScrutinizerEntityProcessSeparator = "_" // ScrutinizerResultsPrefix is the prefix of the storage results summary keys ScrutinizerResultsPrefix = "r_" // ScrutinizerProcessEndingPrefix is the prefix for keep track of the processes ending on a specific block ScrutinizerProcessEndingPrefix = "s_" // PetitionSign contains the string that needs to match with the received vote type for petition-sign PetitionSign = "petition-sign" // PollVote contains the string that needs to match with the received vote type for poll-vote PollVote = "poll-vote" // EncryptedPoll contains the string that needs to match with the received vote type for encrypted-poll EncryptedPoll = "encrypted-poll" // SnarkVote contains the string that needs to match with the received vote type for snark-vote SnarkVote = "snark-vote" // List of transation names TxVote = "vote" TxNewProcess = "newProcess" TxCancelProcess = "cancelProcess" TxAddValidator = "addValidator" TxRemoveValidator = "removeValidator" TxAddOracle = "addOracle" TxRemoveOracle = "removeOracle" TxAddProcessKeys = "addProcessKeys" TxRevealProcessKeys = "revealProcessKeys" // MaxKeyIndex is the maxim number of allowed Encryption or Commitment keys MaxKeyIndex = 16 )
Variables ¶
var ( False = Bool(false) True = Bool(true) )
These exported variables should be treated as constants, to be used in API responses which require *bool fields.
var ProcessIsEncrypted = map[string]bool{ PollVote: false, PetitionSign: false, EncryptedPoll: true, SnarkVote: true, }
var ProcessRequireKeys = map[string]bool{ PollVote: false, PetitionSign: false, EncryptedPoll: true, SnarkVote: true, }
var ValidTypes = map[string]string{
TxVote: "VoteTx",
TxNewProcess: "NewProcessTx",
TxCancelProcess: "CancelProcessTx",
TxAddValidator: "AdminTx",
TxRemoveValidator: "AdminTx",
TxAddOracle: "AdminTx",
TxRemoveOracle: "AdminTx",
TxAddProcessKeys: "AdminTx",
TxRevealProcessKeys: "AdminTx",
}
ValidTypes represents an allowed specific tx type
Functions ¶
func ValidateType ¶
ValidateType a valid Tx type specified in ValidTypes. Returns empty string if invalid type.
Types ¶
type AdminTx ¶
type AdminTx struct { Address string `json:"address"` CommitmentKey string `json:"commitmentKey,omitempty"` EncryptionPrivateKey string `json:"encryptionPrivateKey,omitempty"` EncryptionPublicKey string `json:"encryptionPublicKey,omitempty"` KeyIndex int `json:"keyIndex,omitempty"` Nonce string `json:"nonce"` Power int64 `json:"power,omitempty"` ProcessID string `json:"processId,omitempty"` PubKey string `json:"publicKey,omitempty"` RevealKey string `json:"revealKey,omitempty"` Signature string `json:"signature,omitempty"` Type string `json:"type"` // addValidator, removeValidator, addOracle, removeOracle }
AdminTx represents a Tx that can be only executed by some authorized addresses
type CancelProcessTx ¶
type CancelProcessTx struct { // EntityID the process belongs to ProcessID string `json:"processId"` Signature string `json:"signature,omitempty"` Type string `json:"type,omitempty"` }
CancelProcessTx represents a tx for canceling a valid process
func (*CancelProcessTx) TxType ¶ added in v0.3.0
func (tx *CancelProcessTx) TxType() string
type CensusDump ¶
type Connection ¶
type Connection struct { Topic string // channel/topic for topic based messaging such as PubSub Encryption string // what type of encryption to use TransportKey string // transport layer key for encrypting messages Key string // this node's key Address string // this node's address Path string // specific path on which a transport should listen SSLDomain string // ssl domain SSLCertDir string // ssl certificates directory Port int // specific port on which a transport should listen }
Connection describes the settings for any of the transports defined in the net module, note that not all fields are used for all transport types.
type GenesisAppState ¶
type GenesisAppState struct { Validators []tmtypes.GenesisValidator `json:"validators"` Oracles []string `json:"oracles"` }
GenesisAppState application state in genesis
type Message ¶
type Message struct { Data []byte TimeStamp int32 Namespace string Context MessageContext }
Message is a wrapper for messages from various net transport modules
type MessageContext ¶
type MetaRequest ¶
type MetaRequest struct { CensusID string `json:"censusId,omitempty"` CensusURI string `json:"censusUri,omitempty"` ClaimData string `json:"claimData,omitempty"` ClaimsData []string `json:"claimsData,omitempty"` Content string `json:"content,omitempty"` Digested bool `json:"digested,omitempty"` EntityId string `json:"entityId,omitempty"` From int64 `json:"from,omitempty"` FromID string `json:"fromId,omitempty"` ListSize int64 `json:"listSize,omitempty"` Method string `json:"method"` Name string `json:"name,omitempty"` Nullifier string `json:"nullifier,omitempty"` Payload *VoteTx `json:"payload,omitempty"` ProcessID string `json:"processId,omitempty"` ProofData string `json:"proofData,omitempty"` PubKeys []string `json:"pubKeys,omitempty"` RawTx string `json:"rawTx,omitempty"` RootHash string `json:"rootHash,omitempty"` Signature string `json:"signature,omitempty"` Timestamp int32 `json:"timestamp"` Type string `json:"type,omitempty"` URI string `json:"uri,omitempty"` }
MetaRequest contains all of the possible request fields. Fields must be in alphabetical order
type MetaResponse ¶
type MetaResponse struct { APIList []string `json:"apiList,omitempty"` BlockTime *[5]int32 `json:"blockTime,omitempty"` BlockTimestamp int32 `json:"blockTimestamp,omitempty"` CensusID string `json:"censusId,omitempty"` CensusList []string `json:"censusList,omitempty"` ClaimsData []string `json:"claimsData,omitempty"` CommitmentKeys []Key `json:"commitmentKeys,omitempty"` Content string `json:"content,omitempty"` EncryptionPrivKeys []Key `json:"encryptionPrivKeys,omitempty"` EncryptionPublicKeys []Key `json:"encryptionPubKeys,omitempty"` EntityID string `json:"entityId,omitempty"` EntityIDs []string `json:"entityIds,omitempty"` Files []byte `json:"files,omitempty"` Finished *bool `json:"finished,omitempty"` Health int32 `json:"health,omitempty"` Height *int64 `json:"height,omitempty"` InvalidClaims []int `json:"invalidClaims,omitempty"` Message string `json:"message,omitempty"` Nullifier string `json:"nullifier,omitempty"` Nullifiers *[]string `json:"nullifiers,omitempty"` Ok bool `json:"ok"` Paused *bool `json:"paused,omitempty"` Payload string `json:"payload,omitempty"` ProcessIDs []string `json:"processIds,omitempty"` ProcessList []string `json:"processList,omitempty"` Registered *bool `json:"registered,omitempty"` Request string `json:"request"` Results [][]uint32 `json:"results,omitempty"` RevealKeys []Key `json:"revealKeys,omitempty"` Root string `json:"root,omitempty"` Siblings string `json:"siblings,omitempty"` Size *int64 `json:"size,omitempty"` State string `json:"state,omitempty"` Timestamp int32 `json:"timestamp"` Type string `json:"type,omitempty"` URI string `json:"uri,omitempty"` ValidProof *bool `json:"validProof,omitempty"` }
MetaResponse contains all of the possible request fields. Fields must be in alphabetical order Those fields with valid zero-values (such as bool) must be pointers
func (*MetaResponse) SetError ¶
func (r *MetaResponse) SetError(v interface{})
SetError sets the MetaResponse's Ok field to false, and Message to a string representation of v. Usually, v's type will be error or string.
type NewProcessTx ¶
type NewProcessTx struct { // EntityID the process belongs to EntityID string `json:"entityId"` // MkRoot merkle root of all the census in the process MkRoot string `json:"mkRoot,omitempty"` // MkURI merkle tree URI MkURI string `json:"mkURI,omitempty"` // NumberOfBlocks represents the tendermint block where the process goes from active to finished NumberOfBlocks int64 `json:"numberOfBlocks"` ProcessID string `json:"processId"` ProcessType string `json:"processType"` Signature string `json:"signature,omitempty"` // StartBlock represents the tendermint block where the process goes from scheduled to active StartBlock int64 `json:"startBlock"` Type string `json:"type,omitempty"` }
NewProcessTx represents the info required for starting a new process
func (*NewProcessTx) TxType ¶ added in v0.3.0
func (tx *NewProcessTx) TxType() string
type Process ¶
type Process struct { // Canceled if true process is canceled Canceled bool `json:"canceled,omitempty"` // CommitmentKeys are the reveal keys hashed CommitmentKeys []string `json:"commitmentKeys,omitempty"` // EncryptionPrivateKeys are the keys required to decrypt the votes EncryptionPrivateKeys []string `json:"encryptionPrivateKeys,omitempty"` // EncryptionPublicKeys are the keys required to encrypt the votes EncryptionPublicKeys []string `json:"encryptionPublicKeys,omitempty"` // EntityID identifies unequivocally a process EntityID string `json:"entityId,omitempty"` // KeyIndex KeyIndex int `json:"keyIndex,omitempty"` // MkRoot merkle root of all the census in the process MkRoot string `json:"mkRoot,omitempty"` // NumberOfBlocks represents the amount of tendermint blocks that the process will last NumberOfBlocks int64 `json:"numberOfBlocks,omitempty"` // Paused if true process is paused and cannot add or modify any vote Paused bool `json:"paused,omitempty"` // RevealKeys are the seed of the CommitmentKeys RevealKeys []string `json:"revealKeys,omitempty"` // StartBlock represents the tendermint block where the process goes from scheduled to active StartBlock int64 `json:"startBlock,omitempty"` // Type represents the process type Type string `json:"type,omitempty"` }
Process represents a state per process
func (*Process) IsEncrypted ¶ added in v0.3.0
IsEncrypted indicates wheter a process has an encrypted payload or not
func (*Process) RequireKeys ¶ added in v0.3.0
RequireKeys indicates wheter a process require Encryption or Commitment keys
type QueryData ¶
type QueryData struct { Method string `json:"method"` ProcessID string `json:"processId,omitempty"` Nullifier string `json:"nullifier,omitempty"` From int64 `json:"from,omitempty"` ListSize int64 `json:"listSize,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` ProcessType string `json:"type,omitempty"` }
QueryData is an abstraction of any kind of data a query request could have
type RequestMessage ¶
type RequestMessage struct { MetaRequest json.RawMessage `json:"request"` ID string `json:"id"` Signature string `json:"signature"` }
MessageRequest holds a decoded request but does not decode the body
type ResponseMessage ¶
type ResponseMessage struct { MetaResponse json.RawMessage `json:"response"` ID string `json:"id"` Signature string `json:"signature"` }
ResponseMessage wraps an api response
type ScrutinizerOnProcessData ¶ added in v0.3.0
ScrutinizerOnProcessData holds the required data for callbacks when a new process is added into the vochain.
type Tx ¶
type Tx struct {
Type string `json:"type"`
}
Tx is an abstraction for any specific tx which is primarly defined by its type For now we have 3 tx types {voteTx, newProcessTx, adminTx}
type Vote ¶
type Vote struct { EncryptionKeyIndexes []int `json:"encryptionKeyIndexes,omitempty"` // Height the Terndemint block number where the vote is added Height int64 `json:"height,omitempty"` // Nullifier is the unique identifier of the vote Nullifier string `json:"nullifier,omitempty"` // ProcessID contains the unique voting process identifier ProcessID string `json:"processId,omitempty"` // VotePackage base64 encoded vote content VotePackage string `json:"votePackage,omitempty"` }
Vote represents a single Vote
type VotePackage ¶
VotePackage represents the payload of a vote (usually base64 encoded)
type VotePackageStruct ¶ added in v0.3.0
type VotePackageStruct struct { // Nonce vote nonce Nonce string `json:"nonce"` // Type vote type Type string `json:"type"` // Votes directly mapped to the `questions` field of the process metadata Votes []int `json:"votes"` }
VotePackageStruct represents a vote package
type VoteProof ¶ added in v0.5.0
type VoteProof struct { Proof string `json:"proof,omitempty"` PubKey string `json:"pubKey,omitempty"` PubKeyDigest []byte `json:"pubKeyDigest,omitempty"` Nullifier string `json:"nullifier,omitempty"` Created time.Time `json:"timestamp"` }
VoteProof contains the proof indicating that the user is in the census of the process
type VoteTx ¶
type VoteTx struct { EncryptionKeyIndexes []int `json:"encryptionKeyIndexes,omitempty"` Nonce string `json:"nonce,omitempty"` Nullifier string `json:"nullifier,omitempty"` ProcessID string `json:"processId"` Proof string `json:"proof,omitempty"` Signature string `json:"signature,omitempty"` Type string `json:"type,omitempty"` VotePackage string `json:"votePackage,omitempty"` }
VoteTx represents the info required for submmiting a vote