Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 19769652 | 206 days ago | IN | 0 ETH | 0.03058098 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
EnclaveVerifier
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; import { RAVE } from "rave/RAVE.sol"; import { X509Verifier } from "rave/X509Verifier.sol"; import { IEnclaveVerifier } from "puffer/interface/IEnclaveVerifier.sol"; import { RaveEvidence } from "puffer/struct/RaveEvidence.sol"; import { AccessManaged } from "openzeppelin/access/manager/AccessManaged.sol"; import { InvalidAddress } from "puffer/Errors.sol"; /** * @title EnclaveVerifier * @author Puffer Finance * @custom:security-contact [email protected] */ contract EnclaveVerifier is IEnclaveVerifier, AccessManaged, RAVE { /** * @dev RSA Public key for Intel: https://api.portal.trustedservices.intel.com/content/documentation.html */ bytes internal constant _INTEL_RSA_MODULUS = hex"9F3C647EB5773CBB512D2732C0D7415EBB55A0FA9EDE2E649199E6821DB910D53177370977466A6A5E4786CCD2DDEBD4149D6A2F6325529DD10CC98737B0779C1A07E29C47A1AE004948476C489F45A5A15D7AC8ECC6ACC645ADB43D87679DF59C093BC5A2E9696C5478541B979E754B573914BE55D32FF4C09DDF27219934CD990527B3F92ED78FBF29246ABECB71240EF39C2D7107B447545A7FFB10EB060A68A98580219E36910952683892D6A5E2A80803193E407531404E36B315623799AA825074409754A2DFE8F5AFD5FE631E1FC2AF3808906F28A790D9DD9FE060939B125790C5805D037DF56A99531B96DE69DE33ED226CC1207D1042B5C9AB7F404FC711C0FE4769FB9578B1DC0EC469EA1A25E0FF9914886EF2699B235BB4847DD6FF40B606E6170793C2FB98B314587F9CFD257362DFEAB10B3BD2D97673A1A4BD44C453AAF47FC1F2D3D0F384F74A06F89C089F0DA6CDB7FCEEE8C9821A8E54F25C0416D18C46839A5F8012FBDD3DC74D256279ADC2C0D55AFF6F0622425D1B"; bytes internal constant _INTEL_EXPONENT = hex"010001"; /** * @notice Freshness number of blocks */ uint256 public immutable FRESHNESS_BLOCKS; /** * @dev Mapping from keccak'd leaf x509 to RSA pub key components * leafHash -> pubKey */ mapping(bytes32 leafHash => RSAPubKey pubKey) internal _validLeafX509s; constructor(uint256 freshnessBlocks, address accessManager) AccessManaged(accessManager) { if (address(accessManager) == address(0)) { revert InvalidAddress(); } FRESHNESS_BLOCKS = freshnessBlocks; } /** * @inheritdoc IEnclaveVerifier */ function getIntelRootCAPubKey() external pure returns (RSAPubKey memory) { return RSAPubKey({ modulus: _INTEL_RSA_MODULUS, exponent: _INTEL_EXPONENT }); } /** * @inheritdoc IEnclaveVerifier */ function addLeafX509(bytes calldata leafX509Cert) external { (bytes memory leafCertModulus, bytes memory leafCertExponent) = X509Verifier.verifySignedX509(leafX509Cert, _INTEL_RSA_MODULUS, _INTEL_EXPONENT); bytes32 hashedCert = keccak256(leafX509Cert); _validLeafX509s[hashedCert] = RSAPubKey({ modulus: leafCertModulus, exponent: leafCertExponent }); emit AddedPubKey(hashedCert); } /** * @notice Removes a whitelisted leaf x509 RSA public key */ function removeLeafX509(bytes32 hashedCert) external restricted { delete _validLeafX509s[hashedCert].modulus; delete _validLeafX509s[hashedCert].exponent; emit RemovedPubKey(hashedCert); } /** * @inheritdoc IEnclaveVerifier */ function verifyEvidence( uint256 blockNumber, bytes32 raveCommitment, RaveEvidence calldata evidence, bytes32 mrenclave, bytes32 mrsigner ) external view returns (bool) { // Check for freshness if ((block.number - blockNumber) > FRESHNESS_BLOCKS) { revert StaleEvidence(); } RSAPubKey memory leafX509 = _validLeafX509s[evidence.leafX509CertDigest]; // Recover a remote attestation payload if everything is valid bytes memory recoveredPayload = verifyRemoteAttestation({ report: evidence.report, sig: evidence.signature, signingMod: leafX509.modulus, signingExp: leafX509.exponent, mrenclave: mrenclave, mrsigner: mrsigner }); // Remote attestation payloads are expected to be in the form (32B_Commitment || 32B_BlockHash) bytes memory expectedPayload = abi.encode(raveCommitment, blockhash(blockNumber)); // Compare with the expected payload return (keccak256(expectedPayload) == keccak256(recoveredPayload)); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; import { X509Verifier } from "rave/X509Verifier.sol"; import { JSONBuilder } from "rave/JSONBuilder.sol"; import { BytesUtils } from "ens-contracts/dnssec-oracle/BytesUtils.sol"; import { Base64 } from "openzeppelin/utils/Base64.sol"; import { RAVEBase } from "rave/RAVEBase.sol"; /** * @title RAVE * @author PufferFinance * @custom:security-contact [email protected] * @notice RAVe is a smart contract for verifying Remote Attestation evidence. */ contract RAVE is RAVEBase, JSONBuilder { using BytesUtils for *; constructor() { } /** * @inheritdoc RAVEBase */ function verifyRemoteAttestation( bytes calldata report, bytes calldata sig, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) public view override returns (bytes memory payload) { // Decode the encoded report JSON values to a Values struct and reconstruct the original JSON string (Values memory reportValues, bytes memory reportBytes) = _buildReportBytes(report); // Verify the report was signed by the SigningPK if (!verifyReportSignature(reportBytes, sig, signingMod, signingExp)) { revert BadReportSignature(); } // Verify the report's contents match the expected payload = _verifyReportContents(reportValues, mrenclave, mrsigner); } /** * @inheritdoc RAVEBase */ function rave( bytes calldata report, bytes calldata sig, bytes memory leafX509Cert, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) public view override returns (bytes memory payload) { // Verify the leafX509Cert was signed with signingMod and signingExp (bytes memory leafCertModulus, bytes memory leafCertExponent) = X509Verifier.verifySignedX509(leafX509Cert, signingMod, signingExp); // Verify report has expected fields then extract its payload payload = verifyRemoteAttestation(report, sig, leafCertModulus, leafCertExponent, mrenclave, mrsigner); } /* * @dev Builds the JSON report string from the abi-encoded `encodedReportValues`. The assumption is that `isvEnclaveQuoteBody` value was previously base64 decoded off-chain and needs to be base64 encoded to produce the message-to-be-signed. * @param encodedReportValues The values from the attestation evidence report JSON from IAS. * @return reportValues The JSON values as a Values struct for easier processing downstream * @return reportBytes The exact message-to-be-signed */ function _buildReportBytes(bytes memory encodedReportValues) internal view returns (Values memory reportValues, bytes memory reportBytes) { // Decode the report JSON values ( bytes memory id, bytes memory timestamp, bytes memory version, bytes memory epidPseudonym, bytes memory advisoryURL, bytes memory advisoryIDs, bytes memory isvEnclaveQuoteStatus, bytes memory isvEnclaveQuoteBody ) = abi.decode(encodedReportValues, (bytes, bytes, bytes, bytes, bytes, bytes, bytes, bytes)); // Assumes the quote body was already decoded off-chain bytes memory encBody = bytes(Base64.encode(isvEnclaveQuoteBody)); // Pack values to struct reportValues = JSONBuilder.Values( id, timestamp, version, epidPseudonym, advisoryURL, advisoryIDs, isvEnclaveQuoteStatus, encBody ); // Reconstruct the JSON report that was signed reportBytes = bytes(buildJSON(reportValues)); // Pass on the decoded value for later processing reportValues.isvEnclaveQuoteBody = isvEnclaveQuoteBody; } /* * @dev Parses a report, verifies the fields are correctly set, and extracts the enclave' 64 byte commitment. * @param reportValues The values from the attestation evidence report JSON from IAS. * @param mrenclave The expected enclave measurement. * @param mrsigner The expected enclave signer. * @return The 64 byte payload if the mrenclave and mrsigner values were correctly set. */ function _verifyReportContents(Values memory reportValues, bytes32 mrenclave, bytes32 mrsigner) internal pure returns (bytes memory payload) { // check enclave status bytes32 status = keccak256(reportValues.isvEnclaveQuoteStatus); require(status == OK_STATUS || status == HARDENING_STATUS, "bad isvEnclaveQuoteStatus"); // quote body is already base64 decoded bytes memory quoteBody = reportValues.isvEnclaveQuoteBody; assert(quoteBody.length == QUOTE_BODY_LENGTH); // Verify report's MRENCLAVE matches the expected bytes32 mre = quoteBody.readBytes32(MRENCLAVE_OFFSET); require(mre == mrenclave); // Verify report's MRSIGNER matches the expected bytes32 mrs = quoteBody.readBytes32(MRSIGNER_OFFSET); require(mrs == mrsigner); // Verify report's <= 64B payload matches the expected payload = quoteBody.substring(PAYLOAD_OFFSET, PAYLOAD_SIZE); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; import { Asn1Decode, NodePtr } from "rave/ASN1Decode.sol"; import { RSAVerify } from "ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol"; import { BytesUtils } from "ens-contracts/dnssec-oracle/BytesUtils.sol"; library X509Verifier { using Asn1Decode for bytes; using BytesUtils for bytes; /* * @dev Verifies an x509 certificate was signed (RSASHA256) by the supplied public key. * @param childCertBody The DER-encoded body (preimage) of the x509 child certificate * @param certSig The RSASHA256 signature of the childCertBody * @param parentMod The modulus of the parent certificate's public RSA key * @param parentExp The exponent of the parent certificate's public RSA key * @return Returns true if this childCertBody was signed by the parent's RSA private key */ function verifyChildCert( bytes memory childCertBody, bytes memory certSig, bytes memory parentMod, bytes memory parentExp ) public view returns (bool) { // Recover the digest using parent's public key (bool success, bytes memory res) = RSAVerify.rsarecover(parentMod, parentExp, certSig); // Digest is last 32 bytes of res bytes32 recovered = res.readBytes32(res.length - 32); return success && recovered == sha256(childCertBody); } /* * @dev specs: https://www.ietf.org/rfc/rfc5280.txt * @dev Certificate ::= SEQUENCE { * @dev tbsCertificate TBSCertificate, * @dev signatureAlgorithm AlgorithmIdentifier, * @dev signatureValue BIT STRING } * @dev * @dev TBSCertificate ::= SEQUENCE { * @dev version [0] EXPLICIT Version DEFAULT v1, * @dev serialNumber CertificateSerialNumber, * @dev signature AlgorithmIdentifier, * @dev issuer Name, * @dev validity Validity, * @dev subject Name, * @dev subjectPublicKeyInfo SubjectPublicKeyInfo, * @dev issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, * @dev -- If present, version MUST be v2 or v3 * @dev subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, * @dev -- If present, version MUST be v2 or v3 * @dev extensions [3] EXPLICIT Extensions OPTIONAL * @dev -- If present, version MUST be v3 * @dev } * @dev Verifies an x509 certificate was signed (RSASHA256) by the parent's * @dev supplied modulus and exponent, then returns the child x509's modulus and exponent. * @param cert The DER-encoded signed x509 certificate. * @param parentMod The parent RSA modulus. * @param parentExp The parent RSA exponent. * @return Returns the RSA modulus and exponent of the signed x509 certificate iff it was signed by the parent. */ function verifySignedX509(bytes memory cert, bytes memory parentMod, bytes memory parentExp) public view returns (bytes memory, bytes memory) { // Pointer to top level asn1 object: Sequence{tbsCertificate, signatureAlgorithm, signatureValue} uint256 root = cert.root(); // Traverse to first in sequence (the tbsCertificate) uint256 tbsPtr = cert.firstChildOf(root); // Extracts the TBSCerificate (what is used as input to RSA-SHA256) bytes memory certBody = cert.allBytesAt(tbsPtr); // Top level traverse to signatureAlgorithm uint256 sigAlgPtr = cert.nextSiblingOf(tbsPtr); // Top level traverse to signatureValue uint256 sigPtr = cert.nextSiblingOf(sigAlgPtr); // Extracts the signed certificate body bytes memory signature = cert.bytesAt(sigPtr); // Verify the parent signed the certBody require(verifyChildCert(certBody, signature, parentMod, parentExp), "verifyChildCert fail"); // ---------------- // Begin traversing the tbsCertificate // ---------------- // Traverse to first child of tbsCertificate uint256 ptr = cert.firstChildOf(tbsPtr); // Account for v1 vs v3 if (cert[NodePtr.ixs(ptr)] == 0xa0) { ptr = cert.nextSiblingOf(ptr); } // Extract serialNumber (CertificateSerialNumber) // uint256 serialNumber = uint160(cert.uintAt(ptr)); // Skip the next 3 fields (signature, issuer, validity, subject) ptr = cert.nextSiblingOf(ptr); // point to signature ptr = cert.nextSiblingOf(ptr); // point to issuer ptr = cert.nextSiblingOf(ptr); // point to validity // Arrive at the validity field // todo verifiy validity timestamps // uint256 validityPtr = ptr; // bytes memory validNotBefore = cert.bytesAt(validityPtr); // console.logBytes(validNotBefore); // uint40 validNotBefore = uint40(toTimestamp(cert.bytesAt(validityPtr))); // console.log("validNotBefore: %s", validNotBefore); // validityPtr = cert.nextSiblingOf(validityPtr); // bytes memory validNotAfter = cert.bytesAt(validityPtr); // console.logBytes(validNotAfter); // uint40 validNotAfter = uint40(toTimestamp(cert.bytesAt(validityPtr))); // console.log("validNotAfter: %s", validNotAfter); // Traverse until the subjectPublicKeyInfo field ptr = cert.nextSiblingOf(ptr); // point to subject ptr = cert.nextSiblingOf(ptr); // point to subjectPublicKeyInfo // Enter subjectPublicKeyInfo ptr = cert.firstChildOf(ptr); // point to subjectPublicKeyInfo.algorithm ptr = cert.nextSiblingOf(ptr); // point to subjectPublicKeyInfo.subjectPublicKey // Extract DER-encoded RSA public key bytes memory pubKey = cert.bitstringAt(ptr); // Extract RSA modulus uint256 pkPtr = pubKey.root(); pkPtr = pubKey.firstChildOf(pkPtr); bytes memory modulus = pubKey.bytesAt(pkPtr); // Extract RSA exponent pkPtr = pubKey.nextSiblingOf(pkPtr); bytes memory exponent = pubKey.bytesAt(pkPtr); return (modulus, exponent); } /* * @dev Verifies the x509 certificate hasn't expired * @param certBody The DER-encoded body (preimage) of the x509 * @return Returns ... */ function notExpired(bytes calldata certBody) public view returns (bool) { // TODO return true; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; import { RaveEvidence } from "puffer/struct/RaveEvidence.sol"; /** * @title IEnclaveVerifier interface * @author Puffer Finance * @custom:security-contact [email protected] */ interface IEnclaveVerifier { struct RSAPubKey { bytes modulus; bytes exponent; } /** * @notice Thrown if the Evidence that we're trying to verify is stale * Evidence should be submitted for the recent block < `FRESHNESS_BLOCKS` * @dev Signature "0x5d4ad9a9" */ error StaleEvidence(); /** * @notice Emitted when the `pubKeyHash` is added to valid pubKeys * @dev Signature "0x13b85b042d2bb270091da7111e3b3cc407f6b86c85882cf48ae94123cae22b17" */ event AddedPubKey(bytes32 indexed pubKeyHash); /** * @notice Emitted when the `pubKeyHash` is removed from valid pubKeys * @dev Signature "0x0ebd07953ae533bded7d9b0715fa49e0a0ed0a6cef4638a685737ffef8b86254" */ event RemovedPubKey(bytes32 indexed pubKeyHash); /** * @notice Getter for intelRootCAPubKey */ function getIntelRootCAPubKey() external pure returns (RSAPubKey memory); /** * @notice Adds a leaf x509 RSA public key if the x509 was signed by Intel's root CA * @param leafX509Cert certificate */ function addLeafX509(bytes calldata leafX509Cert) external; /** * @notice Verifies remote attestation evidence: the report contains the expected MRENCLAVE/MRSIGNER values, a valid TCB status, and was signed by an Intel-issued x509 certificate. The report will contain a 64B payload in the form (32B_Commitment || 32B_BlockHash), where 32B_Blockhash is a recent L1 blockhash and 32B_Commitment is a keccak256 hash that the enclave is committing to. The calling contract is expected to precompute raveCommitment from public inputs. The function returns true if the report is valid and the extracted payload matches the expected. * @param blockNumber is the block number to fetch 32B_Blockhash * @param raveCommitment is the keccak256 hash commitment 32B_Commitment * @param evidence is the remote attestation evidence * @param mrenclave is the MRENCLAVE value expected by the calling contract * @param mrsigner is the MRSIGNER value expected by the calling contract * @return true if evidence verification is a success */ function verifyEvidence( uint256 blockNumber, bytes32 raveCommitment, RaveEvidence calldata evidence, bytes32 mrenclave, bytes32 mrsigner ) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; struct RaveEvidence { // Preprocessed remote attestation report bytes report; // Preprocessed RSA signature over the report bytes signature; // The hash of a whitelisted Intel-signed leaf x509 certificate bytes32 leafX509CertDigest; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/AccessManaged.sol) pragma solidity ^0.8.20; import {IAuthority} from "./IAuthority.sol"; import {AuthorityUtils} from "./AuthorityUtils.sol"; import {IAccessManager} from "./IAccessManager.sol"; import {IAccessManaged} from "./IAccessManaged.sol"; import {Context} from "../../utils/Context.sol"; /** * @dev This contract module makes available a {restricted} modifier. Functions decorated with this modifier will be * permissioned according to an "authority": a contract like {AccessManager} that follows the {IAuthority} interface, * implementing a policy that allows certain callers to access certain functions. * * IMPORTANT: The `restricted` modifier should never be used on `internal` functions, judiciously used in `public` * functions, and ideally only used in `external` functions. See {restricted}. */ abstract contract AccessManaged is Context, IAccessManaged { address private _authority; bool private _consumingSchedule; /** * @dev Initializes the contract connected to an initial authority. */ constructor(address initialAuthority) { _setAuthority(initialAuthority); } /** * @dev Restricts access to a function as defined by the connected Authority for this contract and the * caller and selector of the function that entered the contract. * * [IMPORTANT] * ==== * In general, this modifier should only be used on `external` functions. It is okay to use it on `public` * functions that are used as external entry points and are not called internally. Unless you know what you're * doing, it should never be used on `internal` functions. Failure to follow these rules can have critical security * implications! This is because the permissions are determined by the function that entered the contract, i.e. the * function at the bottom of the call stack, and not the function where the modifier is visible in the source code. * ==== * * [WARNING] * ==== * Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[`receive()`] * function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[`fallback()`]. These * functions are the only execution paths where a function selector cannot be unambiguosly determined from the calldata * since the selector defaults to `0x00000000` in the `receive()` function and similarly in the `fallback()` function * if no calldata is provided. (See {_checkCanCall}). * * The `receive()` function will always panic whereas the `fallback()` may panic depending on the calldata length. * ==== */ modifier restricted() { _checkCanCall(_msgSender(), _msgData()); _; } /// @inheritdoc IAccessManaged function authority() public view virtual returns (address) { return _authority; } /// @inheritdoc IAccessManaged function setAuthority(address newAuthority) public virtual { address caller = _msgSender(); if (caller != authority()) { revert AccessManagedUnauthorized(caller); } if (newAuthority.code.length == 0) { revert AccessManagedInvalidAuthority(newAuthority); } _setAuthority(newAuthority); } /// @inheritdoc IAccessManaged function isConsumingScheduledOp() public view returns (bytes4) { return _consumingSchedule ? this.isConsumingScheduledOp.selector : bytes4(0); } /** * @dev Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the * permissions set by the current authority. */ function _setAuthority(address newAuthority) internal virtual { _authority = newAuthority; emit AuthorityUpdated(newAuthority); } /** * @dev Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata * is less than 4 bytes long. */ function _checkCanCall(address caller, bytes calldata data) internal virtual { (bool immediate, uint32 delay) = AuthorityUtils.canCallWithDelay( authority(), caller, address(this), bytes4(data[0:4]) ); if (!immediate) { if (delay > 0) { _consumingSchedule = true; IAccessManager(authority()).consumeScheduledOp(caller, data); _consumingSchedule = false; } else { revert AccessManagedUnauthorized(caller); } } } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; /** * @notice Thrown when the operation is not authorized * @dev Signature "0x82b42900" */ error Unauthorized(); /** * @notice Thrown if the address supplied is not valid * @dev Signature "0xe6c4247b" */ error InvalidAddress();
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; contract JSONBuilder { struct Values { bytes id; bytes timestamp; bytes version; bytes epidPseudonym; bytes advisoryURL; bytes advisoryIDs; bytes isvEnclaveQuoteStatus; bytes isvEnclaveQuoteBody; } function buildJSON(Values memory values) public pure returns (string memory json) { json = string( abi.encodePacked( '{"id":"', values.id, '","timestamp":"', values.timestamp, '","version":', values.version, ',"epidPseudonym":"', values.epidPseudonym ) ); json = string( abi.encodePacked( json, '","advisoryURL":"', values.advisoryURL, '","advisoryIDs":', values.advisoryIDs, ',"isvEnclaveQuoteStatus":"', values.isvEnclaveQuoteStatus, '","isvEnclaveQuoteBody":"', values.isvEnclaveQuoteBody, '"}' ) ); } } contract CustomJSONBuilder { string[] public keys; constructor(string[] memory _keys) { keys = _keys; } function buildJSON(string[] memory values) public view returns (string memory) { require(values.length == keys.length); string memory json = ""; for (uint256 i = 0; i < keys.length; i++) { json = string(abi.encodePacked(json, keys[i], values[i])); } return string(abi.encodePacked("{", json, '"}')); } }
pragma solidity ^0.8.4; library BytesUtils { error OffsetOutOfBoundsError(uint256 offset, uint256 length); /* * @dev Returns the keccak-256 hash of a byte range. * @param self The byte string to hash. * @param offset The position to start hashing at. * @param len The number of bytes to hash. * @return The hash of the byte range. */ function keccak( bytes memory self, uint256 offset, uint256 len ) internal pure returns (bytes32 ret) { require(offset + len <= self.length); assembly { ret := keccak256(add(add(self, 32), offset), len) } } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two bytes are equal. * @param self The first bytes to compare. * @param other The second bytes to compare. * @return The result of the comparison. */ function compare( bytes memory self, bytes memory other ) internal pure returns (int256) { return compare(self, 0, self.length, other, 0, other.length); } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two bytes are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first bytes to compare. * @param offset The offset of self. * @param len The length of self. * @param other The second bytes to compare. * @param otheroffset The offset of the other string. * @param otherlen The length of the other string. * @return The result of the comparison. */ function compare( bytes memory self, uint256 offset, uint256 len, bytes memory other, uint256 otheroffset, uint256 otherlen ) internal pure returns (int256) { if (offset + len > self.length) { revert OffsetOutOfBoundsError(offset + len, self.length); } if (otheroffset + otherlen > other.length) { revert OffsetOutOfBoundsError(otheroffset + otherlen, other.length); } uint256 shortest = len; if (otherlen < len) shortest = otherlen; uint256 selfptr; uint256 otherptr; assembly { selfptr := add(self, add(offset, 32)) otherptr := add(other, add(otheroffset, 32)) } for (uint256 idx = 0; idx < shortest; idx += 32) { uint256 a; uint256 b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint256 mask; if (shortest - idx >= 32) { mask = type(uint256).max; } else { mask = ~(2 ** (8 * (idx + 32 - shortest)) - 1); } int256 diff = int256(a & mask) - int256(b & mask); if (diff != 0) return diff; } selfptr += 32; otherptr += 32; } return int256(len) - int256(otherlen); } /* * @dev Returns true if the two byte ranges are equal. * @param self The first byte range to compare. * @param offset The offset into the first byte range. * @param other The second byte range to compare. * @param otherOffset The offset into the second byte range. * @param len The number of bytes to compare * @return True if the byte ranges are equal, false otherwise. */ function equals( bytes memory self, uint256 offset, bytes memory other, uint256 otherOffset, uint256 len ) internal pure returns (bool) { return keccak(self, offset, len) == keccak(other, otherOffset, len); } /* * @dev Returns true if the two byte ranges are equal with offsets. * @param self The first byte range to compare. * @param offset The offset into the first byte range. * @param other The second byte range to compare. * @param otherOffset The offset into the second byte range. * @return True if the byte ranges are equal, false otherwise. */ function equals( bytes memory self, uint256 offset, bytes memory other, uint256 otherOffset ) internal pure returns (bool) { return keccak(self, offset, self.length - offset) == keccak(other, otherOffset, other.length - otherOffset); } /* * @dev Compares a range of 'self' to all of 'other' and returns True iff * they are equal. * @param self The first byte range to compare. * @param offset The offset into the first byte range. * @param other The second byte range to compare. * @return True if the byte ranges are equal, false otherwise. */ function equals( bytes memory self, uint256 offset, bytes memory other ) internal pure returns (bool) { return self.length == offset + other.length && equals(self, offset, other, 0, other.length); } /* * @dev Returns true if the two byte ranges are equal. * @param self The first byte range to compare. * @param other The second byte range to compare. * @return True if the byte ranges are equal, false otherwise. */ function equals( bytes memory self, bytes memory other ) internal pure returns (bool) { return self.length == other.length && equals(self, 0, other, 0, self.length); } /* * @dev Returns the 8-bit number at the specified index of self. * @param self The byte string. * @param idx The index into the bytes * @return The specified 8 bits of the string, interpreted as an integer. */ function readUint8( bytes memory self, uint256 idx ) internal pure returns (uint8 ret) { return uint8(self[idx]); } /* * @dev Returns the 16-bit number at the specified index of self. * @param self The byte string. * @param idx The index into the bytes * @return The specified 16 bits of the string, interpreted as an integer. */ function readUint16( bytes memory self, uint256 idx ) internal pure returns (uint16 ret) { require(idx + 2 <= self.length); assembly { ret := and(mload(add(add(self, 2), idx)), 0xFFFF) } } /* * @dev Returns the 32-bit number at the specified index of self. * @param self The byte string. * @param idx The index into the bytes * @return The specified 32 bits of the string, interpreted as an integer. */ function readUint32( bytes memory self, uint256 idx ) internal pure returns (uint32 ret) { require(idx + 4 <= self.length); assembly { ret := and(mload(add(add(self, 4), idx)), 0xFFFFFFFF) } } /* * @dev Returns the 32 byte value at the specified index of self. * @param self The byte string. * @param idx The index into the bytes * @return The specified 32 bytes of the string. */ function readBytes32( bytes memory self, uint256 idx ) internal pure returns (bytes32 ret) { require(idx + 32 <= self.length); assembly { ret := mload(add(add(self, 32), idx)) } } /* * @dev Returns the 32 byte value at the specified index of self. * @param self The byte string. * @param idx The index into the bytes * @return The specified 32 bytes of the string. */ function readBytes20( bytes memory self, uint256 idx ) internal pure returns (bytes20 ret) { require(idx + 20 <= self.length); assembly { ret := and( mload(add(add(self, 32), idx)), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000 ) } } /* * @dev Returns the n byte value at the specified index of self. * @param self The byte string. * @param idx The index into the bytes. * @param len The number of bytes. * @return The specified 32 bytes of the string. */ function readBytesN( bytes memory self, uint256 idx, uint256 len ) internal pure returns (bytes32 ret) { require(len <= 32); require(idx + len <= self.length); assembly { let mask := not(sub(exp(256, sub(32, len)), 1)) ret := and(mload(add(add(self, 32), idx)), mask) } } function memcpy(uint256 dest, uint256 src, uint256 len) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes unchecked { uint256 mask = (256 ** (32 - len)) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } } /* * @dev Copies a substring into a new byte string. * @param self The byte string to copy from. * @param offset The offset to start copying at. * @param len The number of bytes to copy. */ function substring( bytes memory self, uint256 offset, uint256 len ) internal pure returns (bytes memory) { require(offset + len <= self.length); bytes memory ret = new bytes(len); uint256 dest; uint256 src; assembly { dest := add(ret, 32) src := add(add(self, 32), offset) } memcpy(dest, src, len); return ret; } // Maps characters from 0x30 to 0x7A to their base32 values. // 0xFF represents invalid characters in that range. bytes constant base32HexTable = hex"00010203040506070809FFFFFFFFFFFFFF0A0B0C0D0E0F101112131415161718191A1B1C1D1E1FFFFFFFFFFFFFFFFFFFFF0A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"; /** * @dev Decodes unpadded base32 data of up to one word in length. * @param self The data to decode. * @param off Offset into the string to start at. * @param len Number of characters to decode. * @return The decoded data, left aligned. */ function base32HexDecodeWord( bytes memory self, uint256 off, uint256 len ) internal pure returns (bytes32) { require(len <= 52); uint256 ret = 0; uint8 decoded; for (uint256 i = 0; i < len; i++) { bytes1 char = self[off + i]; require(char >= 0x30 && char <= 0x7A); decoded = uint8(base32HexTable[uint256(uint8(char)) - 0x30]); require(decoded <= 0x20); if (i == len - 1) { break; } ret = (ret << 5) | decoded; } uint256 bitlen = len * 5; if (len % 8 == 0) { // Multiple of 8 characters, no padding ret = (ret << 5) | decoded; } else if (len % 8 == 2) { // Two extra characters - 1 byte ret = (ret << 3) | (decoded >> 2); bitlen -= 2; } else if (len % 8 == 4) { // Four extra characters - 2 bytes ret = (ret << 1) | (decoded >> 4); bitlen -= 4; } else if (len % 8 == 5) { // Five extra characters - 3 bytes ret = (ret << 4) | (decoded >> 1); bitlen -= 1; } else if (len % 8 == 7) { // Seven extra characters - 4 bytes ret = (ret << 2) | (decoded >> 3); bitlen -= 3; } else { revert(); } return bytes32(ret << (256 - bitlen)); } /** * @dev Finds the first occurrence of the byte `needle` in `self`. * @param self The string to search * @param off The offset to start searching at * @param len The number of bytes to search * @param needle The byte to search for * @return The offset of `needle` in `self`, or 2**256-1 if it was not found. */ function find( bytes memory self, uint256 off, uint256 len, bytes1 needle ) internal pure returns (uint256) { for (uint256 idx = off; idx < off + len; idx++) { if (self[idx] == needle) { return idx; } } return type(uint256).max; } /** * @dev Attempts to parse an address from a hex string * @param str The string to parse * @param idx The offset to start parsing at * @param lastIdx The (exclusive) last index in `str` to consider. Use `str.length` to scan the whole string. */ function hexToAddress( bytes memory str, uint256 idx, uint256 lastIdx ) internal pure returns (address, bool) { if (lastIdx - idx < 40) return (address(0x0), false); uint256 ret = 0; for (uint256 i = idx; i < idx + 40; i++) { ret <<= 4; uint256 x = readUint8(str, i); if (x >= 48 && x < 58) { ret |= x - 48; } else if (x >= 65 && x < 71) { ret |= x - 55; } else if (x >= 97 && x < 103) { ret |= x - 87; } else { return (address(0x0), false); } } return (address(uint160(ret)), true); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Base64.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to operate with Base64 strings. */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; import { BytesUtils } from "ens-contracts/dnssec-oracle/BytesUtils.sol"; import { RSAVerify } from "ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol"; import { IRave } from "rave/IRave.sol"; abstract contract RAVEBase is IRave { using BytesUtils for *; uint256 constant MAX_JSON_ELEMENTS = 19; uint256 constant QUOTE_BODY_LENGTH = 432; uint256 constant MRENCLAVE_OFFSET = 112; uint256 constant MRSIGNER_OFFSET = 176; uint256 constant PAYLOAD_OFFSET = 368; uint256 constant PAYLOAD_SIZE = 64; bytes32 constant OK_STATUS = keccak256("OK"); bytes32 constant HARDENING_STATUS = keccak256("SW_HARDENING_NEEDED"); constructor() { } /** * @inheritdoc IRave */ function verifyReportSignature( bytes memory report, bytes calldata sig, bytes memory signingMod, bytes memory signingExp ) public view returns (bool) { // Use signingPK to verify sig is the RSA signature over sha256(report) (bool success, bytes memory got) = RSAVerify.rsarecover(signingMod, signingExp, sig); // Last 32 bytes is recovered signed digest bytes32 recovered = got.readBytes32(got.length - 32); return success && recovered == sha256(report); } /** * @inheritdoc IRave */ function verifyRemoteAttestation( bytes calldata report, bytes calldata sig, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) public view virtual returns (bytes memory payload) { } /** * @inheritdoc IRave */ function rave( bytes calldata report, bytes calldata sig, bytes memory leafX509Cert, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) external view virtual returns (bytes memory payload) { } }
// SPDX-License-Identifier: MIT // Original source: https://github.com/JonahGroendal/asn1-decode pragma solidity >=0.8.0 <0.9.0; import { BytesUtils } from "ens-contracts/dnssec-oracle/BytesUtils.sol"; library NodePtr { // Unpack first byte index function ixs(uint256 self) internal pure returns (uint256) { return uint80(self); } // Unpack first content byte index function ixf(uint256 self) internal pure returns (uint256) { return uint80(self >> 80); } // Unpack last content byte index function ixl(uint256 self) internal pure returns (uint256) { return uint80(self >> 160); } // Pack 3 uint80s into a uint256 function getPtr(uint256 _ixs, uint256 _ixf, uint256 _ixl) internal pure returns (uint256) { _ixs |= _ixf << 80; _ixs |= _ixl << 160; return _ixs; } } library Asn1Decode { using NodePtr for uint256; using BytesUtils for bytes; /* * @dev Get the root node. First step in traversing an ASN1 structure * @param der The DER-encoded ASN1 structure * @return A pointer to the outermost node */ function root(bytes memory der) internal pure returns (uint256) { return readNodeLength(der, 0); } /* * @dev Get the root node of an ASN1 structure that's within a bit string value * @param der The DER-encoded ASN1 structure * @return A pointer to the outermost node */ function rootOfBitStringAt(bytes memory der, uint256 ptr) internal pure returns (uint256) { require(der[ptr.ixs()] == 0x03, "Not type BIT STRING"); return readNodeLength(der, ptr.ixf() + 1); } /* * @dev Get the root node of an ASN1 structure that's within an octet string value * @param der The DER-encoded ASN1 structure * @return A pointer to the outermost node */ function rootOfOctetStringAt(bytes memory der, uint256 ptr) internal pure returns (uint256) { require(der[ptr.ixs()] == 0x04, "Not type OCTET STRING"); return readNodeLength(der, ptr.ixf()); } /* * @dev Get the next sibling node * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return A pointer to the next sibling node */ function nextSiblingOf(bytes memory der, uint256 ptr) internal pure returns (uint256) { return readNodeLength(der, ptr.ixl() + 1); } /* * @dev Get the first child node of the current node * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return A pointer to the first child node */ function firstChildOf(bytes memory der, uint256 ptr) internal pure returns (uint256) { require(der[ptr.ixs()] & 0x20 == 0x20, "Not a constructed type"); return readNodeLength(der, ptr.ixf()); } /* * @dev Use for looping through children of a node (either i or j). * @param i Pointer to an ASN1 node * @param j Pointer to another ASN1 node of the same ASN1 structure * @return True iff j is child of i or i is child of j. */ function isChildOf(uint256 i, uint256 j) internal pure returns (bool) { return (((i.ixf() <= j.ixs()) && (j.ixl() <= i.ixl())) || ((j.ixf() <= i.ixs()) && (i.ixl() <= j.ixl()))); } /* * @dev Extract value of node from DER-encoded structure * @param der The der-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return Value bytes of node */ function bytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) { return der.substring(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf()); } /* * @dev Extract entire node from DER-encoded structure * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return All bytes of node */ function allBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) { return der.substring(ptr.ixs(), ptr.ixl() + 1 - ptr.ixs()); } /* * @dev Extract value of node from DER-encoded structure * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return Value bytes of node as bytes32 */ function bytes32At(bytes memory der, uint256 ptr) internal pure returns (bytes32) { return der.readBytesN(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf()); } /* * @dev Extract value of node from DER-encoded structure * @param der The der-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return Uint value of node */ function uintAt(bytes memory der, uint256 ptr) internal pure returns (uint256) { require(der[ptr.ixs()] == 0x02, "Not type INTEGER"); require(der[ptr.ixf()] & 0x80 == 0, "Not positive"); uint256 len = ptr.ixl() + 1 - ptr.ixf(); return uint256(der.readBytesN(ptr.ixf(), len) >> (32 - len) * 8); } /* * @dev Extract value of a positive integer node from DER-encoded structure * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return Value bytes of a positive integer node */ function uintBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) { require(der[ptr.ixs()] == 0x02, "Not type INTEGER"); require(der[ptr.ixf()] & 0x80 == 0, "Not positive"); uint256 valueLength = ptr.ixl() + 1 - ptr.ixf(); if (der[ptr.ixf()] == 0) { return der.substring(ptr.ixf() + 1, valueLength - 1); } else { return der.substring(ptr.ixf(), valueLength); } } function keccakOfBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes32) { return der.keccak(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf()); } function keccakOfAllBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes32) { return der.keccak(ptr.ixs(), ptr.ixl() + 1 - ptr.ixs()); } /* * @dev Extract value of bitstring node from DER-encoded structure * @param der The DER-encoded ASN1 structure * @param ptr Points to the indices of the current node * @return Value of bitstring converted to bytes */ function bitstringAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) { require(der[ptr.ixs()] == 0x03, "Not type BIT STRING"); // Only 00 padded bitstr can be converted to bytestr! require(der[ptr.ixf()] == 0x00); uint256 valueLength = ptr.ixl() + 1 - ptr.ixf(); return der.substring(ptr.ixf() + 1, valueLength - 1); } function readNodeLength(bytes memory der, uint256 ix) private pure returns (uint256) { uint256 length; uint80 ixFirstContentByte; uint80 ixLastContentByte; if ((der[ix + 1] & 0x80) == 0) { length = uint8(der[ix + 1]); ixFirstContentByte = uint80(ix + 2); ixLastContentByte = uint80(ixFirstContentByte + length - 1); } else { uint8 lengthbytesLength = uint8(der[ix + 1] & 0x7F); if (lengthbytesLength == 1) { length = der.readUint8(ix + 2); } else if (lengthbytesLength == 2) { length = der.readUint16(ix + 2); } else { length = uint256(der.readBytesN(ix + 2, lengthbytesLength) >> (32 - lengthbytesLength) * 8); } ixFirstContentByte = uint80(ix + 2 + lengthbytesLength); ixLastContentByte = uint80(ixFirstContentByte + length - 1); } return NodePtr.getPtr(ix, ixFirstContentByte, ixLastContentByte); } }
pragma solidity ^0.8.4; import "../BytesUtils.sol"; import "./ModexpPrecompile.sol"; library RSAVerify { /** * @dev Recovers the input data from an RSA signature, returning the result in S. * @param N The RSA public modulus. * @param E The RSA public exponent. * @param S The signature to recover. * @return True if the recovery succeeded. */ function rsarecover( bytes memory N, bytes memory E, bytes memory S ) internal view returns (bool, bytes memory) { return ModexpPrecompile.modexp(S, E, N); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAuthority.sol) pragma solidity ^0.8.20; /** * @dev Standard interface for permissioning originally defined in Dappsys. */ interface IAuthority { /** * @dev Returns true if the caller can invoke on a target the function identified by a function selector. */ function canCall(address caller, address target, bytes4 selector) external view returns (bool allowed); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/AuthorityUtils.sol) pragma solidity ^0.8.20; import {IAuthority} from "./IAuthority.sol"; library AuthorityUtils { /** * @dev Since `AccessManager` implements an extended IAuthority interface, invoking `canCall` with backwards compatibility * for the preexisting `IAuthority` interface requires special care to avoid reverting on insufficient return data. * This helper function takes care of invoking `canCall` in a backwards compatible way without reverting. */ function canCallWithDelay( address authority, address caller, address target, bytes4 selector ) internal view returns (bool immediate, uint32 delay) { (bool success, bytes memory data) = authority.staticcall( abi.encodeCall(IAuthority.canCall, (caller, target, selector)) ); if (success) { if (data.length >= 0x40) { (immediate, delay) = abi.decode(data, (bool, uint32)); } else if (data.length >= 0x20) { immediate = abi.decode(data, (bool)); } } return (immediate, delay); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManager.sol) pragma solidity ^0.8.20; import {IAccessManaged} from "./IAccessManaged.sol"; import {Time} from "../../utils/types/Time.sol"; interface IAccessManager { /** * @dev A delayed operation was scheduled. */ event OperationScheduled( bytes32 indexed operationId, uint32 indexed nonce, uint48 schedule, address caller, address target, bytes data ); /** * @dev A scheduled operation was executed. */ event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce); /** * @dev A scheduled operation was canceled. */ event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce); /** * @dev Informational labelling for a roleId. */ event RoleLabel(uint64 indexed roleId, string label); /** * @dev Emitted when `account` is granted `roleId`. * * NOTE: The meaning of the `since` argument depends on the `newMember` argument. * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role, * otherwise it indicates the execution delay for this account and roleId is updated. */ event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember); /** * @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous. */ event RoleRevoked(uint64 indexed roleId, address indexed account); /** * @dev Role acting as admin over a given `roleId` is updated. */ event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin); /** * @dev Role acting as guardian over a given `roleId` is updated. */ event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian); /** * @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached. */ event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since); /** * @dev Target mode is updated (true = closed, false = open). */ event TargetClosed(address indexed target, bool closed); /** * @dev Role required to invoke `selector` on `target` is updated to `roleId`. */ event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId); /** * @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached. */ event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since); error AccessManagerAlreadyScheduled(bytes32 operationId); error AccessManagerNotScheduled(bytes32 operationId); error AccessManagerNotReady(bytes32 operationId); error AccessManagerExpired(bytes32 operationId); error AccessManagerLockedAccount(address account); error AccessManagerLockedRole(uint64 roleId); error AccessManagerBadConfirmation(); error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId); error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector); error AccessManagerUnauthorizedConsume(address target); error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector); error AccessManagerInvalidInitialAdmin(address initialAdmin); /** * @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with * no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule} * & {execute} workflow. * * This function is usually called by the targeted contract to control immediate execution of restricted functions. * Therefore we only return true if the call can be performed without any delay. If the call is subject to a * previously set delay (not zero), then the function should return false and the caller should schedule the operation * for future execution. * * If `immediate` is true, the delay can be disregarded and the operation can be immediately executed, otherwise * the operation can be executed if and only if delay is greater than 0. * * NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that * is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail * to identify the indirect workflow, and will consider calls that require a delay to be forbidden. * * NOTE: This function does not report the permissions of this manager itself. These are defined by the * {_canCallSelf} function instead. */ function canCall( address caller, address target, bytes4 selector ) external view returns (bool allowed, uint32 delay); /** * @dev Expiration delay for scheduled proposals. Defaults to 1 week. * * IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately, * disabling any scheduling usage. */ function expiration() external view returns (uint32); /** * @dev Minimum setback for all delay updates, with the exception of execution delays. It * can be increased without setback (and reset via {revokeRole} in the case event of an * accidental increase). Defaults to 5 days. */ function minSetback() external view returns (uint32); /** * @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied. */ function isTargetClosed(address target) external view returns (bool); /** * @dev Get the role required to call a function. */ function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64); /** * @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay. */ function getTargetAdminDelay(address target) external view returns (uint32); /** * @dev Get the id of the role that acts as an admin for the given role. * * The admin permission is required to grant the role, revoke the role and update the execution delay to execute * an operation that is restricted to this role. */ function getRoleAdmin(uint64 roleId) external view returns (uint64); /** * @dev Get the role that acts as a guardian for a given role. * * The guardian permission allows canceling operations that have been scheduled under the role. */ function getRoleGuardian(uint64 roleId) external view returns (uint64); /** * @dev Get the role current grant delay. * * Its value may change at any point without an event emitted following a call to {setGrantDelay}. * Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event. */ function getRoleGrantDelay(uint64 roleId) external view returns (uint32); /** * @dev Get the access details for a given account for a given role. These details include the timepoint at which * membership becomes active, and the delay applied to all operation by this user that requires this permission * level. * * Returns: * [0] Timestamp at which the account membership becomes valid. 0 means role is not granted. * [1] Current execution delay for the account. * [2] Pending execution delay for the account. * [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled. */ function getAccess(uint64 roleId, address account) external view returns (uint48, uint32, uint32, uint48); /** * @dev Check if a given account currently has the permission level corresponding to a given role. Note that this * permission might be associated with an execution delay. {getAccess} can provide more details. */ function hasRole(uint64 roleId, address account) external view returns (bool, uint32); /** * @dev Give a label to a role, for improved role discoverability by UIs. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleLabel} event. */ function labelRole(uint64 roleId, string calldata label) external; /** * @dev Add `account` to `roleId`, or change its execution delay. * * This gives the account the authorization to call any function that is restricted to this role. An optional * execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation * that is restricted to members of this role. The user will only be able to execute the operation after the delay has * passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}). * * If the account has already been granted this role, the execution delay will be updated. This update is not * immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is * called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any * operation executed in the 3 hours that follows this update was indeed scheduled before this update. * * Requirements: * * - the caller must be an admin for the role (see {getRoleAdmin}) * - granted role must not be the `PUBLIC_ROLE` * * Emits a {RoleGranted} event. */ function grantRole(uint64 roleId, address account, uint32 executionDelay) external; /** * @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has * no effect. * * Requirements: * * - the caller must be an admin for the role (see {getRoleAdmin}) * - revoked role must not be the `PUBLIC_ROLE` * * Emits a {RoleRevoked} event if the account had the role. */ function revokeRole(uint64 roleId, address account) external; /** * @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in * the role this call has no effect. * * Requirements: * * - the caller must be `callerConfirmation`. * * Emits a {RoleRevoked} event if the account had the role. */ function renounceRole(uint64 roleId, address callerConfirmation) external; /** * @dev Change admin role for a given role. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleAdminChanged} event */ function setRoleAdmin(uint64 roleId, uint64 admin) external; /** * @dev Change guardian role for a given role. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleGuardianChanged} event */ function setRoleGuardian(uint64 roleId, uint64 guardian) external; /** * @dev Update the delay for granting a `roleId`. * * Requirements: * * - the caller must be a global admin * * Emits a {RoleGrantDelayChanged} event. */ function setGrantDelay(uint64 roleId, uint32 newDelay) external; /** * @dev Set the role required to call functions identified by the `selectors` in the `target` contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetFunctionRoleUpdated} event per selector. */ function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external; /** * @dev Set the delay for changing the configuration of a given target contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetAdminDelayUpdated} event. */ function setTargetAdminDelay(address target, uint32 newDelay) external; /** * @dev Set the closed flag for a contract. * * Requirements: * * - the caller must be a global admin * * Emits a {TargetClosed} event. */ function setTargetClosed(address target, bool closed) external; /** * @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the * operation is not yet scheduled, has expired, was executed, or was canceled. */ function getSchedule(bytes32 id) external view returns (uint48); /** * @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never * been scheduled. */ function getNonce(bytes32 id) external view returns (uint32); /** * @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to * choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays * required for the caller. The special value zero will automatically set the earliest possible time. * * Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when * the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this * scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}. * * Emits a {OperationScheduled} event. * * NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If * this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target * contract if it is using standard Solidity ABI encoding. */ function schedule(address target, bytes calldata data, uint48 when) external returns (bytes32, uint32); /** * @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the * execution delay is 0. * * Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the * operation wasn't previously scheduled (if the caller doesn't have an execution delay). * * Emits an {OperationExecuted} event only if the call was scheduled and delayed. */ function execute(address target, bytes calldata data) external payable returns (uint32); /** * @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled * operation that is cancelled. * * Requirements: * * - the caller must be the proposer, a guardian of the targeted function, or a global admin * * Emits a {OperationCanceled} event. */ function cancel(address caller, address target, bytes calldata data) external returns (uint32); /** * @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed * (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error. * * This is useful for contract that want to enforce that calls targeting them were scheduled on the manager, * with all the verifications that it implies. * * Emit a {OperationExecuted} event. */ function consumeScheduledOp(address caller, bytes calldata data) external; /** * @dev Hashing function for delayed operations. */ function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32); /** * @dev Changes the authority of a target managed by this manager instance. * * Requirements: * * - the caller must be a global admin */ function updateAuthority(address target, address newAuthority) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManaged.sol) pragma solidity ^0.8.20; interface IAccessManaged { /** * @dev Authority that manages this contract was updated. */ event AuthorityUpdated(address authority); error AccessManagedUnauthorized(address caller); error AccessManagedRequiredDelay(address caller, uint32 delay); error AccessManagedInvalidAuthority(address authority); /** * @dev Returns the current authority. */ function authority() external view returns (address); /** * @dev Transfers control to a new authority. The caller must be the current authority. */ function setAuthority(address) external; /** * @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is * being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs * attacker controlled calls. */ function isConsumingScheduledOp() external view returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; /** * @title IRave interface * @author Puffer finance * @custom:security-contact [email protected] * @notice IRave interface */ interface IRave { /** * Bad report signature */ error BadReportSignature(); /* * @dev Verifies the RSA-SHA256 signature of the attestation report. * @param report The attestation evidence report from IAS. * @param sig The RSA-SHA256 signature over the report. * @param signingMod The expected signer's RSA modulus * @param signingExp The expected signer's RSA exponent * @return True if the signature is valid */ function verifyReportSignature( bytes memory report, bytes calldata sig, bytes memory signingMod, bytes memory signingExp ) external view returns (bool); /* * @dev Verifies that the leafX509Cert was signed by the expected signer (signingMod, signingExp). Then uses leafX509Cert RSA public key to verify the signature over the report, sig. The trusted report is verified for correct fields and then the enclave' 64 byte commitment is extracted. * @param report The attestation evidence report from IAS. * @param sig The RSA-SHA256 signature over the report. * @param leafX509Cert The signed leaf x509 certificate. * @param signingMod The expected signer's RSA modulus * @param signingExp The expected signer's RSA exponent * @param mrenclave The expected enclave measurement. * @param mrsigner The expected enclave signer. * @return The 64 byte payload from the report. */ function rave( bytes calldata report, bytes memory sig, bytes memory leafX509Cert, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) external view returns (bytes memory payload); /* * @dev Verifies that this report was signed by the expected signer, then extracts out the report's 64 byte payload. * @param report The attestation evidence report from IAS. * @param sig The RSA-SHA256 signature over the report. * @param signingMod The expected signer's RSA modulus * @param signingExp The expected signer's RSA exponent * @param mrenclave The expected enclave measurement. * @param mrsigner The expected enclave signer. * @return The 64 byte payload from the report. */ function verifyRemoteAttestation( bytes calldata report, bytes memory sig, bytes memory signingMod, bytes memory signingExp, bytes32 mrenclave, bytes32 mrsigner ) external view returns (bytes memory payload); }
pragma solidity ^0.8.4; library ModexpPrecompile { /** * @dev Computes (base ^ exponent) % modulus over big numbers. */ function modexp( bytes memory base, bytes memory exponent, bytes memory modulus ) internal view returns (bool success, bytes memory output) { bytes memory input = abi.encodePacked( uint256(base.length), uint256(exponent.length), uint256(modulus.length), base, exponent, modulus ); output = new bytes(modulus.length); assembly { success := staticcall( gas(), 5, add(input, 32), mload(input), add(output, 32), mload(modulus) ) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol) pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; import {SafeCast} from "../math/SafeCast.sol"; /** * @dev This library provides helpers for manipulating time-related objects. * * It uses the following types: * - `uint48` for timepoints * - `uint32` for durations * * While the library doesn't provide specific types for timepoints and duration, it does provide: * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point * - additional helper functions */ library Time { using Time for *; /** * @dev Get the block timestamp as a Timepoint. */ function timestamp() internal view returns (uint48) { return SafeCast.toUint48(block.timestamp); } /** * @dev Get the block number as a Timepoint. */ function blockNumber() internal view returns (uint48) { return SafeCast.toUint48(block.number); } // ==================================================== Delay ===================================================== /** * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the * future. The "effect" timepoint describes when the transitions happens from the "old" value to the "new" value. * This allows updating the delay applied to some operation while keeping some guarantees. * * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should * still apply for some time. * * * The `Delay` type is 112 bits long, and packs the following: * * ``` * | [uint48]: effect date (timepoint) * | | [uint32]: value before (duration) * ↓ ↓ ↓ [uint32]: value after (duration) * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC * ``` * * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently * supported. */ type Delay is uint112; /** * @dev Wrap a duration into a Delay to add the one-step "update in the future" feature */ function toDelay(uint32 duration) internal pure returns (Delay) { return Delay.wrap(duration); } /** * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered. */ function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) { (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack(); return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect); } /** * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the * effect timepoint is 0, then the pending value should not be considered. */ function getFull(Delay self) internal view returns (uint32, uint32, uint48) { return _getFullAt(self, timestamp()); } /** * @dev Get the current value. */ function get(Delay self) internal view returns (uint32) { (uint32 delay, , ) = self.getFull(); return delay; } /** * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the * new delay becomes effective. */ function withUpdate( Delay self, uint32 newValue, uint32 minSetback ) internal view returns (Delay updatedDelay, uint48 effect) { uint32 value = self.get(); uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0)); effect = timestamp() + setback; return (pack(value, newValue, effect), effect); } /** * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). */ function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) { uint112 raw = Delay.unwrap(self); valueAfter = uint32(raw); valueBefore = uint32(raw >> 32); effect = uint48(raw >> 64); return (valueBefore, valueAfter, effect); } /** * @dev pack the components into a Delay object. */ function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) { return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/=lib/openzeppelin-contracts/", "openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/", "eigenlayer/=lib/eigenlayer-contracts/src/contracts/", "eigenlayer-middleware/=lib/eigenlayer-middleware/src/", "eigenlayer-test/=lib/eigenlayer-contracts/src/test/", "openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "puffer/=src/", "script/=script/", "rave/=lib/rave/src/", "rave-test/=lib/rave/test/", "murky/=lib/murky/src/", "pufETH/=lib/pufETH/src/", "pufETHTest/=lib/pufETH/test/", "pufETHScript/=lib/pufETH/script/", "@openzeppelin-contracts-upgradeable/=lib/pufETH/lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin-upgrades/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ERC4626/=lib/pufETH/lib/properties/lib/ERC4626/contracts/", "eigenlayer-contracts/=lib/eigenlayer-contracts/", "ens-contracts/=lib/rave/lib/ens-contracts/contracts/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "properties/=lib/pufETH/lib/properties/contracts/", "solady/=lib/pufETH/lib/solady/src/", "solmate/=lib/pufETH/lib/properties/lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": false }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": { "lib/rave/src/X509Verifier.sol": { "X509Verifier": "0xE242c27cD0568FEADC46f09811a55F9b24C754a4" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"freshnessBlocks","type":"uint256"},{"internalType":"address","name":"accessManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"authority","type":"address"}],"name":"AccessManagedInvalidAuthority","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"uint32","name":"delay","type":"uint32"}],"name":"AccessManagedRequiredDelay","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"AccessManagedUnauthorized","type":"error"},{"inputs":[],"name":"BadReportSignature","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"StaleEvidence","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"pubKeyHash","type":"bytes32"}],"name":"AddedPubKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"authority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"pubKeyHash","type":"bytes32"}],"name":"RemovedPubKey","type":"event"},{"inputs":[],"name":"FRESHNESS_BLOCKS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"leafX509Cert","type":"bytes"}],"name":"addLeafX509","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"authority","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"id","type":"bytes"},{"internalType":"bytes","name":"timestamp","type":"bytes"},{"internalType":"bytes","name":"version","type":"bytes"},{"internalType":"bytes","name":"epidPseudonym","type":"bytes"},{"internalType":"bytes","name":"advisoryURL","type":"bytes"},{"internalType":"bytes","name":"advisoryIDs","type":"bytes"},{"internalType":"bytes","name":"isvEnclaveQuoteStatus","type":"bytes"},{"internalType":"bytes","name":"isvEnclaveQuoteBody","type":"bytes"}],"internalType":"struct JSONBuilder.Values","name":"values","type":"tuple"}],"name":"buildJSON","outputs":[{"internalType":"string","name":"json","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getIntelRootCAPubKey","outputs":[{"components":[{"internalType":"bytes","name":"modulus","type":"bytes"},{"internalType":"bytes","name":"exponent","type":"bytes"}],"internalType":"struct IEnclaveVerifier.RSAPubKey","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isConsumingScheduledOp","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"report","type":"bytes"},{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"bytes","name":"leafX509Cert","type":"bytes"},{"internalType":"bytes","name":"signingMod","type":"bytes"},{"internalType":"bytes","name":"signingExp","type":"bytes"},{"internalType":"bytes32","name":"mrenclave","type":"bytes32"},{"internalType":"bytes32","name":"mrsigner","type":"bytes32"}],"name":"rave","outputs":[{"internalType":"bytes","name":"payload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hashedCert","type":"bytes32"}],"name":"removeLeafX509","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes32","name":"raveCommitment","type":"bytes32"},{"components":[{"internalType":"bytes","name":"report","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"leafX509CertDigest","type":"bytes32"}],"internalType":"struct RaveEvidence","name":"evidence","type":"tuple"},{"internalType":"bytes32","name":"mrenclave","type":"bytes32"},{"internalType":"bytes32","name":"mrsigner","type":"bytes32"}],"name":"verifyEvidence","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"report","type":"bytes"},{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"bytes","name":"signingMod","type":"bytes"},{"internalType":"bytes","name":"signingExp","type":"bytes"},{"internalType":"bytes32","name":"mrenclave","type":"bytes32"},{"internalType":"bytes32","name":"mrsigner","type":"bytes32"}],"name":"verifyRemoteAttestation","outputs":[{"internalType":"bytes","name":"payload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"report","type":"bytes"},{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"bytes","name":"signingMod","type":"bytes"},{"internalType":"bytes","name":"signingExp","type":"bytes"}],"name":"verifyReportSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a060405234801562000010575f80fd5b50604051620021c3380380620021c38339810160408190526200003391620000c5565b806200003f8162000072565b506001600160a01b038116620000685760405163e6c4247b60e01b815260040160405180910390fd5b5060805262000101565b5f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f658b440c35314f52658ea8a740e05b284cdc84dc9ae01e891f21b8933e7cad9060200160405180910390a150565b5f8060408385031215620000d7575f80fd5b825160208401519092506001600160a01b0381168114620000f6575f80fd5b809150509250929050565b6080516120a3620001205f395f818160ed015261068a01526120a35ff3fe608060405234801561000f575f80fd5b50600436106100b1575f3560e01c80637a9e5e4b1161006e5780637a9e5e4b146101735780637accaea4146101865780638c1c9085146101995780638fb36037146101ac578063bf7e214f146101cd578063fe4e6aee146101e7575f80fd5b806319d2be90146100b557806327a88ff0146100d357806328a55c21146100e85780633549c40e1461011d57806354a2da361461014057806361bb035514610160575b5f80fd5b6100bd6101fa565b6040516100ca91906110f5565b60405180910390f35b6100e66100e136600461117a565b61025e565b005b61010f7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016100ca565b61013061012b36600461129d565b6103ab565b60405190151581526020016100ca565b61015361014e366004611347565b610473565b6040516100ca9190611408565b61015361016e366004611421565b6104fd565b6100e6610181366004611504565b6105a1565b6100e661019436600461152a565b61061e565b6101306101a7366004611541565b610687565b6101b4610891565b6040516001600160e01b031990911681526020016100ca565b5f546040516001600160a01b0390911681526020016100ca565b6101536101f53660046115a1565b6108b3565b60408051808201909152606080825260208201526040518060400160405280604051806101a001604052806101808152602001611f23610180913981526020016040518060400160405280600381526020016201000160e81b815250815250905090565b5f8073e242c27cd0568feadc46f09811a55f9b24c754a463a21f157a8585604051806101a001604052806101808152602001611f2361018091396040518060400160405280600381526020016201000160e81b8152506040518563ffffffff1660e01b81526004016102d39493929190611726565b5f60405180830381865af41580156102ed573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261031491908101906117b4565b915091505f8484604051610329929190611813565b60408051918290038220828201825285835260208084018690525f828152600190915291909120825191935090819061036290826118a3565b506020820151600182019061037790826118a3565b50506040518291507f13b85b042d2bb270091da7111e3b3cc407f6b86c85882cf48ae94123cae22b17905f90a25050505050565b5f805f6103ee858589898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061092892505050565b915091505f61040b602083516104049190611976565b8390610942565b90508280156104665750600289604051610425919061198f565b602060405180830381855afa158015610440573d5f803e3d5ffd5b5050506040513d601f19601f8201168201806040525081019061046391906119aa565b81145b9998505050505050505050565b60605f806104b58b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061096492505050565b915091506104c6818a8a8a8a6103ab565b6104e357604051633f1a65c760e21b815260040160405180910390fd5b6104ee828686610a43565b9b9a5050505050505050505050565b60605f8073e242c27cd0568feadc46f09811a55f9b24c754a463a21f157a8989896040518463ffffffff1660e01b815260040161053c939291906119c1565b5f60405180830381865af4158015610556573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261057d91908101906117b4565b915091506105918c8c8c8c86868b8b610473565b9c9b505050505050505050505050565b5f5433906001600160a01b031681146105dc5760405162d1953b60e31b81526001600160a01b03821660048201526024015b60405180910390fd5b816001600160a01b03163b5f03610611576040516361798f2f60e11b81526001600160a01b03831660048201526024016105d3565b61061a82610b4f565b5050565b610629335f36610ba2565b5f81815260016020526040812061063f91611056565b5f818152600160208190526040822061065a92910190611056565b60405181907f0ebd07953ae533bded7d9b0715fa49e0a0ed0a6cef4638a685737ffef8b86254905f90a250565b5f7f00000000000000000000000000000000000000000000000000000000000000006106b38743611976565b11156106d257604051635d4ad9a960e01b815260040160405180910390fd5b5f60015f866040013581526020019081526020015f206040518060400160405290815f8201805461070290611822565b80601f016020809104026020016040519081016040528092919081815260200182805461072e90611822565b80156107795780601f1061075057610100808354040283529160200191610779565b820191905f5260205f20905b81548152906001019060200180831161075c57829003601f168201915b5050505050815260200160018201805461079290611822565b80601f01602080910402602001604051908101604052809291908181526020018280546107be90611822565b80156108095780601f106107e057610100808354040283529160200191610809565b820191905f5260205f20905b8154815290600101906020018083116107ec57829003601f168201915b50505091909252509192505f915061084190506108268780611a03565b61083360208a018a611a03565b865160208801518b8b610473565b90505f878940604051602001610861929190918252602082015260400190565b60405160208183030381529060405290508180519060200120818051906020012014935050505095945050505050565b5f8054600160a01b900460ff166108a757505f90565b50638fb3603760e01b90565b6060815f01518260200151836040015184606001516040516020016108db9493929190611a45565b60408051601f1981840301815290829052608084015160a085015160c086015160e087015193955061091294869490602001611b04565b6040516020818303038152906040529050919050565b5f6060610936838587610c98565b91509150935093915050565b81515f90610951836020611c0e565b111561095b575f80fd5b50016020015190565b6109ac60405180610100016040528060608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b60605f805f805f805f808a8060200190518101906109ca9190611c21565b975097509750975097509750975097505f6109e482610d2c565b90506040518061010001604052808a8152602001898152602001888152602001878152602001868152602001858152602001848152602001828152509a50610a2b8b6108b3565b60e08c019290925250989a9899505050505050505050565b60c083015180516020909101206060907fdaa4f5d475c02455977059e29f0bd4c2f7e92e8cfa8026b3dcd2c374e8a520e6811480610aa057507f174348b9c1e9ee5c57cffc36f0797c45d85e5ec45e51b2b17433eb33f56a215081145b610aec5760405162461bcd60e51b815260206004820152601960248201527f62616420697376456e636c61766551756f74655374617475730000000000000060448201526064016105d3565b60e085015180516101b014610b0357610b03611d53565b5f610b0f826070610942565b9050858114610b1c575f80fd5b5f610b288360b0610942565b9050858114610b35575f80fd5b610b43836101706040610e7a565b98975050505050505050565b5f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f658b440c35314f52658ea8a740e05b284cdc84dc9ae01e891f21b8933e7cad9060200160405180910390a150565b5f80610bd5610bb85f546001600160a01b031690565b8630610bc760045f898b611d67565b610bd091611d8e565b610ef9565b9150915081610c915763ffffffff811615610c6e575f805460ff60a01b198116600160a01b17909155604051634a63ebf760e11b81526001600160a01b03909116906394c7d7ee90610c2f90889088908890600401611dbe565b5f604051808303815f87803b158015610c46575f80fd5b505af1158015610c58573d5f803e3d5ffd5b50505f805460ff60a01b1916905550610c919050565b60405162d1953b60e31b81526001600160a01b03861660048201526024016105d3565b5050505050565b5f60605f855185518551888888604051602001610cba96959493929190611de2565b604051602081830303815290604052905083516001600160401b03811115610ce457610ce46111b8565b6040519080825280601f01601f191660200182016040528015610d0e576020820181803683370190505b50915083516020830182516020840160055afa925050935093915050565b606081515f03610d4957505060408051602081019091525f815290565b5f604051806060016040528060408152602001611ee36040913990505f600384516002610d769190611c0e565b610d809190611e42565b610d8b906004611e61565b6001600160401b03811115610da257610da26111b8565b6040519080825280601f01601f191660200182016040528015610dcc576020820181803683370190505b509050600182016020820185865187015b80821015610e38576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250610ddd565b5050600386510660018114610e545760028114610e6757610e6f565b603d6001830353603d6002830353610e6f565b603d60018303535b509195945050505050565b8251606090610e898385611c0e565b1115610e93575f80fd5b5f826001600160401b03811115610eac57610eac6111b8565b6040519080825280601f01601f191660200182016040528015610ed6576020820181803683370190505b50905060208082019086860101610eee828287611001565b509095945050505050565b6040516001600160a01b03848116602483015283811660448301526001600160e01b0319831660648301525f9182918291829189169060840160408051601f198184030181529181526020820180516001600160e01b031663b700961360e01b17905251610f67919061198f565b5f60405180830381855afa9150503d805f8114610f9f576040519150601f19603f3d011682016040523d82523d5f602084013e610fa4565b606091505b50915091508115610ff6576040815110610fd65780806020019051810190610fcc9190611e8c565b9094509250610ff6565b6020815110610ff65780806020019051810190610ff39190611ec9565b93505b505094509492505050565b602081106110395781518352611018602084611c0e565b9250611025602083611c0e565b9150611032602082611976565b9050611001565b905182516020929092036101000a5f190180199091169116179052565b50805461106290611822565b5f825580601f10611071575050565b601f0160209004905f5260205f209081019061108d9190611090565b50565b5b808211156110a4575f8155600101611091565b5090565b5f5b838110156110c25781810151838201526020016110aa565b50505f910152565b5f81518084526110e18160208601602086016110a8565b601f01601f19169290920160200192915050565b602081525f82516040602084015261111060608401826110ca565b90506020840151601f1984830301604085015261112d82826110ca565b95945050505050565b5f8083601f840112611146575f80fd5b5081356001600160401b0381111561115c575f80fd5b602083019150836020828501011115611173575f80fd5b9250929050565b5f806020838503121561118b575f80fd5b82356001600160401b038111156111a0575f80fd5b6111ac85828601611136565b90969095509350505050565b634e487b7160e01b5f52604160045260245ffd5b60405161010081016001600160401b03811182821017156111ef576111ef6111b8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561121d5761121d6111b8565b604052919050565b5f6001600160401b0382111561123d5761123d6111b8565b50601f01601f191660200190565b5f82601f83011261125a575f80fd5b813561126d61126882611225565b6111f5565b818152846020838601011115611281575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f805f608086880312156112b1575f80fd5b85356001600160401b03808211156112c7575f80fd5b6112d389838a0161124b565b965060208801359150808211156112e8575f80fd5b6112f489838a01611136565b9096509450604088013591508082111561130c575f80fd5b61131889838a0161124b565b9350606088013591508082111561132d575f80fd5b5061133a8882890161124b565b9150509295509295909350565b5f805f805f805f8060c0898b03121561135e575f80fd5b88356001600160401b0380821115611374575f80fd5b6113808c838d01611136565b909a50985060208b0135915080821115611398575f80fd5b6113a48c838d01611136565b909850965060408b01359150808211156113bc575f80fd5b6113c88c838d0161124b565b955060608b01359150808211156113dd575f80fd5b506113ea8b828c0161124b565b9350506080890135915060a089013590509295985092959890939650565b602081525f61141a60208301846110ca565b9392505050565b5f805f805f805f805f60e08a8c031215611439575f80fd5b89356001600160401b038082111561144f575f80fd5b61145b8d838e01611136565b909b50995060208c0135915080821115611473575f80fd5b61147f8d838e01611136565b909950975060408c0135915080821115611497575f80fd5b6114a38d838e0161124b565b965060608c01359150808211156114b8575f80fd5b6114c48d838e0161124b565b955060808c01359150808211156114d9575f80fd5b506114e68c828d0161124b565b93505060a08a0135915060c08a013590509295985092959850929598565b5f60208284031215611514575f80fd5b81356001600160a01b038116811461141a575f80fd5b5f6020828403121561153a575f80fd5b5035919050565b5f805f805f60a08688031215611555575f80fd5b853594506020860135935060408601356001600160401b03811115611578575f80fd5b860160608189031215611589575f80fd5b94979396509394606081013594506080013592915050565b5f602082840312156115b1575f80fd5b81356001600160401b03808211156115c7575f80fd5b9083019061010082860312156115db575f80fd5b6115e36111cc565b8235828111156115f1575f80fd5b6115fd8782860161124b565b825250602083013582811115611611575f80fd5b61161d8782860161124b565b602083015250604083013582811115611634575f80fd5b6116408782860161124b565b604083015250606083013582811115611657575f80fd5b6116638782860161124b565b60608301525060808301358281111561167a575f80fd5b6116868782860161124b565b60808301525060a08301358281111561169d575f80fd5b6116a98782860161124b565b60a08301525060c0830135828111156116c0575f80fd5b6116cc8782860161124b565b60c08301525060e0830135828111156116e3575f80fd5b6116ef8782860161124b565b60e08301525095945050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b606081525f6117396060830186886116fe565b828103602084015261174b81866110ca565b9050828103604084015261175f81856110ca565b979650505050505050565b5f82601f830112611779575f80fd5b815161178761126882611225565b81815284602083860101111561179b575f80fd5b6117ac8260208301602087016110a8565b949350505050565b5f80604083850312156117c5575f80fd5b82516001600160401b03808211156117db575f80fd5b6117e78683870161176a565b935060208501519150808211156117fc575f80fd5b506118098582860161176a565b9150509250929050565b818382375f9101908152919050565b600181811c9082168061183657607f821691505b60208210810361185457634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561189e57805f5260205f20601f840160051c8101602085101561187f5750805b601f840160051c820191505b81811015610c91575f815560010161188b565b505050565b81516001600160401b038111156118bc576118bc6111b8565b6118d0816118ca8454611822565b8461185a565b602080601f831160018114611903575f84156118ec5750858301515b5f19600386901b1c1916600185901b17855561195a565b5f85815260208120601f198616915b8281101561193157888601518255948401946001909101908401611912565b508582101561194e57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561198957611989611962565b92915050565b5f82516119a08184602087016110a8565b9190910192915050565b5f602082840312156119ba575f80fd5b5051919050565b606081525f6119d360608301866110ca565b82810360208401526119e581866110ca565b905082810360408401526119f981856110ca565b9695505050505050565b5f808335601e19843603018112611a18575f80fd5b8301803591506001600160401b03821115611a31575f80fd5b602001915036819003821315611173575f80fd5b663d9134b2111d1160c91b815284515f90611a67816007850160208a016110a8565b6e1116113a34b6b2b9ba30b6b8111d1160891b6007918401918201528551611a96816016840160208a016110a8565b6b1116113b32b939b4b7b7111d60a11b601692909101918201528451611ac38160228401602089016110a8565b71161132b834b22839b2bab237b73cb6911d1160711b602292909101918201528351611af68160348401602088016110a8565b016034019695505050505050565b5f8651611b15818460208b016110a8565b7011161130b23b34b9b7b93caaa926111d1160791b9083019081528651611b43816011840160208b016110a8565b6f11161130b23b34b9b7b93ca4a239911d60811b601192909101918201528551611b74816021840160208a016110a8565b7f2c22697376456e636c61766551756f7465537461747573223a22000000000000602192909101918201528451611bb281603b8401602089016110a8565b7f222c22697376456e636c61766551756f7465426f6479223a2200000000000000603b92909101918201528351611bf08160548401602088016110a8565b61227d60f01b60549290910191820152605601979650505050505050565b8082018082111561198957611989611962565b5f805f805f805f80610100898b031215611c39575f80fd5b88516001600160401b0380821115611c4f575f80fd5b611c5b8c838d0161176a565b995060208b0151915080821115611c70575f80fd5b611c7c8c838d0161176a565b985060408b0151915080821115611c91575f80fd5b611c9d8c838d0161176a565b975060608b0151915080821115611cb2575f80fd5b611cbe8c838d0161176a565b965060808b0151915080821115611cd3575f80fd5b611cdf8c838d0161176a565b955060a08b0151915080821115611cf4575f80fd5b611d008c838d0161176a565b945060c08b0151915080821115611d15575f80fd5b611d218c838d0161176a565b935060e08b0151915080821115611d36575f80fd5b50611d438b828c0161176a565b9150509295985092959890939650565b634e487b7160e01b5f52600160045260245ffd5b5f8085851115611d75575f80fd5b83861115611d81575f80fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015611db65780818660040360031b1b83161692505b505092915050565b6001600160a01b03841681526040602082018190525f9061112d90830184866116fe565b8681528560208201528460408201525f8451611e058160608501602089016110a8565b845190830190611e1c8160608401602089016110a8565b8451910190611e328160608401602088016110a8565b0160600198975050505050505050565b5f82611e5c57634e487b7160e01b5f52601260045260245ffd5b500490565b808202811582820484141761198957611989611962565b80518015158114611e87575f80fd5b919050565b5f8060408385031215611e9d575f80fd5b611ea683611e78565b9150602083015163ffffffff81168114611ebe575f80fd5b809150509250929050565b5f60208284031215611ed9575f80fd5b61141a82611e7856fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f9f3c647eb5773cbb512d2732c0d7415ebb55a0fa9ede2e649199e6821db910d53177370977466a6a5e4786ccd2ddebd4149d6a2f6325529dd10cc98737b0779c1a07e29c47a1ae004948476c489f45a5a15d7ac8ecc6acc645adb43d87679df59c093bc5a2e9696c5478541b979e754b573914be55d32ff4c09ddf27219934cd990527b3f92ed78fbf29246abecb71240ef39c2d7107b447545a7ffb10eb060a68a98580219e36910952683892d6a5e2a80803193e407531404e36b315623799aa825074409754a2dfe8f5afd5fe631e1fc2af3808906f28a790d9dd9fe060939b125790c5805d037df56a99531b96de69de33ed226cc1207d1042b5c9ab7f404fc711c0fe4769fb9578b1dc0ec469ea1a25e0ff9914886ef2699b235bb4847dd6ff40b606e6170793c2fb98b314587f9cfd257362dfeab10b3bd2d97673a1a4bd44c453aaf47fc1f2d3d0f384f74a06f89c089f0da6cdb7fceee8c9821a8e54f25c0416d18c46839a5f8012fbdd3dc74d256279adc2c0d55aff6f0622425d1b00000000000000000000000000000000000000000000000000000000000000640000000000000000000000008c1686069474410e6243425f4a10177a94ebee11
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106100b1575f3560e01c80637a9e5e4b1161006e5780637a9e5e4b146101735780637accaea4146101865780638c1c9085146101995780638fb36037146101ac578063bf7e214f146101cd578063fe4e6aee146101e7575f80fd5b806319d2be90146100b557806327a88ff0146100d357806328a55c21146100e85780633549c40e1461011d57806354a2da361461014057806361bb035514610160575b5f80fd5b6100bd6101fa565b6040516100ca91906110f5565b60405180910390f35b6100e66100e136600461117a565b61025e565b005b61010f7f000000000000000000000000000000000000000000000000000000000000006481565b6040519081526020016100ca565b61013061012b36600461129d565b6103ab565b60405190151581526020016100ca565b61015361014e366004611347565b610473565b6040516100ca9190611408565b61015361016e366004611421565b6104fd565b6100e6610181366004611504565b6105a1565b6100e661019436600461152a565b61061e565b6101306101a7366004611541565b610687565b6101b4610891565b6040516001600160e01b031990911681526020016100ca565b5f546040516001600160a01b0390911681526020016100ca565b6101536101f53660046115a1565b6108b3565b60408051808201909152606080825260208201526040518060400160405280604051806101a001604052806101808152602001611f23610180913981526020016040518060400160405280600381526020016201000160e81b815250815250905090565b5f8073e242c27cd0568feadc46f09811a55f9b24c754a463a21f157a8585604051806101a001604052806101808152602001611f2361018091396040518060400160405280600381526020016201000160e81b8152506040518563ffffffff1660e01b81526004016102d39493929190611726565b5f60405180830381865af41580156102ed573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261031491908101906117b4565b915091505f8484604051610329929190611813565b60408051918290038220828201825285835260208084018690525f828152600190915291909120825191935090819061036290826118a3565b506020820151600182019061037790826118a3565b50506040518291507f13b85b042d2bb270091da7111e3b3cc407f6b86c85882cf48ae94123cae22b17905f90a25050505050565b5f805f6103ee858589898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061092892505050565b915091505f61040b602083516104049190611976565b8390610942565b90508280156104665750600289604051610425919061198f565b602060405180830381855afa158015610440573d5f803e3d5ffd5b5050506040513d601f19601f8201168201806040525081019061046391906119aa565b81145b9998505050505050505050565b60605f806104b58b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061096492505050565b915091506104c6818a8a8a8a6103ab565b6104e357604051633f1a65c760e21b815260040160405180910390fd5b6104ee828686610a43565b9b9a5050505050505050505050565b60605f8073e242c27cd0568feadc46f09811a55f9b24c754a463a21f157a8989896040518463ffffffff1660e01b815260040161053c939291906119c1565b5f60405180830381865af4158015610556573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261057d91908101906117b4565b915091506105918c8c8c8c86868b8b610473565b9c9b505050505050505050505050565b5f5433906001600160a01b031681146105dc5760405162d1953b60e31b81526001600160a01b03821660048201526024015b60405180910390fd5b816001600160a01b03163b5f03610611576040516361798f2f60e11b81526001600160a01b03831660048201526024016105d3565b61061a82610b4f565b5050565b610629335f36610ba2565b5f81815260016020526040812061063f91611056565b5f818152600160208190526040822061065a92910190611056565b60405181907f0ebd07953ae533bded7d9b0715fa49e0a0ed0a6cef4638a685737ffef8b86254905f90a250565b5f7f00000000000000000000000000000000000000000000000000000000000000646106b38743611976565b11156106d257604051635d4ad9a960e01b815260040160405180910390fd5b5f60015f866040013581526020019081526020015f206040518060400160405290815f8201805461070290611822565b80601f016020809104026020016040519081016040528092919081815260200182805461072e90611822565b80156107795780601f1061075057610100808354040283529160200191610779565b820191905f5260205f20905b81548152906001019060200180831161075c57829003601f168201915b5050505050815260200160018201805461079290611822565b80601f01602080910402602001604051908101604052809291908181526020018280546107be90611822565b80156108095780601f106107e057610100808354040283529160200191610809565b820191905f5260205f20905b8154815290600101906020018083116107ec57829003601f168201915b50505091909252509192505f915061084190506108268780611a03565b61083360208a018a611a03565b865160208801518b8b610473565b90505f878940604051602001610861929190918252602082015260400190565b60405160208183030381529060405290508180519060200120818051906020012014935050505095945050505050565b5f8054600160a01b900460ff166108a757505f90565b50638fb3603760e01b90565b6060815f01518260200151836040015184606001516040516020016108db9493929190611a45565b60408051601f1981840301815290829052608084015160a085015160c086015160e087015193955061091294869490602001611b04565b6040516020818303038152906040529050919050565b5f6060610936838587610c98565b91509150935093915050565b81515f90610951836020611c0e565b111561095b575f80fd5b50016020015190565b6109ac60405180610100016040528060608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b60605f805f805f805f808a8060200190518101906109ca9190611c21565b975097509750975097509750975097505f6109e482610d2c565b90506040518061010001604052808a8152602001898152602001888152602001878152602001868152602001858152602001848152602001828152509a50610a2b8b6108b3565b60e08c019290925250989a9899505050505050505050565b60c083015180516020909101206060907fdaa4f5d475c02455977059e29f0bd4c2f7e92e8cfa8026b3dcd2c374e8a520e6811480610aa057507f174348b9c1e9ee5c57cffc36f0797c45d85e5ec45e51b2b17433eb33f56a215081145b610aec5760405162461bcd60e51b815260206004820152601960248201527f62616420697376456e636c61766551756f74655374617475730000000000000060448201526064016105d3565b60e085015180516101b014610b0357610b03611d53565b5f610b0f826070610942565b9050858114610b1c575f80fd5b5f610b288360b0610942565b9050858114610b35575f80fd5b610b43836101706040610e7a565b98975050505050505050565b5f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f658b440c35314f52658ea8a740e05b284cdc84dc9ae01e891f21b8933e7cad9060200160405180910390a150565b5f80610bd5610bb85f546001600160a01b031690565b8630610bc760045f898b611d67565b610bd091611d8e565b610ef9565b9150915081610c915763ffffffff811615610c6e575f805460ff60a01b198116600160a01b17909155604051634a63ebf760e11b81526001600160a01b03909116906394c7d7ee90610c2f90889088908890600401611dbe565b5f604051808303815f87803b158015610c46575f80fd5b505af1158015610c58573d5f803e3d5ffd5b50505f805460ff60a01b1916905550610c919050565b60405162d1953b60e31b81526001600160a01b03861660048201526024016105d3565b5050505050565b5f60605f855185518551888888604051602001610cba96959493929190611de2565b604051602081830303815290604052905083516001600160401b03811115610ce457610ce46111b8565b6040519080825280601f01601f191660200182016040528015610d0e576020820181803683370190505b50915083516020830182516020840160055afa925050935093915050565b606081515f03610d4957505060408051602081019091525f815290565b5f604051806060016040528060408152602001611ee36040913990505f600384516002610d769190611c0e565b610d809190611e42565b610d8b906004611e61565b6001600160401b03811115610da257610da26111b8565b6040519080825280601f01601f191660200182016040528015610dcc576020820181803683370190505b509050600182016020820185865187015b80821015610e38576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250610ddd565b5050600386510660018114610e545760028114610e6757610e6f565b603d6001830353603d6002830353610e6f565b603d60018303535b509195945050505050565b8251606090610e898385611c0e565b1115610e93575f80fd5b5f826001600160401b03811115610eac57610eac6111b8565b6040519080825280601f01601f191660200182016040528015610ed6576020820181803683370190505b50905060208082019086860101610eee828287611001565b509095945050505050565b6040516001600160a01b03848116602483015283811660448301526001600160e01b0319831660648301525f9182918291829189169060840160408051601f198184030181529181526020820180516001600160e01b031663b700961360e01b17905251610f67919061198f565b5f60405180830381855afa9150503d805f8114610f9f576040519150601f19603f3d011682016040523d82523d5f602084013e610fa4565b606091505b50915091508115610ff6576040815110610fd65780806020019051810190610fcc9190611e8c565b9094509250610ff6565b6020815110610ff65780806020019051810190610ff39190611ec9565b93505b505094509492505050565b602081106110395781518352611018602084611c0e565b9250611025602083611c0e565b9150611032602082611976565b9050611001565b905182516020929092036101000a5f190180199091169116179052565b50805461106290611822565b5f825580601f10611071575050565b601f0160209004905f5260205f209081019061108d9190611090565b50565b5b808211156110a4575f8155600101611091565b5090565b5f5b838110156110c25781810151838201526020016110aa565b50505f910152565b5f81518084526110e18160208601602086016110a8565b601f01601f19169290920160200192915050565b602081525f82516040602084015261111060608401826110ca565b90506020840151601f1984830301604085015261112d82826110ca565b95945050505050565b5f8083601f840112611146575f80fd5b5081356001600160401b0381111561115c575f80fd5b602083019150836020828501011115611173575f80fd5b9250929050565b5f806020838503121561118b575f80fd5b82356001600160401b038111156111a0575f80fd5b6111ac85828601611136565b90969095509350505050565b634e487b7160e01b5f52604160045260245ffd5b60405161010081016001600160401b03811182821017156111ef576111ef6111b8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561121d5761121d6111b8565b604052919050565b5f6001600160401b0382111561123d5761123d6111b8565b50601f01601f191660200190565b5f82601f83011261125a575f80fd5b813561126d61126882611225565b6111f5565b818152846020838601011115611281575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f805f608086880312156112b1575f80fd5b85356001600160401b03808211156112c7575f80fd5b6112d389838a0161124b565b965060208801359150808211156112e8575f80fd5b6112f489838a01611136565b9096509450604088013591508082111561130c575f80fd5b61131889838a0161124b565b9350606088013591508082111561132d575f80fd5b5061133a8882890161124b565b9150509295509295909350565b5f805f805f805f8060c0898b03121561135e575f80fd5b88356001600160401b0380821115611374575f80fd5b6113808c838d01611136565b909a50985060208b0135915080821115611398575f80fd5b6113a48c838d01611136565b909850965060408b01359150808211156113bc575f80fd5b6113c88c838d0161124b565b955060608b01359150808211156113dd575f80fd5b506113ea8b828c0161124b565b9350506080890135915060a089013590509295985092959890939650565b602081525f61141a60208301846110ca565b9392505050565b5f805f805f805f805f60e08a8c031215611439575f80fd5b89356001600160401b038082111561144f575f80fd5b61145b8d838e01611136565b909b50995060208c0135915080821115611473575f80fd5b61147f8d838e01611136565b909950975060408c0135915080821115611497575f80fd5b6114a38d838e0161124b565b965060608c01359150808211156114b8575f80fd5b6114c48d838e0161124b565b955060808c01359150808211156114d9575f80fd5b506114e68c828d0161124b565b93505060a08a0135915060c08a013590509295985092959850929598565b5f60208284031215611514575f80fd5b81356001600160a01b038116811461141a575f80fd5b5f6020828403121561153a575f80fd5b5035919050565b5f805f805f60a08688031215611555575f80fd5b853594506020860135935060408601356001600160401b03811115611578575f80fd5b860160608189031215611589575f80fd5b94979396509394606081013594506080013592915050565b5f602082840312156115b1575f80fd5b81356001600160401b03808211156115c7575f80fd5b9083019061010082860312156115db575f80fd5b6115e36111cc565b8235828111156115f1575f80fd5b6115fd8782860161124b565b825250602083013582811115611611575f80fd5b61161d8782860161124b565b602083015250604083013582811115611634575f80fd5b6116408782860161124b565b604083015250606083013582811115611657575f80fd5b6116638782860161124b565b60608301525060808301358281111561167a575f80fd5b6116868782860161124b565b60808301525060a08301358281111561169d575f80fd5b6116a98782860161124b565b60a08301525060c0830135828111156116c0575f80fd5b6116cc8782860161124b565b60c08301525060e0830135828111156116e3575f80fd5b6116ef8782860161124b565b60e08301525095945050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b606081525f6117396060830186886116fe565b828103602084015261174b81866110ca565b9050828103604084015261175f81856110ca565b979650505050505050565b5f82601f830112611779575f80fd5b815161178761126882611225565b81815284602083860101111561179b575f80fd5b6117ac8260208301602087016110a8565b949350505050565b5f80604083850312156117c5575f80fd5b82516001600160401b03808211156117db575f80fd5b6117e78683870161176a565b935060208501519150808211156117fc575f80fd5b506118098582860161176a565b9150509250929050565b818382375f9101908152919050565b600181811c9082168061183657607f821691505b60208210810361185457634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561189e57805f5260205f20601f840160051c8101602085101561187f5750805b601f840160051c820191505b81811015610c91575f815560010161188b565b505050565b81516001600160401b038111156118bc576118bc6111b8565b6118d0816118ca8454611822565b8461185a565b602080601f831160018114611903575f84156118ec5750858301515b5f19600386901b1c1916600185901b17855561195a565b5f85815260208120601f198616915b8281101561193157888601518255948401946001909101908401611912565b508582101561194e57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561198957611989611962565b92915050565b5f82516119a08184602087016110a8565b9190910192915050565b5f602082840312156119ba575f80fd5b5051919050565b606081525f6119d360608301866110ca565b82810360208401526119e581866110ca565b905082810360408401526119f981856110ca565b9695505050505050565b5f808335601e19843603018112611a18575f80fd5b8301803591506001600160401b03821115611a31575f80fd5b602001915036819003821315611173575f80fd5b663d9134b2111d1160c91b815284515f90611a67816007850160208a016110a8565b6e1116113a34b6b2b9ba30b6b8111d1160891b6007918401918201528551611a96816016840160208a016110a8565b6b1116113b32b939b4b7b7111d60a11b601692909101918201528451611ac38160228401602089016110a8565b71161132b834b22839b2bab237b73cb6911d1160711b602292909101918201528351611af68160348401602088016110a8565b016034019695505050505050565b5f8651611b15818460208b016110a8565b7011161130b23b34b9b7b93caaa926111d1160791b9083019081528651611b43816011840160208b016110a8565b6f11161130b23b34b9b7b93ca4a239911d60811b601192909101918201528551611b74816021840160208a016110a8565b7f2c22697376456e636c61766551756f7465537461747573223a22000000000000602192909101918201528451611bb281603b8401602089016110a8565b7f222c22697376456e636c61766551756f7465426f6479223a2200000000000000603b92909101918201528351611bf08160548401602088016110a8565b61227d60f01b60549290910191820152605601979650505050505050565b8082018082111561198957611989611962565b5f805f805f805f80610100898b031215611c39575f80fd5b88516001600160401b0380821115611c4f575f80fd5b611c5b8c838d0161176a565b995060208b0151915080821115611c70575f80fd5b611c7c8c838d0161176a565b985060408b0151915080821115611c91575f80fd5b611c9d8c838d0161176a565b975060608b0151915080821115611cb2575f80fd5b611cbe8c838d0161176a565b965060808b0151915080821115611cd3575f80fd5b611cdf8c838d0161176a565b955060a08b0151915080821115611cf4575f80fd5b611d008c838d0161176a565b945060c08b0151915080821115611d15575f80fd5b611d218c838d0161176a565b935060e08b0151915080821115611d36575f80fd5b50611d438b828c0161176a565b9150509295985092959890939650565b634e487b7160e01b5f52600160045260245ffd5b5f8085851115611d75575f80fd5b83861115611d81575f80fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015611db65780818660040360031b1b83161692505b505092915050565b6001600160a01b03841681526040602082018190525f9061112d90830184866116fe565b8681528560208201528460408201525f8451611e058160608501602089016110a8565b845190830190611e1c8160608401602089016110a8565b8451910190611e328160608401602088016110a8565b0160600198975050505050505050565b5f82611e5c57634e487b7160e01b5f52601260045260245ffd5b500490565b808202811582820484141761198957611989611962565b80518015158114611e87575f80fd5b919050565b5f8060408385031215611e9d575f80fd5b611ea683611e78565b9150602083015163ffffffff81168114611ebe575f80fd5b809150509250929050565b5f60208284031215611ed9575f80fd5b61141a82611e7856fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f9f3c647eb5773cbb512d2732c0d7415ebb55a0fa9ede2e649199e6821db910d53177370977466a6a5e4786ccd2ddebd4149d6a2f6325529dd10cc98737b0779c1a07e29c47a1ae004948476c489f45a5a15d7ac8ecc6acc645adb43d87679df59c093bc5a2e9696c5478541b979e754b573914be55d32ff4c09ddf27219934cd990527b3f92ed78fbf29246abecb71240ef39c2d7107b447545a7ffb10eb060a68a98580219e36910952683892d6a5e2a80803193e407531404e36b315623799aa825074409754a2dfe8f5afd5fe631e1fc2af3808906f28a790d9dd9fe060939b125790c5805d037df56a99531b96de69de33ed226cc1207d1042b5c9ab7f404fc711c0fe4769fb9578b1dc0ec469ea1a25e0ff9914886ef2699b235bb4847dd6ff40b606e6170793c2fb98b314587f9cfd257362dfeab10b3bd2d97673a1a4bd44c453aaf47fc1f2d3d0f384f74a06f89c089f0da6cdb7fceee8c9821a8e54f25c0416d18c46839a5f8012fbdd3dc74d256279adc2c0d55aff6f0622425d1b
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000640000000000000000000000008c1686069474410e6243425f4a10177a94ebee11
-----Decoded View---------------
Arg [0] : freshnessBlocks (uint256): 100
Arg [1] : accessManager (address): 0x8c1686069474410E6243425f4a10177a94EBEE11
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000064
Arg [1] : 0000000000000000000000008c1686069474410e6243425f4a10177a94ebee11
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.