Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

[KGA-18] [KGA-67] fix: off by one error ripemd-160 #1575

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cairo_zero/kakarot/precompiles/ripemd160.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func finish{range_check_ptr, bitwise_ptr: BitwiseBuiltin*}(
let len_8 = mswlen * 8;
let (val_15) = uint32_or(factor, len_8);

let next_block = is_nn_le(55, len);
let next_block = is_nn_le(56, len);
if (next_block == FALSE) {
dict_write{dict_ptr=x}(14, val);
dict_write{dict_ptr=x}(15, val_15);
Expand Down
6 changes: 4 additions & 2 deletions cairo_zero/tests/src/kakarot/precompiles/test_ripemd160.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import pytest
from Crypto.Hash import RIPEMD160
from hypothesis import given, settings
from hypothesis import example, given
from hypothesis.strategies import binary


@pytest.mark.asyncio
@pytest.mark.slow
class TestRIPEMD160:
@given(msg_bytes=binary(min_size=1, max_size=200))
@settings(max_examples=3)
@example(
msg_bytes=b"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmomnopnopq"
) # https://github.com/code-423n4/2024-09-kakarot-findings/issues/50
async def test_ripemd160_should_return_correct_hash(self, cairo_run, msg_bytes):
precompile_hash = cairo_run("test__ripemd160", msg=list(msg_bytes))

Expand Down
Loading