Skip to content

Commit 3b928b7

Browse files
committed
chore(gateway-contracts): remove chainId from add ciphertext hash
1 parent 0244708 commit 3b928b7

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

gateway-contracts/contracts/CiphertextCommits.sol

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ contract CiphertextCommits is
113113

114114
// Compute the hash of the ciphertext material to differentiate different ciphertext
115115
// material additions
116-
bytes32 addCiphertextHash = keccak256(
117-
abi.encode(ctHandle, chainId, keyId, ciphertextDigest, snsCiphertextDigest)
118-
);
116+
// Note that chainId is not included in the hash because it is already contained in the ctHandle.
117+
bytes32 addCiphertextHash = keccak256(abi.encode(ctHandle, keyId, ciphertextDigest, snsCiphertextDigest));
119118

120119
CiphertextCommitsStorage storage $ = _getCiphertextCommitsStorage();
121120

@@ -139,11 +138,7 @@ contract CiphertextCommits is
139138
// Only accept coprocessor transaction senders from the same context
140139
COPROCESSOR_CONTEXTS.checkIsCoprocessorTxSenderFromContext(contextId, msg.sender);
141140

142-
/**
143-
* @dev Check if the coprocessor transaction sender has already added the ciphertext handle.
144-
* Note that a coprocessor transaction sender cannot add the same ciphertext material on
145-
* two different host chains.
146-
*/
141+
// Check if the coprocessor transaction sender has already added the ciphertext handle.
147142
if ($._alreadyAddedCoprocessorTxSenders[ctHandle][msg.sender]) {
148143
revert CoprocessorAlreadyAdded(ctHandle, msg.sender);
149144
}
@@ -154,11 +149,9 @@ contract CiphertextCommits is
154149
// TODO: Re-enable this check once keys are generated through the Gateway
155150
// KMS_MANAGEMENT.checkCurrentKeyId(keyId);
156151

157-
/**
158-
* @dev The addCiphertextHash is the hash of all received input arguments which means that multiple
159-
* Coprocessors can only have a consensus on a ciphertext material with the same information.
160-
* This hash is used to track the addition consensus on the received ciphertext material.
161-
*/
152+
// The addCiphertextHash is the hash of all received input arguments which means that multiple
153+
// coprocessors can only have a consensus on a ciphertext material with the same information.
154+
// This hash is used to track the addition consensus on the received ciphertext material.
162155
$._addCiphertextHashCounters[addCiphertextHash]++;
163156

164157
$._alreadyAddedCoprocessorTxSenders[ctHandle][msg.sender] = true;

0 commit comments

Comments
 (0)