-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: cairo_native swaps the high and low fields of U256 compared to C…
…airo's u256 (#720) * fix u256 fields swapped * fix tests * apply suggestion * add test * remove dbg * fix gas
- Loading branch information
Showing
7 changed files
with
300 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#[starknet::interface] | ||
trait IKeccak<TContractState> { | ||
fn cairo_keccak_test(self: @TContractState) -> felt252; | ||
} | ||
|
||
#[starknet::contract] | ||
mod Keccak { | ||
use core::clone::Clone; | ||
use array::{Array, ArrayTrait}; | ||
use core::traits::Into; | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
#[abi(embed_v0)] | ||
impl Keccak of super::IKeccak<ContractState> { | ||
fn cairo_keccak_test(self: @ContractState) -> felt252 { | ||
let input : Array::<u64> = array![1,2,4,5,6,6,7,2,3,4,4,5,5,6,7,7,2]; | ||
let output = starknet::syscalls::keccak_syscall(input.span()).unwrap(); | ||
|
||
if output.low == 0x9293867273ef341e81577655f28aeade && output.high == 0xf70cba9bb86caa97b086fdfa3df602ed { | ||
panic_with_felt252('arguments swapped'); | ||
} | ||
output.low.into() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod keccak; | ||
mod secp256; | ||
mod u256; | ||
|
||
#[cfg(feature = "with-cheatcode")] | ||
mod syscalls; |
Oops, something went wrong.