Skip to content

Commit 9e377a8

Browse files
committed
disputes: use joinSignature to send r,s,v over the wire and parse signature in that order from the DisputeManager
1 parent c6aa09d commit 9e377a8

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

contracts/disputes/DisputeManager.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ contract DisputeManager is Managed, IDisputeManager {
3939
uint256 private constant ATTESTATION_SIZE_BYTES = 161;
4040
uint256 private constant RECEIPT_SIZE_BYTES = 96;
4141

42-
uint256 private constant SIG_V_LENGTH = 1;
4342
uint256 private constant SIG_R_LENGTH = 32;
44-
uint256 private constant SIG_V_OFFSET = RECEIPT_SIZE_BYTES;
45-
uint256 private constant SIG_R_OFFSET = RECEIPT_SIZE_BYTES + SIG_V_LENGTH;
46-
uint256 private constant SIG_S_OFFSET = RECEIPT_SIZE_BYTES + SIG_V_LENGTH + SIG_R_LENGTH;
43+
uint256 private constant SIG_S_LENGTH = 32;
44+
uint256 private constant SIG_R_OFFSET = RECEIPT_SIZE_BYTES;
45+
uint256 private constant SIG_S_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH;
46+
uint256 private constant SIG_V_OFFSET = RECEIPT_SIZE_BYTES + SIG_R_LENGTH + SIG_S_LENGTH;
4747

4848
uint256 private constant UINT8_BYTE_LENGTH = 1;
4949
uint256 private constant BYTES32_BYTE_LENGTH = 32;
@@ -771,11 +771,11 @@ contract DisputeManager is Managed, IDisputeManager {
771771

772772
// Decode signature
773773
// Signature is expected to be in the order defined in the Attestation struct
774-
uint8 v = _toUint8(_data, SIG_V_OFFSET);
775774
bytes32 r = _toBytes32(_data, SIG_R_OFFSET);
776775
bytes32 s = _toBytes32(_data, SIG_S_OFFSET);
776+
uint8 v = _toUint8(_data, SIG_V_OFFSET);
777777

778-
return Attestation(requestCID, responseCID, subgraphDeploymentID, v, r, s);
778+
return Attestation(requestCID, responseCID, subgraphDeploymentID, r, s, v);
779779
}
780780

781781
/**

contracts/disputes/IDisputeManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ interface IDisputeManager {
2828
bytes32 requestCID;
2929
bytes32 responseCID;
3030
bytes32 subgraphDeploymentID;
31-
uint8 v;
3231
bytes32 r;
3332
bytes32 s;
33+
uint8 v;
3434
}
3535

3636
// -- Configuration --

test/disputes/query.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from '../lib/testHelpers'
2222

2323
const { AddressZero, HashZero } = constants
24-
const { defaultAbiCoder: abi, arrayify, concat, hexlify, solidityKeccak256 } = utils
24+
const { defaultAbiCoder: abi, arrayify, concat, hexlify, solidityKeccak256, joinSignature } = utils
2525

2626
const MAX_PPM = 1000000
2727
const NON_EXISTING_DISPUTE_ID = randomHexBytes()
@@ -58,11 +58,7 @@ function encodeAttestation(attestation: Attestation): string {
5858
[attestation.requestCID, attestation.responseCID, attestation.subgraphDeploymentID],
5959
),
6060
)
61-
const sig = concat([
62-
arrayify(hexlify(attestation.v)),
63-
arrayify(attestation.r),
64-
arrayify(attestation.s),
65-
])
61+
const sig = joinSignature(attestation)
6662
return hexlify(concat([data, sig]))
6763
}
6864

0 commit comments

Comments
 (0)