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

Conversation

naure
Copy link

@naure naure commented Feb 15, 2023

With KECCAK_DEGREE=19, get_num_bits_per_absorb_lookup() is 11. In some places, 2**3**11 overflows u32.

Replace with u64. Also use faster bitshifts like Axiom’s version.

@lispc
Copy link

lispc commented Feb 16, 2023

i am curious that i sometimes use k = 20 or 28, but everything works well? 20 / 28 is even bigger than 19..

@lispc lispc merged commit e391628 into scroll-stable Feb 16, 2023
@lispc lispc deleted the fix/keccak-decode-overflow branch February 16, 2023 13:58
@naure
Copy link
Author

naure commented Feb 16, 2023

That works, there is test in #326

 // The largest imaginable value does not overflow u64.
assert_eq!(get_num_bits_per_lookup_impl(3, 32) * BIT_COUNT, 60);

@naure
Copy link
Author

naure commented Feb 16, 2023

Maybe you were using profile "bench"? Or set k but not KECCAK_DEGREE?

debug-assertions = false
overflow-checks = false

CPerezz pushed a commit to privacy-ethereum/zkevm-circuits that referenced this pull request Feb 27, 2023
### Description

With `KECCAK_DEGREE=19`, `get_num_bits_per_absorb_lookup()` is 11. In
some places, `2**3**11` overflows `u32`.

Replace with `u64`. Also use faster bitshifts like Axiom’s version.

### Issue Link

Port fix from Scroll
scroll-tech#335

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Contents

- Compute in `u64`

### How Has This Been Tested?

    cargo test -p zkevm-circuits --features test --release -- keccak

Co-authored-by: Aurélien Nicolas <info@nau.re>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants