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

eth-prover: incorrect behavior of Ethereum Merkle Patricia Trie proof verification #488

Closed
abacabadabacaba opened this issue Feb 8, 2021 · 1 comment

Comments

@abacabadabacaba
Copy link
Contributor

During code review, I found the following issues with proof verification for Ethereum Merkle Patricia Trie (in contracts/near/eth-prover/src/lib.rs):

  1. In function verify_trie_proof: the code that is supposed to split the bytes of the key into nibbles will not split a byte if actual_key.len() + 1 == proof.len(). This is incorrect.
  2. In function _verify_trie_proof: the case node.len() < 32 is superfluous. The size of a receipt is always greater than 32 bytes, and therefore so is the size of any node in the trie.
  3. In function _verify_trie_proof: the case key_index == key.len() is superfluous. The value may be only stored directly in a branch node if there are two keys such that one is a prefix of the other. In the trie of receipts, the keys are RLP encodings, and an RLP encoding can never be a prefix of a different RLP encoding.
  4. In function _verify_trie_proof: the calls to Self::concat_nibbles are incorrect, because both key and key_end (or shared_nibbles) contain nibbles.
  5. In function _verify_trie_proof: the condition expected_value.len() == 0 is incorrect. If the execution reached this point, the function should return false (however, since expected_value is an RLP encoding of a receipt, it cannot be empty).
@abacabadabacaba
Copy link
Contributor Author

Fixed by #556.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants