Skip to content

Commit 6388e8f

Browse files
authored
Merge pull request #19 from datachainlab/fix-register-enclave-key-domain
Fix `RegisterEnclaveKey`'s domain Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
2 parents 074548f + 634fcf2 commit 6388e8f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

contracts/LCPOperator.sol

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ library LCPOperator {
1414
bytes32 internal constant DOMAIN_SEPARATOR_NAME = keccak256("LCPClient");
1515
bytes32 internal constant DOMAIN_SEPARATOR_VERSION = keccak256("1");
1616

17-
// domainSeparator(0, address(0))
17+
// domainSeparatorUniversal()
1818
bytes32 internal constant DOMAIN_SEPARATOR_REGISTER_ENCLAVE_KEY =
19-
0xe33d217bff42bc015bf037be8386bf5055ec6019e58e8c5e89b5c74b8225fa6a;
19+
0x7fd21c2453e80741907e7ff11fd62ae1daa34c6fc0c2eced821f1c1d3fe88a4c;
2020
ChainType internal constant CHAIN_TYPE_EVM = ChainType.wrap(1);
2121
// chainTypeSalt(CHAIN_TYPE_EVM, hex"")
2222
bytes32 internal constant CHAIN_TYPE_EVM_SALT = keccak256(abi.encodePacked(CHAIN_TYPE_EVM, hex""));
@@ -25,7 +25,15 @@ library LCPOperator {
2525
return keccak256(abi.encodePacked(chainType, args));
2626
}
2727

28-
function domainSeparator(uint256 chainId, address verifyingContract) internal pure returns (bytes32) {
28+
function domainSeparatorUniversal() internal pure returns (bytes32) {
29+
return keccak256(
30+
abi.encode(
31+
TYPEHASH_DOMAIN_SEPARATOR, DOMAIN_SEPARATOR_NAME, DOMAIN_SEPARATOR_VERSION, 0, address(0), bytes32(0)
32+
)
33+
);
34+
}
35+
36+
function domainSeparatorEVM(uint256 chainId, address verifyingContract) internal pure returns (bytes32) {
2937
return keccak256(
3038
abi.encode(
3139
TYPEHASH_DOMAIN_SEPARATOR,
@@ -69,7 +77,7 @@ library LCPOperator {
6977
) internal pure returns (bytes memory) {
7078
return abi.encodePacked(
7179
hex"1901",
72-
domainSeparator(chainId, verifyingContract),
80+
domainSeparatorEVM(chainId, verifyingContract),
7381
keccak256(
7482
abi.encode(
7583
TYPEHASH_UPDATE_OPERATORS,

test/LCPClientOperator.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ contract LCPClientOperatorTest is BasicTest {
3333
}
3434

3535
function testPreComputationValues() public pure {
36-
assertEq(LCPOperator.domainSeparator(0, address(0)), LCPOperator.DOMAIN_SEPARATOR_REGISTER_ENCLAVE_KEY);
36+
assertEq(LCPOperator.domainSeparatorUniversal(), LCPOperator.DOMAIN_SEPARATOR_REGISTER_ENCLAVE_KEY);
3737
assertEq(LCPOperator.chainTypeSalt(LCPOperator.CHAIN_TYPE_EVM, hex""), LCPOperator.CHAIN_TYPE_EVM_SALT);
3838
}
3939

0 commit comments

Comments
 (0)