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

Feat: Test coverage for merkle related functions and keccak bug fix #39

Merged
merged 9 commits into from
Jun 18, 2024

Conversation

JordyRo1
Copy link
Contributor

@JordyRo1 JordyRo1 commented Jun 17, 2024

Resolves #35 #37

Keccak bug fix

**Implementation of ByteArray for Keccak Function Input: **

We introduced the ByteArray to concatenate the entries array, which serves as the input for our Keccak function.

** Bug Fix for u64 Span Division and Reversal: **

There was a bug causing information loss for the last element of the array during the division into u64 spans and the subsequent reversal. For instance, given the input 0x111111111111111100111223, the build_u64_array function correctly returned [0x1111111111111111, 0x111223]. However, reversing the endianness of this array resulted in [0x1111111111111111, 0x232111], losing the '00' in the process.
This pull request resolves the issue by considering the last two u64 elements of the initial input and ensuring the size of the reversed output matches the size of the last word plus 8 bytes.

Test coverage

Added additional tests for the merkle tree hook, the keccak computation, and fixing existing bugs with the current tests.

TODO

  • Detailed documentation on the computation process for keccak,
  • Code cleanup (remove unused imports, and variables for the modified contracts ONLY)

@EvolveArt EvolveArt linked an issue Jun 18, 2024 that may be closed by this pull request
Copy link
Contributor

@EvolveArt EvolveArt left a comment

Choose a reason for hiding this comment

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

why remove the MerkleLib ?

contracts/src/contracts/libs/message.cairo Outdated Show resolved Hide resolved
contracts/src/tests/hooks/test_merkle_tree_hook.cairo Outdated Show resolved Hide resolved
contracts/src/tests/hooks/test_merkle_tree_hook.cairo Outdated Show resolved Hide resolved
contracts/src/utils/keccak256.cairo Show resolved Hide resolved
@EvolveArt EvolveArt merged commit 7bfd99f into main Jun 18, 2024
6 checks passed
@EvolveArt EvolveArt deleted the feat-Test-coverage-for-merkle-related-functions branch June 18, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants