mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 22:03:07 +00:00
Change endianness within generate_keccak_general
This commit is contained in:
parent
0146f48a87
commit
0529fa06a5
@ -127,7 +127,12 @@ pub(crate) fn generate_keccak_general<F: Field>(
|
||||
log::debug!("Hashing {:?}", input);
|
||||
|
||||
let hash = keccak(&input);
|
||||
let log_push = stack_push_log_and_fill(state, &mut row, hash.into_uint())?;
|
||||
let val_u64s: [u64; 4] =
|
||||
core::array::from_fn(|i| u64::from_le_bytes(core::array::from_fn(|j| hash.0[i * 8 + j])));
|
||||
let hash_int = U256(val_u64s);
|
||||
|
||||
let mut log_push = stack_push_log_and_fill(state, &mut row, hash_int)?;
|
||||
log_push.value = hash.into_uint();
|
||||
|
||||
keccak_sponge_log(state, base_address, input);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use ethereum_types::{BigEndianHash, H256, U256};
|
||||
use ethereum_types::U256;
|
||||
use plonky2::field::types::Field;
|
||||
|
||||
use crate::cpu::columns::CpuColumnsView;
|
||||
@ -135,18 +135,9 @@ pub(crate) fn mem_write_gp_log_and_fill<F: Field>(
|
||||
channel.addr_context = F::from_canonical_usize(address.context);
|
||||
channel.addr_segment = F::from_canonical_usize(address.segment);
|
||||
channel.addr_virtual = F::from_canonical_usize(address.virt);
|
||||
if row.is_keccak_sponge.is_one() {
|
||||
// Retrieve hash value as it was computed and store the values in memory the same way the kernel hash is stored.
|
||||
let val_h256 = H256::from_uint(&val).0;
|
||||
let val_u32s: [u32; 8] = core::array::from_fn(|i| {
|
||||
u32::from_le_bytes(core::array::from_fn(|j| val_h256[i * 4 + j]))
|
||||
});
|
||||
channel.value = val_u32s.map(F::from_canonical_u32);
|
||||
} else {
|
||||
for (i, limb) in val_limbs.into_iter().enumerate() {
|
||||
channel.value[2 * i] = F::from_canonical_u32(limb as u32);
|
||||
channel.value[2 * i + 1] = F::from_canonical_u32((limb >> 32) as u32);
|
||||
}
|
||||
for (i, limb) in val_limbs.into_iter().enumerate() {
|
||||
channel.value[2 * i] = F::from_canonical_u32(limb as u32);
|
||||
channel.value[2 * i + 1] = F::from_canonical_u32((limb >> 32) as u32);
|
||||
}
|
||||
|
||||
op
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user