Skip to content

Commit c150746

Browse files
authored
feat(docs): Catalyst vote v2 (#66)
* add new tx v2 spec * wip * wip * wip * wip * wip * wip * fix CI checks * wip * fix
1 parent 29a4988 commit c150746

File tree

4 files changed

+91
-13
lines changed

4 files changed

+91
-13
lines changed

docs/src/architecture/08_concepts/catalyst_voting/crypto.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Before any voting will start an initial setup procedure should be performed.
6565
* As most of the crypto algorithms are group dependent
6666
(more about this you can read in [appendix A](#a-group-definition)),
6767
it is needed to specifically define which cryptographically secure group would be used.
68-
* Define a hash function which will be used by the underlying crypto algorithms.
6968
* Define a commitment key $ck$,
7069
which will be used during the voter proof generation and verification procedures.
7170

@@ -502,7 +501,7 @@ To compute it, prover needs to perform the next steps:
502501
* $A_l = g^{i_l * \beta_l} \circ ck^{\delta_l}, A_l \in \mathbb{G}$.
503502
5. Calculate a first verifier challenge
504503
$ch_1 = H(ck, pk, \{c_j\}, \{I_l\}, \{B_l\}, \{A_l\})$,
505-
where $H$ is a hash function,
504+
where $H$ is [BLAKE2b-512] hash function,
506505
$j \in [0, \ldots, N-1]$
507506
and $l \in [0, \ldots, log_2(N)-1]$.
508507
6. For $j \in [0, \ldots, N-1]$ calculate polynomials
@@ -518,7 +517,7 @@ To compute it, prover needs to perform the next steps:
518517
and $p_{j,l}$ - corresponding coefficients of the polynomial $p_j(x)$ calculated on step `7`.
519518
9. Calculate a second verifier challenge
520519
$ch_2 = H(ch_1, \{D_l\})$,
521-
where $H$ is a hash function
520+
where $H$ is [BLAKE2b-512] hash function
522521
and $l \in [0, \ldots, log_2(N)-1]$.
523522
10. For $l \in [0, \ldots, log_2(N)-1]$ calculate:
524523
* $z_l = i_l * ch_2 + \beta_l, z_l \in \mathbb{Z}_q$.
@@ -558,12 +557,12 @@ verifier needs to perform the next steps:
558557
So the resulted $\mathbf{c} = (c_1, \ldots, c_M, \{c_j\})$.
559558
2. Calculate the first verifier challenge
560559
$ch_1 = H(ck, pk, \{c_j\}, \{I_l\}, \{B_l\}, \{A_l\})$,
561-
where $H$ is a hash function,
560+
where $H$ is [BLAKE2b-512] hash function,
562561
$j \in [0, \ldots, N-1]$
563562
and $l \in [0, \ldots, log_2(N)-1]$.
564563
3. Calculate a second verifier challenge
565564
$ch_2 = H(ch_1, \{D_l\})$,
566-
where $H$ is a hash function
565+
where $H$ is [BLAKE2b-512] hash function
567566
and $l \in [0, \ldots, log_2(N)-1]$.
568567
4. For $l \in [0, \ldots, log_2(N)-1]$ verify that the following statements are `true`,
569568
where $g$ is the group generator:
@@ -683,3 +682,4 @@ If step `6` returns `true` so the final result is `true` otherwise return `false
683682
[treasury_system_paper]: https://eprint.iacr.org/2018/435.pdf
684683
[treasury_system_spec]: https://github.com/input-output-hk/treasury-crypto/blob/master/docs/voting_protocol_spec/Treasury_voting_protocol_spec.pdf
685684
[crypto_book]: https://gnanavelrec.wordpress.com/wp-content/uploads/2019/06/2.understanding-cryptography-by-christof-paar-.pdf
685+
[BLAKE2b-512]: https://www.blake2.net/blake2.pdf

docs/src/architecture/08_concepts/catalyst_voting/transaction.md

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Transaction
1+
# Transactions
22

33
---
44

5-
Title: Voting Transaction
5+
Title: Voting Transactions
66

77
Status: Proposed
88

@@ -46,7 +46,7 @@ V1 transaction representation in hex:
4646

4747
<!-- markdownlint-disable line-length code-block-style -->
4848
1. Transaction size (u32): `0000037e`
49-
2. `00`
49+
2. Jörmungandr specific tag (u8): `00`
5050
3. Jörmungandr specific tag (u8): `0b`
5151
4. Vote plan id (32 byte hash): `36ad42885189a0ac3438cdb57bc8ac7f6542e05a59d1f2e4d1d38194c9d4ac7b`
5252
5. Proposal index (u8): `00`
@@ -87,8 +87,7 @@ the following properties are used:
8787

8888
1. Each proposal, defined by the "Vote plan id" and "Proposal index", defines a number of possible options.
8989
2. [ristretto255] as a backend cryptographic group.
90-
3. [BLAKE2b-512] hash function.
91-
4. A commitment key $ck$ defined as a [BLAKE2b-512] hash of the "Vote plan id" bytes.
90+
3. A commitment key $ck$ defined as a [BLAKE2b-512] hash of the "Vote plan id" bytes.
9291

9392
#### Transaction signing (witness generation)
9493

@@ -115,7 +114,56 @@ Expected witness (includes signature)
115114

116115
<!-- markdownlint-disable code-block-style -->
117116
```hex
118-
0200000000e6c8aa48925e37fdab75db13aca7c4f39068e12eeb3af8fd1f342005cae5ab9a1ef5344fab2374e9436a67f57041899693d333610dfe785d329988736797950d
117+
0200000000e6c8aa48925e37fdab75db13aca7c4f39068e12eeb3af8fd1f342005cae5ab9a1ef5344fab2374e9436a67f57041899693d333610dfe785d329988736797950d
118+
```
119+
<!-- markdownlint-enable code-block-style -->
120+
121+
### v2
122+
123+
<!-- markdownlint-disable max-one-sentence-per-line code-block-style -->
124+
??? note "V2 vote transaction definition: `tx_v2.cddl`"
125+
126+
```CDDL
127+
{{ include_file('src/architecture/08_concepts/catalyst_voting/tx_v2.cddl', indent=4) }}
128+
```
129+
<!-- markdownlint-enable max-one-sentence-per-line code-block-style -->
130+
131+
`event` - a set of different identifiers which is uniquely define a particular voting event.
132+
133+
Vote:
134+
135+
* `choices` - a collection of voter choices for the proposal.
136+
* `proof` - a voter proof, could be `null`.
137+
* `prop_id` - a proposal id for which `choice` is made, could be `null`.
138+
For that case where for the `event` defined only **one** proposal,
139+
so it's redundant to provide an additional identifier for the proposal,
140+
so it could be placed `null`.
141+
142+
`voters_data` - an any additional voter's specific data.
143+
144+
#### Transaction signing
145+
146+
[COSE] is used to define a transaction's signature structure.
147+
[COSE] is a flexible security protocol that supports various types of security messages.
148+
However, only `COSE Signed Data Object` or `COSE_Sign` type is used.
149+
150+
The following header must be included in the [COSE] signature.
151+
152+
`protected`:
153+
154+
* `content type`: `application/cbor`
155+
(this parameter is used to indicate the content type of the data in the payload or ciphertext fields).
156+
157+
Any other headers as `alg`, `kid` etc. could be specified of any kind and not defined by this spec.
158+
159+
##### Signature payload
160+
161+
As mentioned earlier, the content type of the [COSE] signature payload is `application/cbor`.
162+
In particular it must be a [CBOR] encoded [BLAKE2b-256] hash bytes:
163+
164+
<!-- markdownlint-disable code-block-style -->
165+
```CDDL
166+
{{ include_file('src/architecture/08_concepts/catalyst_voting/tx_v2_cose_payload.cddl') }}
119167
```
120168
<!-- markdownlint-enable code-block-style -->
121169

@@ -131,6 +179,8 @@ Expected witness (includes signature)
131179

132180
<!-- OPTIONAL SECTIONS: see CIP-0001 > Document > Structure table -->
133181

134-
[BLAKE2b-256]: https://www.blake2.net/blake2.pdf\
135-
[BLAKE2b-512]: https://www.blake2.net/blake2.pdf\
182+
[BLAKE2b-256]: https://www.blake2.net/blake2.pdf
183+
[BLAKE2b-512]: https://www.blake2.net/blake2.pdf
136184
[ristretto255]: https://ristretto.group
185+
[COSE]: https://datatracker.ietf.org/doc/rfc9052/
186+
[CBOR]: https://datatracker.ietf.org/doc/rfc8949/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
vote_tx = [
2+
vote_tx_body,
3+
signature
4+
]
5+
6+
vote_tx_body = [
7+
vote_type: UUID ; e.g. Public or Private vote
8+
event,
9+
votes,
10+
voters_data: encoded_cbor
11+
]
12+
13+
event = { * event_key => any }
14+
event_key = int / text
15+
16+
votes = [+ vote]
17+
vote = [
18+
choices: encoded-cbor,
19+
proof: encoded-cbor / null,
20+
prop_id: encoded-cbor / null,
21+
]
22+
choices = [+ choice]
23+
choice = encoded-cbor
24+
25+
UUID = #6.37(bytes) ; UUID type
26+
signature = #6.98(COSE_Sign) ; COSE signature
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cose_payload = blake2b-256
2+
blake2b-256 = #6.32782(bytes .size 32) ; Blake2b-256 hash bytes

0 commit comments

Comments
 (0)