We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello!
reverse endianness of u64 is useful in many cases when dealing with keccak
I wanted to implement it based off this https://github.com/starkware-libs/cairo-lang/blob/3a32740d0a743af6f4bfe227d1b5ecab0fc2884b/src/starkware/cairo/common/uint256.cairo#L464-L510
with 3 steps instead of 4
fn u64_byte_reverse(word: u64) -> u64 { let word: u128 = word.into(); let word = (word & 0x00ff00ff00ff00ff00ff00ff00ff00ff) * (65535) + word; let word = (word & 0x00ffff0000ffff0000ffff0000ffff00) * (4294967295) + word; let word = (word & 0x0fffffffffffffff0000000000000000) * (18446744073709551615) + word; return (word / (72057594037927936)).try_into().unwrap(); }
the problem is that & is not implemented on felt252 and u128 isn't large enough and gives mul overflow
&
is it possible to add a u64_byte_reverse in the integer core lib ?
thanks!!
The text was updated successfully, but these errors were encountered:
we should add these for additional types - but currently you can rather efficiently implement by:
fn u64_byte_reverse(word: u64) -> u64 { (u128_byte_reverse(word.into()) / 0x10000000000000000).try_into().unwrap() }
Sorry, something went wrong.
No branches or pull requests
Hello!
reverse endianness of u64 is useful in many cases when dealing with keccak
I wanted to implement it based off this https://github.com/starkware-libs/cairo-lang/blob/3a32740d0a743af6f4bfe227d1b5ecab0fc2884b/src/starkware/cairo/common/uint256.cairo#L464-L510
with 3 steps instead of 4
the problem is that
&
is not implemented on felt252 and u128 isn't large enough and gives mul overflowis it possible to add a u64_byte_reverse in the integer core lib ?
thanks!!
The text was updated successfully, but these errors were encountered: