Skip to content

Commit

Permalink
Use identical code
Browse files Browse the repository at this point in the history
  • Loading branch information
pcw109550 committed Feb 5, 2024
1 parent 3c72c74 commit 8c8fea8
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions rvsol/src/Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,24 @@ contract Step {
}

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

// 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(memPtr, preImageKey)
// mstore(add(memPtr, 0x20), caller())
// mstore(add(memPtr, 0x40), localContext_)
// // Localize the key
// 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 8c8fea8

Please sign in to comment.