urbit/sur/ballet.hoon

93 lines
2.1 KiB
Plaintext
Raw Normal View History

2019-06-05 02:46:34 +03:00
:: /sour/ballot
::
:: TODO: ring signature stuff should be provided by their own sur files, this is just
:: stubs for now.
::
|%
++ ring-tag
:: TODO: the ring-tag is really supposed to be a point on a elliptic curve:
:: [@ @]. But to make sure we have ring-tag uniqueness for now, just make
:: the structure a ship name.
::
@p
+$ ring-signature
[@ (list @) =ring-tag]
++ verify-signature
|= [=ring-signature linkage-tag=(unit *) data=*]
^- ?
~& %verify-signature-is-a-stub
::
%.y
--
|%
:: The electorate is the set of people who may vote in an election. This is
:: set during the creation of the election
::
++ electorate
(set @p)
:: The ballot is the set of questions which are then voted on.
::
++ ballot
$: preamble=tape
questions=(list question)
==
:: A question is either a select as many as you want %check or select one %radio
::
++ question
2019-06-06 01:23:05 +03:00
$% [%check preamble=tape descriptions=(list tape)]
[%radio preamble=tape descriptions=(list tape)]
2019-06-05 02:46:34 +03:00
==
2019-06-06 01:23:05 +03:00
:: An individual answer to a question
::
++ answer
$% [%check checked=(list @u)]
[%radio checked=@u]
==
:: A vote is a list of answers to questions on a ballot
2019-06-05 02:46:34 +03:00
::
++ vote
2019-06-06 01:23:05 +03:00
(list answer)
2019-06-05 02:46:34 +03:00
:: A unique id which is used as linkage scope on signatures to votes
::
++ id
$: host=@p
election-num=@u
==
2019-06-06 01:23:05 +03:00
:: A running count of the state of the election
::
+$ tally
(list (map index=@u count=@u))
2019-06-05 02:46:34 +03:00
:: +election contains all the state of an election, and is releasable during
:: and after the fact
::
++ election
$: :: a unique id for this election
::
=id
:: who may vote
::
=electorate
:: what is being voted on
::
=ballot
:: when the election closes
::
closes=@da
:: cast votes, sorted on linkage tag
::
cast=(map ring-tag [=ring-signature =vote])
2019-06-06 01:23:05 +03:00
:: the current running tally of the results
2019-06-05 02:46:34 +03:00
::
2019-06-06 01:23:05 +03:00
=tally
2019-06-05 02:46:34 +03:00
==
:: +election-diff: a series of events which rebuilds an +election object
::
++ election-diff
2019-06-06 02:21:27 +03:00
$% [%snapshot =election]
2019-06-05 02:46:34 +03:00
[%vote =ring-signature =vote]
[%election-completed ~]
==
--