-
Notifications
You must be signed in to change notification settings - Fork 5
/
vochain.proto
493 lines (440 loc) · 12 KB
/
vochain.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
syntax = "proto3";
package dvote.types.v1;
option go_package = "go.vocdoni.io/proto/build/go/models";
message VoteEnvelope {
// Unique number per vote attempt, so that replay attacks can't reuse this payload
bytes nonce = 1;
// The process for which the vote is casted
bytes processId = 2;
// Franchise proof
Proof proof = 3;
// JSON string of the Vote Package (potentially encrypted), encoded as bytes.
bytes votePackage = 4;
// Hash of the private key + processId
bytes nullifier = 5;
// On encrypted votes, contains the (sorted) indexes of the keys used to encrypt
repeated uint32 encryptionKeyIndexes = 6;
}
message Census {
enum Type {
UNKNOWN = 0;
ARBO_BLAKE2B = 1;
ARBO_POSEIDON = 2;
ETHEREUMSTORAGE = 3;
ETHEREUMACCOUNT = 4;
CA = 5;
GRAVITON = 1001;
IDEN3 = 1002;
}
}
message Proof {
oneof payload {
// Proof used for signed envelopes
ProofGraviton graviton = 1;
// Proof used for anonymous votes
ProofIden3 iden3 = 2;
// Proof used on EVM census based processes
ProofEthereumStorage ethereumStorage = 3;
// Proof used by oracles to update the census of EVM processes
ProofEthereumAccount ethereumAccount = 4;
// Proof Certification Authority
ProofCA ca = 5;
// Proof used for census using arbo
ProofArbo arbo = 6;
// zkSnark proof
ProofZkSNARK zkSnark = 7;
// Proof used in Minime token based census
ProofMinime minimeStorage = 8;
}
}
message ProofGraviton {
bytes siblings = 1;
}
message ProofIden3 {
bytes siblings = 1;
}
message ProofEthereumStorage {
bytes key = 1;
bytes value = 2;
repeated bytes siblings = 3;
}
message ProofEthereumAccount {
bytes nonce = 1;
bytes balance = 2; // Big Int encoded as bytes
bytes storageHash = 3;
bytes codeHash = 4;
repeated bytes siblings = 5;
}
message ProofMinime {
ProofEthereumStorage proofPrevBlock = 1;
ProofEthereumStorage proofNextBlock = 2;
}
message ProofCA {
enum Type {
UNKNOWN = 0;
ECDSA = 1;
ECDSA_PIDSALTED = 2;
ECDSA_BLIND = 3;
ECDSA_BLIND_PIDSALTED = 4;
}
Type type = 1;
CAbundle bundle = 2;
bytes signature = 3;
}
message CAbundle {
bytes processId = 1;
bytes address = 2;
}
message ProofArbo {
enum Type {
BLAKE2B = 0;
POSEIDON = 1;
}
enum KeyType {
PUBKEY = 0;
ADDRESS = 1;
}
Type type = 1;
bytes siblings = 2;
bytes availableWeight = 3;
KeyType keyType = 4;
bytes voteWeight = 5;
}
// Groth16 zkSNARK proof + public inputs
message ProofZkSNARK {
// circuitParametersIndex defines the index of the parameter set of the
// circuit. Each process has defined a set of available parameters for
// the same circuit, the 'parametersIndex' defines the index of the set
// for which the ProofZkSNARK belongs for the circuit used in that
// process.
int32 circuitParametersIndex = 1;
// a represents a G1 point in Affine coordinates
repeated string a = 2;
// b represents a G2 point in Affine coordinates, represented by an
// array of arrays: []string => [2][2]bigint).
// [w, x, y, z] => [[w, x], [y, z]]
repeated string b = 3;
// c represents a G1 point in Affine coordinates
repeated string c = 4;
repeated string publicInputs = 5;
}
// Account represents an entity with an amount of tokens, usually attached to an address.
message Account {
uint64 balance = 1;
uint32 nonce = 2;
string infoURI = 3;
repeated bytes delegateAddrs = 4;
uint32 processIndex = 5;
}
message Treasurer {
bytes address = 1;
uint32 nonce = 2;
}
enum TxType {
TX_UNKNOWN = 0;
NEW_PROCESS = 1;
SET_PROCESS_STATUS = 2;
SET_PROCESS_CENSUS = 3;
SET_PROCESS_QUESTION_INDEX = 4;
ADD_PROCESS_KEYS = 5;
REVEAL_PROCESS_KEYS = 6;
ADD_ORACLE = 7;
REMOVE_ORACLE = 8;
ADD_VALIDATOR = 9;
REMOVE_VALIDATOR = 10;
VOTE = 11;
SET_PROCESS_RESULTS = 12;
REGISTER_VOTER_KEY = 13;
MINT_TOKENS = 14;
SEND_TOKENS = 15;
SET_TRANSACTION_COSTS = 16;
SET_ACCOUNT_INFO_URI = 17;
ADD_DELEGATE_FOR_ACCOUNT = 18;
DEL_DELEGATE_FOR_ACCOUNT = 19;
COLLECT_FAUCET = 20;
ADD_KEYKEEPER = 21;
DELETE_KEYKEEPER = 22;
CREATE_ACCOUNT = 23;
SET_ACCOUNT_SIK = 24;
DEL_ACCOUNT_SIK = 25;
REGISTER_SIK = 26;
}
message Tx {
oneof payload {
VoteEnvelope vote = 1;
NewProcessTx newProcess = 2;
AdminTx admin = 3;
SetProcessTx setProcess = 4;
RegisterKeyTx registerKey = 5;
MintTokensTx mintTokens = 6;
SendTokensTx sendTokens = 7;
SetTransactionCostsTx setTransactionCosts = 8;
SetAccountTx setAccount = 9;
CollectFaucetTx collectFaucet = 10;
SetKeykeeperTx setKeykeeper = 11;
SIKTx setSIK = 12;
SIKTx delSIK = 13;
RegisterSIKTx registerSIK = 14;
}
}
message SignedTx {
// The bytes produced by Marshaling a Tx{} message
bytes tx = 1;
// The signature for the tx bytes.
// signature is only required in those transactions that actually need signature.
// I.e zk-Snarks based transactions won't needed, however the transaction should use
// this message type in order to preserve consistency on the Vochain
optional bytes signature = 2;
}
message NewProcessTx {
TxType txtype = 1;
uint32 nonce = 2;
Process process = 3;
}
message SetProcessTx {
TxType txtype = 1;
uint32 nonce = 2;
bytes processId = 3;
optional ProcessStatus status = 4;
optional uint32 questionIndex = 5;
optional bytes censusRoot = 6;
optional string censusURI = 7;
optional Proof proof = 8;
optional ProcessResult results = 9;
// tempSIKs flag decides if when the process has finished, the SIKs related
// to it will be removed or not
optional bool tempSIKs = 10;
}
message AdminTx {
TxType txtype = 1;
bytes processId = 2;
optional bytes address = 3;
optional bytes encryptionPrivateKey = 5;
optional bytes encryptionPublicKey = 6;
optional uint32 keyIndex = 7;
optional uint64 power = 8;
optional bytes publicKey = 9;
uint32 nonce = 11;
}
message RegisterKeyTx {
uint32 nonce = 1; // Unique number per vote attempt, so that replay attacks can't reuse this payload
bytes processId = 2; // The process for which the vote is casted
Proof proof = 3; // Franchise proof
bytes newKey = 4; // New key to register
string weight = 5; // Weight to delegate to newKey
}
message MintTokensTx {
TxType txtype = 1;
uint32 nonce = 2;
bytes to = 3;
uint64 value = 4;
}
message SendTokensTx {
TxType txtype = 1;
uint32 nonce = 2;
bytes from = 3;
bytes to = 4;
uint64 value = 5;
}
message SetTransactionCostsTx {
TxType txtype = 1;
uint32 nonce = 2;
uint64 value = 3;
}
message SetAccountTx {
TxType txtype = 1;
optional uint32 nonce = 2;
optional string infoURI = 3;
optional bytes account = 4;
optional FaucetPackage faucetPackage = 5;
repeated bytes delegates = 6;
optional bytes SIK = 7;
}
message SIKTx {
TxType txtype = 1;
optional bytes SIK = 3;
}
message RegisterSIKTx {
bytes electionId = 1;
Proof censusProof = 2;
bytes SIK = 3;
}
message CollectFaucetTx {
TxType txType = 1;
FaucetPackage faucetPackage = 2;
uint32 nonce = 3;
}
message FaucetPayload {
uint64 identifier = 1;
bytes to = 2;
uint64 amount = 3;
}
message FaucetPackage {
bytes payload = 1;
bytes signature = 2;
}
message SetKeykeeperTx {
TxType txtype = 1;
uint32 nonce = 2;
bytes keykeeper = 3;
}
message Process {
bytes processId = 1;
// EntityId identifies unequivocally an entity
bytes entityId = 2;
// StartBlock represents the tendermint block where the process goes from scheduled to active
uint32 startBlock = 3;
// BlockCount represents the amount of tendermint blocks that the process will last
uint32 blockCount = 4;
// CensusRoot merkle root of all the census in the process
bytes censusRoot = 5;
// CensusURI where to find the census
optional string censusURI = 6;
// EncryptionPrivateKeys are the keys required to decrypt the votes
repeated string encryptionPrivateKeys = 8;
// EncryptionPublicKeys are the keys required to encrypt the votes
repeated string encryptionPublicKeys = 9;
optional uint32 keyIndex = 11;
ProcessStatus status = 12;
optional bytes paramsSignature = 13;
uint32 namespace = 14;
EnvelopeType envelopeType = 15;
ProcessMode mode = 16;
optional uint32 questionIndex = 17;
optional uint32 questionCount = 18;
ProcessVoteOptions voteOptions = 19;
CensusOrigin censusOrigin = 20;
ProcessResult results = 21;
optional uint32 ethIndexSlot = 23;
// SourceBlockHeight is the block height of the origin blockchain (if any)
optional uint64 sourceBlockHeight = 24;
// Owner is the creator of a process (if any) otherwise is assumed the creator is the entityId
optional bytes owner = 25;
// Metadata is the content hashed URI of the JSON meta data (See Data Origins)
optional string metadata = 26;
// SourceNetworkId is the identifier of the network origin (where the process have been created)
SourceNetworkId sourceNetworkId = 27;
// MaxCensusSize is set by the Process creator, indicates the maximum number of votes that will be allowed.
uint64 maxCensusSize = 28;
// RollingCensusRoot merkle root of the rolling census. Set by the
// vocdoni-node when Mode.Process = true
optional bytes rollingCensusRoot = 29;
// RollingCensusSize is set by the vocdoni-node when Mode.PreRegister =
// true and the StartBlock has been reached.
optional uint64 rollingCensusSize = 30;
// NullifiersRoot is the root of the pre-census nullifiers merkle tree.
// Used when Mode.PreRegister = true.
optional bytes nullifiersRoot = 31;
// sourceNetworkContractAddr is used for EVM token based voting and it is
// the contract address of the token that is going to define the census
optional bytes sourceNetworkContractAddr = 32;
// tokenDecimals represents the number of decimals of the token (i.e ERC20) used for voting.
// It is normally used for processes with on-chain census
optional uint32 tokenDecimals = 33;
// tempSIKs flag decides if when the process has finished, the SIKs related
// to it will be removed or not
optional bool tempSIKs = 34;
}
enum ProcessStatus {
PROCESS_UNKNOWN = 0;
READY = 1;
ENDED = 2;
CANCELED = 3;
PAUSED = 4;
RESULTS = 5;
}
enum SourceNetworkId {
UNKNOWN = 0;
ETH_MAINNET = 1;
ETH_RINKEBY = 2;
ETH_GOERLI = 3;
POA_XDAI = 4;
POA_SOKOL = 5;
POLYGON = 6;
BSC = 7;
ETH_MAINNET_SIGNALING = 8;
ETH_RINKEBY_SIGNALING = 9;
AVAX_FUJI = 10;
AVAX = 11;
POLYGON_MUMBAI = 12;
OPTIMISM = 13;
ARBITRUM = 14;
}
enum CensusOrigin {
CENSUS_UNKNOWN = 0;
OFF_CHAIN_TREE = 1;
OFF_CHAIN_TREE_WEIGHTED = 2;
OFF_CHAIN_CA = 3;
ERC20 = 11;
ERC721 = 12;
ERC1155 = 13;
ERC777 = 14;
MINI_ME = 15;
}
message EnvelopeType {
bool serial = 1;
bool anonymous = 2;
bool encryptedVotes = 3;
bool uniqueValues = 4;
bool costFromWeight = 5;
}
message ProcessMode {
bool autoStart = 1;
bool interruptible = 2;
bool dynamicCensus = 3;
bool encryptedMetaData = 4;
bool preRegister = 5;
}
message ProcessVoteOptions {
uint32 maxCount = 1;
uint32 maxValue = 2;
uint32 maxVoteOverwrites = 3;
uint32 maxTotalCost = 4;
uint32 costExponent = 5;
}
message OracleList {
repeated bytes oracles = 1;
}
message ValidatorList {
repeated Validator validators = 1;
}
message Validator {
bytes address = 1;
bytes pubKey = 2;
uint64 power = 3;
string name = 4;
uint32 keyIndex = 5;
}
message TendermintHeader {
// basic block info
string chain_id = 2 ;
int64 height = 3;
int64 timestamp = 4 ;
// prev block info
bytes blockID = 5;
// hashes of block data
bytes last_commit_hash = 6; // commit from validators from the last block
bytes data_hash = 7; // transactions
// hashes from the app output from the prev block
bytes validators_hash = 8; // validators for the current block
bytes next_validators_hash = 9; // validators for the next block
bytes consensus_hash = 10; // consensus params for current block
bytes app_hash = 11; // state after txs from the previous block
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
// consensus info
bytes evidence_hash = 13; // evidence included in the block
bytes proposer_address = 14; // original proposer of the block
}
message ProcessResult {
repeated QuestionResult votes = 1;
}
message QuestionResult {
repeated bytes question = 1;
}
message ProcessEndingList {
repeated bytes processList = 1;
}
// KeyKeeper
message StoredKeys {
repeated bytes pids = 1;
}