Skip to content

Commit

Permalink
Try free memory pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
pcw109550 committed Feb 1, 2024
1 parent 9c84f40 commit 38c176c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rvsol/src/Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -774,16 +774,13 @@ contract Step {
}

function localize(preImageKey, localContext_) -> localizedKey {
// Grab the current free memory pointer to restore later.
let memPtr := mload(0x40)
let memPtr := mload(0x40) // get pointer to free memory for preimage interactions
// Store the local data key and caller next to each other in memory for hashing.
mstore(0, preImageKey)
mstore(0x20, caller())
mstore(0x40, localContext_)
mstore(memPtr, preImageKey)
mstore(add(memPtr, 0x20), caller())
mstore(add(memPtr, 0x40), localContext_)
// Localize the key
localizedKey := or(and(keccak256(0, 0x60), not(shl(248, 0xFF))), shl(248, 1))
// Restore the free memory pointer
mstore(0x40, memPtr)
localizedKey := or(and(keccak256(memPtr, 0x60), not(shl(248, 0xFF))), shl(248, 1))
}

function readPreimageValue(addr, count, localContext_) -> out {
Expand Down

0 comments on commit 38c176c

Please sign in to comment.