-
Notifications
You must be signed in to change notification settings - Fork 186
Maci Threat Modeling - DRAFT #2788
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
Draft
AronisAt79
wants to merge
23
commits into
privacy-ethereum:main
Choose a base branch
from
AronisAt79:mac-threat-model-draft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+648
−0
Draft
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a6d9996
add mermaid sequences
AronisAt79 ca1b3eb
system spec
AronisAt79 2127714
Add threat model and expand tm for L2 deployments
AronisAt79 ca9131c
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 17f4ba8
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 2dc0954
Update threat-model/THREAT_MODEL.md
AronisAt79 515200c
Update threat-model/THREAT_MODEL.md
AronisAt79 66aebdf
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 5927a24
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 8940d49
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 e28071e
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 d813f86
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 92a1053
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 ac154e5
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 1488dcb
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 e039c5f
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 d8616ac
Update threat-model/SYSTEM_SPECIFICATION.md
AronisAt79 9d43c44
Rename THRET_MODEL_L2.md to THREAT_MODEL_L2.md
AronisAt79 32e68e9
Update threat-model/THREAT_MODEL.md
AronisAt79 1a9af5d
suggestion https://github.com/privacy-ethereum/maci/pull/2788\#discus…
AronisAt79 a1ccc81
add maci key rotation flow to sequences
AronisAt79 a5b1171
format mermaid
AronisAt79 b1a980f
https://github.com/privacy-ethereum/maci/pull/2788\#discussion_r24231…
AronisAt79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| # MACI Data Flows — System-Level Specification | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Purpose | ||
|
|
||
| This document describes the **data flows in the MACI protocol** as explicitly defined in its published documentation. | ||
| It covers how information moves between on-chain and off-chain components — from user signup and vote submission to coordinator tallying and proof publication. | ||
|
|
||
| All flows below are factual summaries of official MACI docs; any implementation detail not present in the docs is clearly marked as **unspecified**. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Roles and Components | ||
|
|
||
| | Role | Responsibility | Documentation Source | | ||
| |------|----------------|----------------------| | ||
| | **User (Voter)** | Signs up, joins polls, submits encrypted votes. | Workflow: “Users, who vote on polls” | | ||
| | **Coordinator** | Deploys contracts and polls, decrypts and tallies votes, generates zk-SNARK proofs, publishes results. | Workflow; Coordinator Service | | ||
| | **Relayer (Off-chain)** | Allows gasless voting, batches messages, uploads to IPFS, submits message hashes on-chain. | Off-chain Relayer | | ||
| | **Smart Contracts (including Verifier contracts)** | Manage user signups and polls, record encrypted votes, and verify zk-SNARK proofs for message processing and tally correctness. | Workflow, Technical References | | ||
| | **IPFS / Off-chain Storage** | Holds encrypted message batches submitted by the relayer. | Off-chain Relayer | | ||
| | **zkSNARK Circuits** | Define proofs for `processMessages` and `tallyVotes`. | Technical References | | ||
| | **Ethereum / L2** | Provides canonical ledger for state commitments and proof verification. | General docs | | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Poll Lifecycle and Data Flow Overview | ||
|
|
||
| Each **Poll** progresses through **three stages**: | ||
| 1. **Open** — users can sign up, join, and vote. | ||
| 2. **Closed** — voting ends; coordinator processes messages. | ||
| 3. **Finalized** — coordinator tallies results and publishes verified proofs. | ||
|
|
||
| MACI’s workflow is a data-driven state machine where messages flow between **users**, **relayer**, **on-chain contracts**, **off-chain coordinator**, and **verifiers**. | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Detailed Data Flows | ||
|
|
||
| ### A. Setup and Deployment | ||
|
|
||
| **Coordinator → Blockchain** | ||
|
|
||
| 1. Deploy `MACI.sol` and dependent contracts (`PollFactory`, `Gatekeeper`, `Verifier`, etc.). | ||
| - Sets gatekeeper policy (who can sign up). | ||
| - Defines state tree depth (max voters). | ||
| - Specifies voting mode (e.g., quadratic funding). | ||
| _Source: Coordinator Service._ | ||
|
|
||
| 2. Deploy a **Poll** via `MACI.deployPoll()`. | ||
| - Poll parameters include: gatekeeper, start/end dates, vote options, and voting mode. | ||
| _Source: Workflow → Poll Lifecycle._ | ||
|
|
||
| 3. Initialize **trusted setup parameters** for proof verification (Groth16 keys). | ||
| _Source: Trusted Setup docs._ | ||
|
|
||
| --- | ||
|
|
||
| ### B. User Sign Up | ||
|
|
||
| **User/Wallet → MACI.sol** | ||
|
|
||
| 1. Generate MACI keypair (distinct from Ethereum key). | ||
AronisAt79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 2. Call `signUp()` on the MACI contract with the **public key**. | ||
| - This key becomes the voter’s MACI identity. | ||
| - The gatekeeper policy enforces Sybil resistance (e.g., NFT, EAS attestation, proof-of-personhood). | ||
NicoSerranoP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _Source: Workflow → “Sign up.”_ | ||
|
|
||
| **Data artifacts created:** | ||
| - `signUp()` event (public). | ||
| - User’s MACI public key (on-chain state tree leaf). | ||
| - Associated private key (off-chain only, user-held). | ||
|
|
||
| --- | ||
|
|
||
| ### C. Poll Joining | ||
|
|
||
| **User/Wallet → Poll.sol** | ||
|
|
||
| 1. Call poll’s **join** function, providing: | ||
| - ZK proof of knowledge of MACI private key. | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Any poll-specific gatekeeper credentials. | ||
| _Source: Workflow → “Poll Joining.”_ | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 2. On success, user is registered to vote in that poll instance. | ||
|
|
||
| **Data artifacts created:** | ||
| - On-chain proof of poll eligibility. | ||
| - Internal state tree update linking user to poll. | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| --- | ||
|
|
||
| ### D. Vote Command and Message Creation | ||
|
|
||
| **User/Wallet (local)** | ||
|
|
||
| 1. Build a **command** (fields per docs): | ||
| - `maciPublicKey`, `voteOption`, `voteWeight`, `nonce`, `pollId`, `salt` | ||
| _Source: Workflow → “Vote.”_ | ||
|
|
||
| 2. **Sign** the command with the MACI private key. | ||
| 3. **Encrypt** the command and signature with a shared key between user and coordinator. | ||
| - Each user–coordinator pair uses a distinct encryption key. | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - This ensures only the coordinator can decrypt the message. | ||
| _Source: Workflow → “Before sending their vote on-chain…”_ | ||
|
|
||
| 4. Resulting ciphertext = **Message**. | ||
|
|
||
| --- | ||
|
|
||
| ### E. Message Submission (Two Paths) | ||
|
|
||
| #### Path 1 — On-chain (direct) | ||
|
|
||
| **User/Wallet → Poll.sol** | ||
| - Call `publishMessage()` with encrypted message. | ||
| - Message stored directly on-chain. | ||
| _Source: Workflow → “Vote on a poll.”_ | ||
|
|
||
| #### Path 2 — Off-chain Relayer (privacy/gasless) | ||
|
|
||
| **User/Wallet → Relayer** | ||
| 1. Send encrypted message off-chain. | ||
| 2. Relayer verifies user authorization via ZK proof (user must know pre-image to a state leaf). | ||
| 3. Relayer batches messages and uploads them to IPFS. | ||
| 4. Relayer submits **batch hash + IPFS CID** to `Poll.sol`. | ||
| _Source: Off-chain Relayer/Core Concepts:Offchain Voting._ | ||
|
|
||
| > ⚠️ If batch hashes are submitted without valid IPFS storage, polls cannot be finalized. | ||
| > _Source: Off-chain Relayer._ | ||
|
|
||
| **Data artifacts created:** | ||
| - IPFS batch (off-chain) | ||
| - On-chain reference (CID + hash) | ||
|
|
||
| --- | ||
|
|
||
AronisAt79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### F. Poll Closing | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Blockchain → Coordinator** | ||
|
|
||
| 1. Once poll duration elapses, Poll transitions from **Open → Closed**. | ||
| 2. No further messages accepted. | ||
| 3. Coordinator begins off-chain processing. | ||
| _Source: Workflow → “Closed.”_ | ||
|
|
||
| --- | ||
|
|
||
| ### G. Message Processing | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Coordinator (local)** | ||
|
|
||
| 1. Fetch all IPFS batches using on-chain CIDs. | ||
| 2. Decrypt and validate each message. | ||
| 3. Apply valid messages to the **state tree**, ignoring superseded votes (only the latest per voter counts). | ||
| _Source: Workflow → “Process Messages.”_ | ||
|
|
||
| 4. Create ZK proof showing: | ||
| - Correct decryption of messages. | ||
| - Correct state tree transitions. | ||
|
|
||
| **Coordinator → Blockchain** | ||
| 5. Call `MessageProcessor.processMessages()` with: | ||
| - State tree hash | ||
| - zk-SNARK proof | ||
|
|
||
| **Verifier Contract** | ||
| 6. Verifies proof validity. | ||
| - If returns `true`, the processed batch is confirmed correct. | ||
| - Repeat until all messages processed. | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| _Source: Workflow → “Process Messages.”_ | ||
|
|
||
| **Data artifacts:** | ||
| - Updated state tree (off-chain) | ||
| - Batch proofs (on-chain) | ||
| - Message proofs (verifier output) | ||
|
|
||
| --- | ||
|
|
||
| ### H. Tally Results | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Coordinator (local)** | ||
|
|
||
| 1. Compute tally from valid votes in state tree. | ||
| 2. Generate ZK proof that tally corresponds to valid votes. | ||
| _Source: Workflow → “Tally Results.”_ | ||
|
|
||
| **Coordinator → Blockchain** | ||
| 3. Call `Tally.tallyVotes()` with: | ||
| - Tally hash | ||
| - zk-SNARK proof | ||
|
|
||
| **Verifier Contract** | ||
| 4. Validates tally proof. | ||
| - If valid, Poll moves to **Finalized** state. | ||
|
|
||
| **Data artifacts:** | ||
| - Tally proof + hash | ||
| - On-chain event `PollFinalized` | ||
|
|
||
| --- | ||
|
|
||
| ### I. Finalization and Verification | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Blockchain (public)** | ||
|
|
||
| - The poll’s final state, tally hash, and ZK proof are now visible. | ||
| - Any user can verify that the results were correctly computed from valid encrypted votes. | ||
| - Individual votes remain private. | ||
| _Source: Workflow → “Finalized.”_ | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Trust Boundaries (per flow segment) | ||
|
|
||
| | Flow Segment | Trust Boundary | Possible Weakness | | ||
| |---------------|----------------|-------------------| | ||
| | User ↔ Wallet | Key generation & signing | Key leakage compromises user’s MACI identity | | ||
| | Wallet ↔ Relayer | Off-chain submission | Relayer may log metadata or fail to upload IPFS batches | | ||
AronisAt79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | Relayer ↔ IPFS | Data persistence | Missing batches block finalization | | ||
| | Coordinator ↔ Blockchain | Proof publication | Coordinator may halt, delaying results | | ||
AronisAt79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | Coordinator ↔ Verifier | Proof correctness | Circuit mismatch or setup corruption may invalidate verification | | ||
NicoSerranoP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| --- | ||
|
|
||
| ## 6. Failure and Liveness Scenarios (as documented) | ||
|
|
||
| | Failure Mode | Effect | Source | | ||
| |---------------|--------|--------| | ||
| | Coordinator halts / offline | Poll never finalized; results not published. | Workflow → “Trust assumptions” | | ||
| | Coordinator decrypts votes | Privacy loss but not integrity failure. | Workflow → “Trust assumptions” | | ||
| | Relayer pushes invalid IPFS hash | Poll cannot be finalized. | Off-chain Relayer | | ||
| | zk-SNARK setup compromised | Fake proofs accepted. | Trusted Setup | | ||
| | L1/L2 censorship | Delays proof publication; no permanent forgery. | General assumption | | ||
AronisAt79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| --- | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.