Skip to content

Commit

Permalink
feat: Use chain id for replay protection (#309)
Browse files Browse the repository at this point in the history
* feat: use chain id in cosignerDigest for replay protection

* chore: forge snapshots
  • Loading branch information
alanhwu authored Oct 16, 2024
1 parent f370eab commit 8f35a85
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
199140
199172
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
231899
231968
Original file line number Diff line number Diff line change
@@ -1 +1 @@
245748
245818
Original file line number Diff line number Diff line change
@@ -1 +1 @@
303522
303592
Original file line number Diff line number Diff line change
@@ -1 +1 @@
225426
225494
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
165523
165555
Original file line number Diff line number Diff line change
@@ -1 +1 @@
151085
151117
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174834
174866
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-RevertInvalidNonce.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
44158
44191
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-ExclusiveFiller.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
169458
169490
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-InputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
169539
169571
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-OutputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
169482
169514
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-DutchDecayBounded.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1206
1193
4 changes: 2 additions & 2 deletions src/lib/V3DutchOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ library V3DutchOrderLib {
/// @notice get the digest of the cosigner data
/// @param order the V3DutchOrder
/// @param orderHash the hash of the order
function cosignerDigest(V3DutchOrder memory order, bytes32 orderHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(orderHash, abi.encode(order.cosignerData)));
function cosignerDigest(V3DutchOrder memory order, bytes32 orderHash) internal view returns (bytes32) {
return keccak256(abi.encodePacked(orderHash, block.chainid, abi.encode(order.cosignerData)));
}
}
4 changes: 2 additions & 2 deletions test/reactors/V3DutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,8 @@ contract V3DutchOrderTest is PermitSignature, DeployPermit2, BaseReactorTest {
(order,) = createAndSignDutchOrder(request);
}

function cosignOrder(bytes32 orderHash, CosignerData memory cosignerData) private pure returns (bytes memory sig) {
bytes32 msgHash = keccak256(abi.encodePacked(orderHash, abi.encode(cosignerData)));
function cosignOrder(bytes32 orderHash, CosignerData memory cosignerData) private view returns (bytes memory sig) {
bytes32 msgHash = keccak256(abi.encodePacked(orderHash, block.chainid, abi.encode(cosignerData)));
(uint8 v, bytes32 r, bytes32 s) = vm.sign(cosignerPrivateKey, msgHash);
sig = bytes.concat(r, s, bytes1(v));
}
Expand Down

0 comments on commit 8f35a85

Please sign in to comment.