8000 Range check by rrtoledo · Pull Request #74 · clearmatics/zeth · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Range check #74

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

Merged
merged 5 commits into from
Oct 4, 2019
Merged

Range check #74

merged 5 commits into from
Oct 4, 2019

Conversation

rrtoledo
Copy link
Contributor

PR related to issue #38

@@ -189,6 +191,10 @@ contract BaseMixer is MerkleTreeMiMC7, ERC223ReceivingContract {
digest_inputs[0] = primary_inputs[i]; // See the way the inputs are ordered in the extended proof
digest_inputs[1] = primary_inputs[i+1];
bytes32 current_commitment = Bytes.sha256_digest_from_field_elements(digest_inputs);
require(
uint256(current_commitment) < r,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double spending threat has to do with the nullifier, not the commitments.
Basically, N and N + MP lie in the same equiv. class mod P, thus you can we need to make sure that no one is able to use multiple elements from a same equiv class mod P to carry out double spendings. That's why we need to make sure that we only accept primary inputs that are < P (P being the scalar field prime here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I removed this check from the assemble function and forgot to add it again (c.f. last commit) (since the assemble function should disappear with the new packing policy).

It is written in the issue to check the primary inputS so I thought you also might want to check tall of them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to double check the diffs of your PRs next time

Copy link
Contributor
@AntoineRondelet AntoineRondelet Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were not checking the right thing here.
In the lines commented above you compare a 256-bit number with the scalar field characteristic r (encoded on 253 bits), I think you haven't ran the python tests. I haven't but I'd bet they would fail most of the time (nothing should prevent your nullifiers and commitments, both output of sha256 or blake2s to be smaller than r, why did you think they should?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I saw some tests failing.
I thought that these commitments were the field commitments already and not the blake2s digests.

Copy link
Contributor
@AntoineRondelet AntoineRondelet Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do I understand correctly that you wanted to merge to develop a piece of code that:

  1. Does not fix the vulnerability
  2. Breaks the tests
    ??

It does not make any sense. If you are assigned to an issue, this is your responsibility to fix it. The goal is not to push an half-baked patch that breaks half of the tests, ask a review and move to the next one.

@AntoineRondelet
Copy link
Contributor
AntoineRondelet commented Oct 2, 2019

Fixed in #85

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

Successfully merging this pull request may close these issues.

2 participants
0