davinci-paper/v2/sections/smart-contracts.tex
v2/sections/smart-contracts.texRaw
1% !TeX root = ../build/main.tex
2
3The \davinci protocol operates on an Ethereum-compatible network, which serves as the source of truth for the election. By leveraging an Ethereum virtual machine (EVM) blockchain, all election transitions become immutable and publicly verifiable. To coordinate and validate each phase of the process, DAVINCI deploys a set of smart contracts that enforce protocol rules, verify \ac{ZK} proofs, and maintain on-chain commitments such as state roots, encryption keys, and final results. Together, these contracts provide a trustless execution environment that guarantees the correct and transparent progression of the election without relying on any centralized authority.
4
5\paragraph{Organization registry.}
6
7The \hlset{\orgregistry} smart contract is used to create and manage organizations within the system. Each organization is identified by the Ethereum address of its creator and is associated with a name and a URL pointing to its metadata. At this stage, the contract serves only as a registration mechanism, but it lays the foundation for future extensions, such as managing multiple elections under the same organization.
8
9\paragraph{Census management.}
10
11This contract is only used by the on-chain dynamic census model (see Section~\ref{sec:vocdoni-protocol:census}), since the off-chain and \ac{CSP} models store the
12census commitment directly as a parameter and require no such contract. This contract maintains the census as an on-chain \ac{IMT} and exposes (i) the current census root, (ii) the total voting power recorded for a given root, and (iii) the validity of a root, returning the last block at which it was valid.
13%To bound storage, only a recent window of roots is retained. During each state transition, the \electionregistry\ contract queries the census contract to confirm that the \censusroot\ used in the membership proof is still valid---and no older than the election's creation block---rejecting the transition otherwise. This lets the census grow during the voting period while ensuring sequencers can only prove membership against roots the contract recognizes.
14
15\paragraph{Key management.}
16
17The \hlset{\dkgmanagement} smart contract coordinates the \ac{DKG} process among the \keywardens. It records their contributions, verifies proofs of correct participation, and ensures that a valid encryption public key is produced once the \ac{DKG} round is complete.
18
19\paragraph{Election registry.}
20
21The \hlset{\electionregistry} smart contract manages the lifecycle of each election, from its creation to the registration of final results. It maintains the election’s current state and ensures that all transitions follow the protocol.
22
23\paragraph{State transition verifier.}
24
25The \hlset{\statetransitionverifier} is responsible for validating the proofs that attest to correct updates of the election state. It stores the verification key corresponding to the state transition circuit (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}) and checks that each submitted proof correctly links the previous and new state roots. Only transitions verified through this contract are accepted as valid updates by the process registry.
26
27\paragraph{Results verifier.}
28
29The \hlset{\resultsverifier} contract validates the proof of correct tally computation. It contains the verification key for the results circuit (see Section~\ref{sec:vocdoni-protocol:circuits:results}) and ensures that the final results submitted by the organizer match the commitments from the final state. Once verified, the results and their proof are permanently recorded on-chain, providing a tamper-proof reference for the election outcome.\\
30
31%1. OrganizationRegistry: se utiliza para crear una organización (que asocia la address del creador con un nombre y una URL a sus metadatos). No tiene ningún otro rol de momento.
32%2. ProcessRegistry: registra como dices todo el proceso de una election, desde su creación hasta registrar los resultados (incluyendo el stateroot en cada momento). En resumen:
33%Genera el state root inicial (aun no, pero lo hará).
34%Controla el status de la election (ready, pause, ...).
35%Verifica las state transitions y actualiza el state de la election.
36%Verifica los resultados una vez que son calculados.
37%3. (Encara no): Coordinación DKG
38%4. Verifier: Realmente son 2 verifiers, el de las statetransitions y el de los results (uno por cada circuito porque cada uno contiene la verification key que debe).