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

Fix MACI 1.0 ProcessMessages circuit to prevent message censorship by the coordinator #320

Closed
weijiekoh opened this issue Dec 1, 2021 · 0 comments
Assignees

Comments

@weijiekoh
Copy link
Contributor

weijiekoh commented Dec 1, 2021

This new design iterates through each message and checks a Merkle path to an intermediate state root. This way, we ensure that no state leaves can be manipulated by the coordinator.

// in this example, batchSize = 4

// The decrypted messages
signal  commands[batchSize];

// These are leaves targeted by the commands
signal private input leavesToOperateOn[batchSize];
/*
Note that leavesToOperateOn = [
    stateLeavesInTree[command[0].stateIndex]]
    stateLeavesInTree[command[1].stateIndex]]
    stateLeavesInTree[command[2].stateIndex]]
    stateLeavesInTree[command[3].stateIndex]]
]

stateLeavesInTree refers to the actual state leaves. e.g. in a tree of depth 2 and arity 2, stateLeavesInTree = [leaf0, leaf1, leaf2, leaf3].
*/

// The state root before it is processed. Actually, this value is from the
// contract.
signal private input currentStateRoot; 

// The intermediate state roots
signal input updatedRoots[batchSize]

// The Merkle proofs per leavesToOperateOn
signal private input pathElements[batchSize][arity];

1. CHECK that leavesToOperateOn[0] **is a member of** currentStateRoot
    - use pathElements[0] to reconstruct a root and then compare it with currentStateRoot
2. APPLY commands[0] to leavesToOperateOn[0] AND SET IT AS updatedRoot[0]
    - use pathElements[0] to construct the root and set it as updatedRoot[0]

3. CHECK that leavesToOperateOn[1] **is a member of** updatedRoot[0]
    - use pathElements[1] to reconstruct a root and then compare it with updatedRoot[0]
4. APPLY commands[1] to leavesToOperateOn[1] AND SET IT AS updatedRoot[1]
    - use pathElements[1] to construct the root and set it as updatedRoot[1]

5. CHECK that leavesToOperateOn[2] **is a member of** updatedRoot[1]
6. APPLY commands[2] to leavesToOperateOn[2] AND SET IT AS updatedRoot[2]

7. CHECK that leavesToOperateOn[3] **is a member of** updatedRoot[2]
8. APPLY commands[3] to leavesToOperateOn[3] AND SET IT AS final state root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants