Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust/vote-tx-v2): Public vote tx v2 CBOR decoding/encoding implementation #86

Merged
merged 30 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5d7a9d6
refactor
Mr-Leshiy Nov 15, 2024
3b53b88
add public_tx mod
Mr-Leshiy Nov 15, 2024
d47b09e
add initial PublicTx impl
Mr-Leshiy Nov 15, 2024
90208cd
make gen_tx::Choice generic
Mr-Leshiy Nov 16, 2024
5ea1516
make gen_tx::PropId and gen_tx::Proof generic
Mr-Leshiy Nov 17, 2024
242e5e0
add more gen_tx decoding tests
Mr-Leshiy Nov 18, 2024
73a49b9
add separate tx_body mod
Mr-Leshiy Nov 18, 2024
39d2d90
move vote impl into vote mod
Mr-Leshiy Nov 18, 2024
76cc88d
move EventMap to event_map mod
Mr-Leshiy Nov 18, 2024
8177528
move VoterData to voter_data mod
Mr-Leshiy Nov 18, 2024
0aa13c7
wip
Mr-Leshiy Nov 18, 2024
8c973f7
remove docoding mod
Mr-Leshiy Nov 18, 2024
8888f6c
wip
Mr-Leshiy Nov 18, 2024
7cca20b
add signature header validation
Mr-Leshiy Nov 18, 2024
9655c64
add a gen_tx::builder
Mr-Leshiy Nov 18, 2024
b2623db
wip
Mr-Leshiy Nov 18, 2024
a7ea7b5
refactor VoterData type
Mr-Leshiy Nov 18, 2024
cf4cdc3
refactor Cbor
Mr-Leshiy Nov 18, 2024
03e8d0e
update cddl specs, make voter-data generic
Mr-Leshiy Nov 19, 2024
6a7d923
move choice to the separate mod
Mr-Leshiy Nov 19, 2024
597230c
wip
Mr-Leshiy Nov 19, 2024
c822ff7
move Uuid impl to seprate mod
Mr-Leshiy Nov 19, 2024
626ecc5
move EncodedCbor struct to separate mod
Mr-Leshiy Nov 19, 2024
415ff9e
add public tx test
Mr-Leshiy Nov 19, 2024
548aa3f
fix spelling
Mr-Leshiy Nov 19, 2024
b005187
Merge branch 'main' into feat/public-private-vote-tx
minikin Nov 26, 2024
57bdaec
fix, add missing comma
Mr-Leshiy Dec 2, 2024
6ed8202
Merge branch 'main' into feat/public-private-vote-tx
Mr-Leshiy Dec 2, 2024
bf461c3
move definition of public_tx/choice and public_tx/proof to the public…
Mr-Leshiy Dec 2, 2024
2cde1b3
add comment which specifies a CBOR encoding/decoding profile
Mr-Leshiy Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
gen-vote-tx<choice-t, proof-t, prop-id-t> = [
tx-body<choice-t, proof-t, prop-id-t>,
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

gen-vote-tx<choice-t, proof-t, prop-id-t, voter-data-t> = [
tx-body<choice-t, proof-t, prop-id-t, voter-data-t>,
signature
]

tx-body<choice-t, proof-t, prop-id-t> = [
vote-type
tx-body<choice-t, proof-t, prop-id-t, voter-data-t> = [
vote-type,
event,
votes<choice-t, proof-t, prop-id-t>,
voter-data,
voter-data<voter-data-t>,
]

vote-type = UUID ; e.g. Public or Private vote
event = { * event-key => any }
event = { * event-key => event-value }
event-key = int / text
event-value = any

votes<choice-t, proof-t, prop-id-t> = [+ vote<choice-t, proof-t, prop-id-t>]
vote<choice-t, proof-t, prop-id-t> = [
Expand All @@ -25,7 +29,7 @@ choice<choice-t> = #6.24(bytes .cbor choice-t) ; encoded-cbor
proof<proof-t> = #6.24(bytes .cbor proof-t) ; encoded-cbor
prop-id<prop-id-t> = #6.24(bytes .cbor prop-id-t) ; encoded-cbor

voter-data = encoded-cbor
voter-data<voter-data-t> = #6.24(bytes .cbor voter-data-t) ; encoded-cbor

UUID = #6.37(bytes) ; UUID type
signature = #6.98(cose.COSE_Sign) ; COSE signature
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

cose-payload = blake2b-256
blake2b-256 = #6.32782(bytes .size 32) ; Blake2b-256 hash bytes
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
vote-tx-v2 = gen-vote-tx<choice-data, proof-data, proposal>
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

vote-tx-v2<voter-data-t> = gen-vote-tx<choice-data, proof-data, proposal, voter-data-t>

choice-data = ciphertext
ciphertext = [group-element, group-element]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
vote-tx-v2-public = gen-vote-tx<choice-data, proof-data, proposal>
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

vote-tx-v2-public<voter-data-t> = gen-vote-tx<choice-data, proof-data, proposal, voter-data-t>

choice-data = uint
proof-data = undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

block = [
block-header,
block-data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

genesis-to-prev-hash = [
chain-id: ULID,
timestamp: #6.1(uint .ge 1722470400), ; Epoch-based date/time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
; All encoders/decoders of this specification must follow deterministic cbor encoding rules
; https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-06

hash-bytes = (
#6.32781(bytes) / ; Blake3 hash
#6.32782(bytes) / ; Blake2b hash
Expand Down
Loading