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(docs): Update voting docs, add cddl validation #79

Merged
merged 17 commits into from
Nov 5, 2024
Next Next commit
fix gen_vote_tx structure
  • Loading branch information
Mr-Leshiy committed Nov 3, 2024
commit bf625f932c2764d73c13974f67d98576d9487bf8
14 changes: 14 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -41,3 +41,17 @@ repo-docs:
COPY --dir *.md LICENSE-APACHE LICENSE-MIT .

SAVE ARTIFACT /repo repo

cddlc:
FROM ruby:3.3.0-alpine

WORKDIR /cddl

RUN gem install cddlc

COPY ./docs/src/architecture/08_concepts/catalyst_voting/cddl/gen_vote_tx.cddl .
COPY ./docs/src/architecture/08_concepts/catalyst_voting/cddl/vote_tx_v2.cddl .

RUN cddlc -u2tcddl vote_tx_v2.cddl


Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@ event = { * event-key => any }
event-key = int / text

votes = [+ vote]
vote = [
choices,
proof \ null,
prop-id \ null,
vote<choice-t, proof-t, prop-id-t> = [
choices<choice-t>,
proof<proof-t> / null,
prop-id<prop-id-t> / null,
]
choices = [+ choice]
choice = encoded-cbor
proof = encoded-cbor
prop-id = encoded-cbor
choices<choice-t> = [+ choice<choice-t>]
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

voters-data = encoded-cbor

Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
vote-tx-v2 = gen-vote-tx

choice = #6.24(bstr(choice-data))
proof = #6.24(bstr(proof-data))
prop-id = #6.24(bstr(proposal))
vote-tx-v2 = gen-vote-tx<choice-data, proof-data, proposal>

choice-data = public-choice / private-choice

@@ -16,10 +12,9 @@ proposal = UUID

proof-data = zk-proof

zk-proof = [[+ (announcement, ciphertext, r-response)], scalar]
zk-proof = [[+ (announcement, ~ciphertext, r-response)], scalar]

announcement = (group-element, group-element, group-element)
ciphertext = (group-element, group-element)
r-response = (scalar, scalar, scalar)

scalar = bytes .size 32