-
Notifications
You must be signed in to change notification settings - Fork 105
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
bug: BytesTrait keccak computation mismatch #317
Comments
Gm gm, |
Hey, no sorry I meant that the version that I used for the test was 2.6.0. But it occurs with previous versions too. Thank you for your time. |
GM @zkcarter |
This code should be removed thanks to: |
@JordyRo1 do you still think it needs to be addressed given that it'll be part of the standard library? |
@gaetbout No it's not necessary anymore, no problem I will not delete it ! |
Hi @gaetbout BytesTrait is a supplement to the standard library that has been developed for some time. I believe that once these functions are implemented in the standard library, this code should be removed, and developers should be encouraged to use the standard library. |
We'll do it, thanks @zkcarter ! |
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. |
Stay alive |
Should be solved with #321 |
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. |
Solved with #321 |
@JordyRo1 Can you close this :) ? |
Bug Report
Alexandria version:
This bug appears for the most recent Alexandria version cairo-v2.6.0
Current behavior:
The BytesTrait keccak function sometimes output incorrect hash, notably when 0-padding is involved. Let me explain with an example.
The objective was to compute the keccak hash of the felt252 element:
0x48595045524c414e455f414e4e4f554e43454d454e54
. The python implementation provided on testswas used to check if the result matches the expectation. The expected result from the python script was
0xda15cbb01a970c130a1bf6ba8b35fcff0fabd4695bfb03f4454482023f2ae84c
. The function keccak from BytesTrait and from the python script have inverse endianness, so the expected result should be0x4CE82A3F02824445F403FB5B69D4AB0FFFFC358BBAF61B0A130C971AB0CB15DA
.However, the output result from the bytes.keccak() is
0x93F59F2604EE54DE51A2DFCFB3E0A6D74EDE53826CF2D1CBA9422A06AF66BC65
. After further investigation, the input argument that could possibly lead to this hash is0000000000000000000048595045524c414e455f414e4e4f554e43454d454e54
.This is why I assume the error might be linked to the padding , unless I am missing something.
Expected behavior:
The output hash of the keccak function should match the one computed using the python script.
Steps to reproduce:
You can just append the following lines to the
test_bytes_keccak
function for example to test.Related code:
The text was updated successfully, but these errors were encountered: