Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions contracts/protocol/switchboard/MessageSwitchboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ contract MessageSwitchboard is SwitchboardBase, ReentrancyGuard {
function attest(bytes32 payloadId_, bytes32 digest_, bytes calldata proof_) public {
// Recover watcher from signature
address watcher = _recoverSigner(
keccak256(abi.encodePacked(toBytes32Format(address(this)), chainSlug, payloadId_, digest_)),
keccak256(
abi.encodePacked(toBytes32Format(address(this)), chainSlug, payloadId_, digest_)
),
proof_
);

Expand Down Expand Up @@ -431,9 +433,9 @@ contract MessageSwitchboard is SwitchboardBase, ReentrancyGuard {
require(packed.length == 36, "Invalid packed length");

assembly {
// Read first 32 bytes of data (contains uint32 in rightmost 4 bytes)
// Read first 32 bytes of data (contains uint32 in leftmost 4 bytes)
let firstWord := mload(add(packed, 32))
// Extract uint32 from rightmost 4 bytes (shift right by 224 bits = 28 bytes)
// Extract uint32 from leftmost 4 bytes (shift right by 224 bits = 28 bytes)
siblingChainSlug := shr(224, firstWord)

// Read next 32 bytes starting at offset 36 (skip 4 bytes for uint32)
Expand Down Expand Up @@ -687,14 +689,16 @@ contract MessageSwitchboard is SwitchboardBase, ReentrancyGuard {
bytes32 oldTransmitterBytes32 = toBytes32Format(oldTransmitter_);
digestParams_.transmitter = oldTransmitterBytes32;
bytes32 oldDigest = createDigest(digestParams_);

if (payloadIdToDigest[digestParams_.payloadId] != oldDigest) revert InvalidDigest();

digestParams_.transmitter = toBytes32Format(newTransmitter_);
bytes32 newDigest = createDigest(digestParams_);

address watcher = _recoverSigner(
keccak256(abi.encodePacked(toBytes32Format(address(this)), chainSlug, oldDigest, newDigest)),
keccak256(
abi.encodePacked(toBytes32Format(address(this)), chainSlug, oldDigest, newDigest)
),
signature_
);
if (!_hasRole(WATCHER_ROLE, watcher)) revert WatcherNotFound();
Expand Down