@@ -141,34 +141,32 @@ contract FlashtestationRegistry is
141141 limitBytesSize (extendedRegistrationData)
142142 {
143143 (bool success , bytes memory output ) = attestationContract.verifyAndAttestOnChain {value: msg .value }(rawQuote);
144- if (! success) {
145- revert InvalidQuote (output);
146- }
144+ require (success, InvalidQuote (output));
147145
148146 // now we know the quote is valid, we can safely parse the output into the TDX report body,
149147 // from which we'll extract the data we need to register the TEE
150148 TD10ReportBody memory td10ReportBody = QuoteParser.parseV4VerifierOutput (output);
151149
152150 // Binding the tee address and extended report data to the quote
153- if (td10ReportBody.reportData.length < TD_REPORTDATA_LENGTH) {
154- revert InvalidReportDataLength (td10ReportBody.reportData.length );
155- }
151+ require (
152+ td10ReportBody.reportData.length >= TD_REPORTDATA_LENGTH,
153+ InvalidReportDataLength (td10ReportBody.reportData.length )
154+ );
156155
157156 (address teeAddress , bytes32 extendedDataReportHash ) = QuoteParser.parseReportData (td10ReportBody.reportData);
158157
159158 // Ensure that the caller is the TEE-controlled address, otherwise we have no guarantees that
160159 // the TEE-controlled address is the one that is registering the TEE
161- if (signer != teeAddress) {
162- revert SignerMustMatchTEEAddress (signer, teeAddress);
163- }
160+ require (signer == teeAddress, SignerMustMatchTEEAddress (signer, teeAddress));
164161
165162 // Verify that the extended registration data matches the hash in the TDX report data
166163 // This is to ensure that the values in extendedRegistrationData are the same as the values
167164 // in the TDX report data, which cannot be forged by the TEE-controlled address
168165 bytes32 extendedRegistrationDataHash = keccak256 (extendedRegistrationData);
169- if (extendedRegistrationDataHash != extendedDataReportHash) {
170- revert InvalidRegistrationDataHash (extendedDataReportHash, extendedRegistrationDataHash);
171- }
166+ require (
167+ extendedRegistrationDataHash == extendedDataReportHash,
168+ InvalidRegistrationDataHash (extendedDataReportHash, extendedRegistrationDataHash)
169+ );
172170
173171 bytes32 newQuoteHash = keccak256 (rawQuote);
174172 bool previouslyRegistered = checkPreviousRegistration (teeAddress, newQuoteHash);
@@ -203,9 +201,7 @@ contract FlashtestationRegistry is
203201 */
204202 function checkPreviousRegistration (address teeAddress , bytes32 newQuoteHash ) internal view returns (bool ) {
205203 bytes32 existingQuoteHash = registeredTEEs[teeAddress].quoteHash;
206- if (newQuoteHash == existingQuoteHash) {
207- revert TEEServiceAlreadyRegistered (teeAddress);
208- }
204+ require (newQuoteHash != existingQuoteHash, TEEServiceAlreadyRegistered (teeAddress));
209205
210206 // if the TEE is already registered, but we're using a different quote,
211207 // return true to signal that the TEE is already registered but is updating its quote
@@ -234,28 +230,17 @@ contract FlashtestationRegistry is
234230 // if the TEE-controlled address is not registered with the FlashtestationRegistry,
235231 // it doesn't make sense to invalidate the attestation
236232 RegisteredTEE memory registeredTEE = registeredTEEs[teeAddress];
237- if (registeredTEE.rawQuote.length == 0 ) {
238- revert TEEServiceNotRegistered (teeAddress);
239- }
240-
241- if (! registeredTEE.isValid) {
242- revert TEEServiceAlreadyInvalid (teeAddress);
243- }
233+ require (registeredTEE.rawQuote.length > 0 , TEEServiceNotRegistered (teeAddress));
234+ require (registeredTEE.isValid, TEEServiceAlreadyInvalid (teeAddress));
244235
245236 // now we check the attestation, and invalidate the TEE if it's no longer valid.
246237 // This will only happen if the DCAP Endorsements associated with the TEE's quote
247238 // have been updated
248239 (bool success ,) = attestationContract.verifyAndAttestOnChain {value: msg .value }(registeredTEE.rawQuote);
249- if (success) {
250- // if the attestation is still valid, then this function call is a no-op except for
251- // wasting the caller's gas. So we revert here to signal that the TEE is still valid.
252- // Offchain users who want to monitor for potential invalid TEEs can do so by calling
253- // this function and checking for the `TEEIsStillValid` error
254- revert TEEIsStillValid (teeAddress);
255- } else {
256- registeredTEEs[teeAddress].isValid = false ;
257- emit TEEServiceInvalidated (teeAddress);
258- }
240+ require (! success, TEEIsStillValid (teeAddress));
241+
242+ registeredTEEs[teeAddress].isValid = false ;
243+ emit TEEServiceInvalidated (teeAddress);
259244 }
260245
261246 /// @inheritdoc IFlashtestationRegistry
0 commit comments