@@ -19,14 +19,6 @@ import {ACLChecks} from "./shared/ACLChecks.sol";
1919 * @dev The contract uses EIP712UpgradeableCrossChain for cryptographic operations.
2020 */
2121contract InputVerifier is UUPSUpgradeableEmptyProxy , Ownable2StepUpgradeable , EIP712UpgradeableCrossChain , ACLChecks {
22- /// @notice Emitted when a signer is added.
23- /// @param signer The address of the signer that was added.
24- event SignerAdded (address indexed signer );
25-
26- /// @notice Emitted when a signer is removed.
27- /// @param signer The address of the signer that was removed.
28- event SignerRemoved (address indexed signer );
29-
3022 /// @notice Returned if the deserializing of the input proof fails.
3123 error DeserializingInputProofFail ();
3224
@@ -45,18 +37,6 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
4537 /// @notice Returned if the handle version is not the correct one.
4638 error InvalidHandleVersion ();
4739
48- /// @notice Returned if signer is null.
49- error SignerNull ();
50-
51- /// @notice Returned if signer is already registered.
52- error AlreadySigner ();
53-
54- /// @notice Returned if no signer is already registered.
55- error AtLeastOneSignerIsRequired ();
56-
57- /// @notice Returned if not a registered signer.
58- error NotASigner ();
59-
6040 /// @notice Returned in case signerRecovered is an invalid signer.
6141 error InvalidSigner (address signerRecovered );
6242
@@ -165,8 +145,8 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
165145 * @notice Initializes the contract.
166146 * @param verifyingContractSource InputVerification contract address from Gateway chain.
167147 * @param chainIDSource chainID of Gateway chain.
168- * @param initialContextId Initial active context ID.
169- * @param initialContextSigners Initial list of signers for the active context ID .
148+ * @param initialCoprocessorContextId Initial active coprocessor context ID.
149+ * @param initialCoprocessorSigners Initial list of signers for the active coprocessor context .
170150 */
171151 /// @custom:oz-upgrades-validate-as-initializer
172152 function initializeFromEmptyProxy (
@@ -195,7 +175,9 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
195175 }
196176
197177 /**
198- * @notice Re-initializes the contract from V3.
178+ * @notice Re-initializes the contract from V1.
179+ * @param initialCoprocessorContextId Initial active coprocessor context ID.
180+ * @param initialCoprocessorSigners Initial list of signers for the active coprocessor context.
199181 */
200182 /// @custom:oz-upgrades-unsafe-allow missing-initializer-call
201183 /// @custom:oz-upgrades-validate-as-initializer
@@ -271,16 +253,16 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
271253 /// @dev bundleCiphertext is compressedPackedCT+ZKPOK
272254 /// inputHandle is keccak256(keccak256(bundleCiphertext)+index)[0:20] + index[21] + chainId[22:29] + type[30] + version[31]
273255 /// and inputProof is numHandles + numSigners + coprocessorContextId + handles + coprocessorSignatures (1 + 1 + 1 + 32*numHandles + 65*numSigners + extraData bytes)
274-
275- // uint256 inputProofLen = inputProof.length ;
276- if (inputProof. length == 0 ) revert EmptyInputProof ();
256+ if (inputProof. length == 0 ) {
257+ revert EmptyInputProof () ;
258+ }
277259 uint256 numHandles = uint256 (uint8 (inputProof[0 ]));
278260 uint256 numSigners = uint256 (uint8 (inputProof[1 ]));
279261
280262 // Extract the coprocessor context ID from inputProof.
281263 uint256 coprocessorContextId;
282264 assembly {
283- coprocessorContextId := mload (add (inputProof, 0x22 )) // 0x20 offset for array prefix + 2 bytes header
265+ coprocessorContextId := mload (add (inputProof, 0x22 )) // 0x20 offset for array prefix + 2 bytes for numHandles and numSigners
284266 }
285267
286268 /// @dev This checks in particular that the list is non-empty.
@@ -289,20 +271,22 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
289271 /// @dev The extraData is the rest of the inputProof bytes after:
290272 /// + numHandles (1 byte)
291273 /// + numSigners (1 byte)
292- /// + coprocesorContextId (32 bytes)
274+ /// + coprocessorContextId (32 bytes)
293275 /// + handles (32 bytes each)
294276 /// + coprocessorSignatures (65 bytes each)
295277 uint256 extraDataOffset = 34 + 32 * numHandles + 65 * numSigners;
296278
297279 /// @dev Check that the inputProof is long enough to contain at least the numHandles + numSigners + handles + coprocessorSignatures
298- if (inputProof.length < extraDataOffset) revert DeserializingInputProofFail ();
280+ if (inputProof.length < extraDataOffset) {
281+ revert DeserializingInputProofFail ();
282+ }
299283
300284 /// @dev Deserialize handle and check that they are from the correct version.
301285 bytes32 [] memory listHandles = new bytes32 [](numHandles);
302286 for (uint256 i = 0 ; i < numHandles; i++ ) {
303287 bytes32 element;
304288 assembly {
305- // 32 (array length) + 2 (numSigners and numHandles) + 32 (coprocessorContextId) + 32* i
289+ // 32 bytes (array length) + 2 bytes (numSigners and numHandles) + 32 bytes (coprocessorContextId) + 32 bytes * i
306290 element := mload (add (inputProof, add (66 , mul (i, 32 ))))
307291 }
308292 /// @dev Check that all handles are from the correct version.
@@ -364,9 +348,9 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
364348 }
365349
366350 /**
367- * @notice Get the threshold for signature .
351+ * @notice Get the threshold for required signatures .
368352 * @param coprocessorContextId The coprocessor context ID of the signer addresses to get the threshold from.
369- * @return threshold Threshold for signature verification.
353+ * @return threshold Threshold for number of signatures verification.
370354 */
371355 function getThreshold (uint256 coprocessorContextId ) public view virtual returns (uint256 ) {
372356 address [] memory coprocessorSigners = getCoprocessorSigners (coprocessorContextId);
@@ -400,15 +384,15 @@ contract InputVerifier is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, EI
400384 function isCoprocessorContextActiveOrSuspended (uint256 coprocessorContextId ) public view virtual returns (bool ) {
401385 InputVerifierStorage storage $ = _getInputVerifierStorage ();
402386 if (
403- $.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Suspended ||
404- $.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Active
387+ $.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Active ||
388+ $.coprocessorContextStates[coprocessorContextId] == CoprocessorContextState.Suspended
405389 ) {
406390 return true ;
407391 }
408392 revert InvalidContextId (coprocessorContextId);
409393 }
410394
411- function addNewContextAndSuspendOldOne (
395+ function addNewContextAndSuspendCurrentOne (
412396 uint256 newContextId ,
413397 address [] calldata newContextSigners
414398 ) public virtual onlyACLOwner {
0 commit comments