Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | Amount | ||
|---|---|---|---|---|---|---|
| 10501850 | 732 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
SoulWalletDefaultValidator
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 100000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
import {IValidator} from "@soulwallet-core/contracts/interface/IValidator.sol";
import {IOwnable} from "@soulwallet-core/contracts/interface/IOwnable.sol";
import {PackedUserOperation} from "@soulwallet-core/contracts/interface/IHook.sol";
import "@account-abstraction/contracts/core/Helpers.sol";
import "./libraries/ValidatorSigDecoder.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {Errors} from "../libraries/Errors.sol";
import {TypeConversion} from "../libraries/TypeConversion.sol";
import {WebAuthn} from "../libraries/WebAuthn.sol";
/**
* @title SoulWalletDefaultValidator
* @dev A contract that implements the IValidator interface for validating user operations and signatures.
*/
contract SoulWalletDefaultValidator is IValidator {
// Magic value indicating a valid signature for ERC-1271 contracts
// bytes4(keccak256("isValidSignature(bytes32,bytes)")
bytes4 internal constant MAGICVALUE = 0x1626ba7e;
// Constants indicating different invalid states
bytes4 internal constant INVALID_ID = 0xffffffff;
bytes4 internal constant INVALID_TIME_RANGE = 0xfffffffe;
// Utility for Ethereum typed structured data hashing
using MessageHashUtils for bytes32;
using TypeConversion for address;
function validateUserOp(PackedUserOperation calldata, bytes32 userOpHash, bytes calldata validatorSignature)
external
view
override
returns (uint256 validationData)
{
uint8 signatureType;
bytes calldata signature;
(signatureType, validationData, signature) = ValidatorSigDecoder.decodeValidatorSignature(validatorSignature);
bytes32 hash = _packSignatureHash(userOpHash, signatureType, validationData);
bytes32 recovered;
bool success;
(recovered, success) = recover(signatureType, hash, signature);
if (!success) {
return SIG_VALIDATION_FAILED;
}
bool ownerCheck = _isOwner(recovered);
if (!ownerCheck) {
return SIG_VALIDATION_FAILED;
}
return validationData;
}
function validateSignature(address, /*unused sender*/ bytes32 rawHash, bytes calldata validatorSignature)
external
view
override
returns (bytes4 magicValue)
{
uint8 signatureType;
bytes calldata signature;
uint256 validationData;
(signatureType, validationData, signature) = ValidatorSigDecoder.decodeValidatorSignature(validatorSignature);
bytes32 hash = _pack1271SignatureHash(rawHash, signatureType, validationData);
bytes32 recovered;
bool success;
(recovered, success) = recover(signatureType, hash, signature);
if (!success) {
return INVALID_ID;
}
bool ownerCheck = _isOwner(recovered);
if (!ownerCheck) {
return INVALID_ID;
}
if (validationData > 0) {
ValidationData memory _validationData = _parseValidationData(validationData);
bool outOfTimeRange =
(block.timestamp > _validationData.validUntil) || (block.timestamp < _validationData.validAfter);
if (outOfTimeRange) {
return INVALID_TIME_RANGE;
}
}
return MAGICVALUE;
}
function _packSignatureHash(bytes32 hash, uint8 signatureType, uint256 validationData)
internal
pure
returns (bytes32 packedHash)
{
if (signatureType == 0x0) {
packedHash = hash.toEthSignedMessageHash();
} else if (signatureType == 0x1) {
packedHash = keccak256(abi.encodePacked(hash, validationData)).toEthSignedMessageHash();
} else if (signatureType == 0x2) {
// passkey sign doesn't need toEthSignedMessageHash
packedHash = hash;
} else if (signatureType == 0x3) {
// passkey sign doesn't need toEthSignedMessageHash
packedHash = keccak256(abi.encodePacked(hash, validationData));
} else {
revert Errors.INVALID_SIGNTYPE();
}
}
function _pack1271SignatureHash(bytes32 hash, uint8 signatureType, uint256 validationData)
internal
pure
returns (bytes32 packedHash)
{
if (signatureType == 0x0) {
packedHash = hash;
} else if (signatureType == 0x1) {
packedHash = keccak256(abi.encodePacked(hash, validationData));
} else if (signatureType == 0x2) {
packedHash = hash;
} else if (signatureType == 0x3) {
packedHash = keccak256(abi.encodePacked(hash, validationData));
} else {
revert Errors.INVALID_SIGNTYPE();
}
}
function _isOwner(bytes32 recovered) private view returns (bool isOwner) {
return IOwnable(address(msg.sender)).isOwner(recovered);
}
function recover(uint8 signatureType, bytes32 rawHash, bytes calldata rawSignature)
internal
view
returns (bytes32 recovered, bool success)
{
if (signatureType == 0x0 || signatureType == 0x1) {
//ecdas recover
(address recoveredAddr, ECDSA.RecoverError error,) = ECDSA.tryRecover(rawHash, rawSignature);
if (error != ECDSA.RecoverError.NoError) {
success = false;
} else {
success = true;
}
recovered = recoveredAddr.toBytes32();
} else if (signatureType == 0x2 || signatureType == 0x3) {
bytes32 publicKey = WebAuthn.recover(rawHash, rawSignature);
if (publicKey == 0) {
recovered = publicKey;
success = false;
} else {
recovered = publicKey;
success = true;
}
} else {
revert Errors.INVALID_SIGNTYPE();
}
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IValidator).interfaceId;
}
function Init(bytes calldata) external override {}
function DeInit() external override {}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;
import {PackedUserOperation} from "../interface/IAccount.sol";
import {IPluggable} from "./IPluggable.sol";
interface IValidator is IPluggable {
/*
NOTE: Any implementation must ensure that the `validatorSignature` exactly matches your expectations,
otherwise, you will face security risks.
For example:
if you do not require any `validatorSignature`, make sure your implementation included the following code:
`require(validatorSignature.length == 0)`
*/
/**
* @dev EIP-1271 Should return whether the signature provided is valid for the provided data
* @param sender Address of the message sender
* @param hash Hash of the data to be signed
* @param validatorSignature Signature byte array associated with _data
*/
function validateSignature(address sender, bytes32 hash, bytes memory validatorSignature)
external
view
returns (bytes4 magicValue);
/**
* @dev EIP-4337 validate PackedUserOperation
* NOTE: Do not rely on PackedUserOperation.signature, which may be empty in some versions of the implementation, see: /contracts/utils/CalldataPack.sol
* @param userOp the operation that is about to be executed.
* @param userOpHash hash of the user's request data. can be used as the basis for signature.
* @param validatorSignature Signature
* @return validationData packaged ValidationData structure. use `_packValidationData` and `_unpackValidationData` to encode and decode
* <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,
* otherwise, an address of an "authorizer" contract.
* <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite"
* <6-byte> validAfter - first timestamp this operation is valid
* If an account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.
* Note that the validation code cannot use block.timestamp (or block.number) directly.
*/
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, bytes calldata validatorSignature)
external
returns (uint256 validationData);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
interface IOwnable {
/**
* @notice Checks if a given bytes32 ID corresponds to an owner within the system
* @param owner The bytes32 ID to check
* @return True if the ID corresponds to an owner, false otherwise
*/
function isOwner(bytes32 owner) external view returns (bool);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;
import {PackedUserOperation} from "../interface/IAccount.sol";
import {IPluggable} from "./IPluggable.sol";
interface IHook is IPluggable {
/*
NOTE: Any implementation must ensure that the `hookSignature` exactly matches your expectations,
otherwise, you will face security risks.
For example:
if you do not require any `hookSignature`, make sure your implementation included the following code:
`require(hookSignature.length == 0)`
NOTE: All implemention must ensure that the DeInit() function can be covered by 100,000 gas in all scenarios.
*/
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param hookSignature Signature byte array associated with _data
*/
function preIsValidSignatureHook(bytes32 hash, bytes calldata hookSignature) external view;
/**
* @dev Hook that is called before any userOp is executed.
* NOTE: Do not rely on userOperation.signature, which may be empty in some versions of the implementation. see: /contracts/utils/CalldataPack.sol
* must revert if the userOp is invalid.
*/
function preUserOpValidationHook(
PackedUserOperation calldata userOp,
bytes32 userOpHash,
uint256 missingAccountFunds,
bytes calldata hookSignature
) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;
/* solhint-disable no-inline-assembly */
/*
* For simulation purposes, validateUserOp (and validatePaymasterUserOp)
* must return this value in case of signature failure, instead of revert.
*/
uint256 constant SIG_VALIDATION_FAILED = 1;
/*
* For simulation purposes, validateUserOp (and validatePaymasterUserOp)
* return this value on success.
*/
uint256 constant SIG_VALIDATION_SUCCESS = 0;
/**
* Returned data from validateUserOp.
* validateUserOp returns a uint256, which is created by `_packedValidationData` and
* parsed by `_parseValidationData`.
* @param aggregator - address(0) - The account validated the signature by itself.
* address(1) - The account failed to validate the signature.
* otherwise - This is an address of a signature aggregator that must
* be used to validate the signature.
* @param validAfter - This UserOp is valid only after this timestamp.
* @param validaUntil - This UserOp is valid only up to this timestamp.
*/
struct ValidationData {
address aggregator;
uint48 validAfter;
uint48 validUntil;
}
/**
* Extract sigFailed, validAfter, validUntil.
* Also convert zero validUntil to type(uint48).max.
* @param validationData - The packed validation data.
*/
function _parseValidationData(
uint256 validationData
) pure returns (ValidationData memory data) {
address aggregator = address(uint160(validationData));
uint48 validUntil = uint48(validationData >> 160);
if (validUntil == 0) {
validUntil = type(uint48).max;
}
uint48 validAfter = uint48(validationData >> (48 + 160));
return ValidationData(aggregator, validAfter, validUntil);
}
/**
* Helper to pack the return value for validateUserOp.
* @param data - The ValidationData to pack.
*/
function _packValidationData(
ValidationData memory data
) pure returns (uint256) {
return
uint160(data.aggregator) |
(uint256(data.validUntil) << 160) |
(uint256(data.validAfter) << (160 + 48));
}
/**
* Helper to pack the return value for validateUserOp, when not using an aggregator.
* @param sigFailed - True for signature failure, false for success.
* @param validUntil - Last timestamp this UserOperation is valid (or zero for infinite).
* @param validAfter - First timestamp this UserOperation is valid.
*/
function _packValidationData(
bool sigFailed,
uint48 validUntil,
uint48 validAfter
) pure returns (uint256) {
return
(sigFailed ? 1 : 0) |
(uint256(validUntil) << 160) |
(uint256(validAfter) << (160 + 48));
}
/**
* keccak function over calldata.
* @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.
*/
function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {
assembly ("memory-safe") {
let mem := mload(0x40)
let len := data.length
calldatacopy(mem, data.offset, len)
ret := keccak256(mem, len)
}
}
/**
* The minimum of two numbers.
* @param a - First number.
* @param b - Second number.
*/
function min(uint256 a, uint256 b) pure returns (uint256) {
return a < b ? a : b;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
library ValidatorSigDecoder {
/*
validator signature format
+----------------------------------------------------------+
| |
| validator signature |
| |
+-------------------------------+--------------------------+
| signature type | signature data |
+-------------------------------+--------------------------+
| | |
| 1 byte | ...... |
| | |
+-------------------------------+--------------------------+
A: signature type 0: eoa sig without validation data
+------------------------------------------------------------------------+
| |
| validator signature |
| |
+--------------------------+----------------------------------------------+
| signature type | signature data |
+--------------------------+----------------------------------------------+
| | |
| 0x00 | 65 bytes |
| | |
+--------------------------+----------------------------------------------+
B: signature type 1: eoa sig with validation data
+-------------------------------------------------------------------------------------+
| |
| validator signature |
| |
+-------------------------------+--------------------------+---------------------------+
| signature type | validationData | signature data |
+-------------------------------+--------------------------+---------------------------+
| | | |
| 0x01 | uint256 32 bytes | 65 bytes |
| | | |
+-------------------------------+--------------------------+---------------------------+
C: signature type 2: passkey sig without validation data
-----------------------------------------------------------------------------------------------------------------+
| |
| validator singature |
| |
+-------------------+--------------------------------------------------------------------------------------------+
| | |
| signature type | signature data |
| | |
+----------------------------------------------------------------------------------------------------------------+
| | |
| | |
| 0x02 | passkey dynamic signature |
| | |
| | |
+-------------------+--------------------------------------------------------------------------------------------+
D: signature type 3: passkey sig without validation data
------------------------------------------------------------------------------------------------------------------------------------+
| |
| validator singature |
| |
+-----------------+--------------------+--------------------------------------------------------------------------------------------+
| | | |
| sig type | validation data | signature data |
| | | |
+-----------------------------------------------------------------------------------------------------------------------------------+
| | | |
| 0x03 | uint256 | passkey dynamic signature |
| | 32 bytes | |
+-----------------+--------------------+--------------------------------------------------------------------------------------------+
*/
function decodeValidatorSignature(
bytes calldata validatorSignature
)
internal
pure
returns (
uint8 signatureType,
uint256 validationData,
bytes calldata signature
)
{
require(
validatorSignature.length >= 1,
"validator signature too short"
);
signatureType = uint8(bytes1(validatorSignature[0:1]));
if (signatureType == 0x0) {
require(
validatorSignature.length == 66,
"invalid validator signature length"
);
validationData = 0;
signature = validatorSignature[1:66];
} else if (signatureType == 0x1) {
require(
validatorSignature.length == 98,
"invalid validator signature length"
);
validationData = uint256(bytes32(validatorSignature[1:33]));
signature = validatorSignature[33:98];
} else if (signatureType == 0x2) {
require(
validatorSignature.length >= 129,
"invalid validator signature length"
);
validationData = 0;
signature = validatorSignature[1:];
} else if (signatureType == 0x3) {
require(
validatorSignature.length >= 161,
"invalid validator signature length"
);
validationData = uint256(bytes32(validatorSignature[1:33]));
signature = validatorSignature[33:];
} else {
revert("invalid validator signature type");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
library Errors {
error ADDRESS_ALREADY_EXISTS();
error ADDRESS_NOT_EXISTS();
error DATA_ALREADY_EXISTS();
error DATA_NOT_EXISTS();
error CALLER_MUST_BE_ENTRYPOINT();
error CALLER_MUST_BE_SELF_OR_MODULE();
error CALLER_MUST_BE_MODULE();
error HASH_ALREADY_APPROVED();
error HASH_ALREADY_REJECTED();
error INVALID_ADDRESS();
error INVALID_GUARD_HOOK_DATA();
error INVALID_SELECTOR();
error INVALID_SIGNTYPE();
error MODULE_ADDRESS_EMPTY();
error MODULE_NOT_SUPPORT_INTERFACE();
error MODULE_SELECTOR_UNAUTHORIZED();
error MODULE_SELECTORS_EMPTY();
error MODULE_EXECUTE_FROM_MODULE_RECURSIVE();
error NO_OWNER();
error SELECTOR_ALREADY_EXISTS();
error SELECTOR_NOT_EXISTS();
error UNSUPPORTED_SIGNTYPE();
error INVALID_LOGIC_ADDRESS();
error SAME_LOGIC_ADDRESS();
error UPGRADE_FAILED();
error NOT_IMPLEMENTED();
error INVALID_SIGNATURE();
error ALERADY_INITIALIZED();
error INVALID_KEY();
error NOT_INITIALIZED();
error INVALID_TIME_RANGE();
error UNAUTHORIZED();
error INVALID_DATA();
error GUARDIAN_SIGNATURE_INVALID();
error UNTRUSTED_KEYSTORE_LOGIC();
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
/**
* @title TypeConversion
* @notice A library to facilitate address to bytes32 conversions
*/
library TypeConversion {
/**
* @notice Converts an address to bytes32
* @param addr The address to be converted
* @return Resulting bytes32 representation of the input address
*/
function toBytes32(address addr) internal pure returns (bytes32) {
return bytes32(uint256(uint160(addr)));
}
/**
* @notice Converts an array of addresses to an array of bytes32
* @param addresses Array of addresses to be converted
* @return Array of bytes32 representations of the input addresses
*/
function addressesToBytes32Array(address[] memory addresses) internal pure returns (bytes32[] memory) {
bytes32[] memory result = new bytes32[](addresses.length);
for (uint256 i = 0; i < addresses.length; i++) {
result[i] = toBytes32(addresses[i]);
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Base64Url} from "./Base64Url.sol";
import {FCL_Elliptic_ZZ} from "./FCL_elliptic.sol";
import {RS256Verify} from "./RS256Verify.sol";
library WebAuthn {
/**
* @dev Prefix for client data
* defined in:
* 1. https://www.w3.org/TR/webauthn-2/#dictdef-collectedclientdata
* 2. https://www.w3.org/TR/webauthn-2/#clientdatajson-serialization
*/
string private constant ClIENTDATA_PREFIX = "{\"type\":\"webauthn.get\",\"challenge\":\"";
/**
* @dev Verify WebAuthN signature
* @param Qx public key point - x
* @param Qy public key point - y
* @param r signature - r
* @param s signature - s
* @param challenge https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialcreationoptions-challenge
* @param authenticatorData https://www.w3.org/TR/webauthn-2/#assertioncreationdata-authenticatordataresult
* @param clientDataSuffix https://www.w3.org/TR/webauthn-2/#clientdatajson-serialization
*/
function verifyP256Signature(
uint256 Qx,
uint256 Qy,
uint256 r,
uint256 s,
bytes32 challenge,
bytes memory authenticatorData,
string memory clientDataSuffix
) internal view returns (bool) {
bytes memory challengeBase64 = bytes(Base64Url.encode(bytes.concat(challenge)));
bytes memory clientDataJSON = bytes.concat(bytes(ClIENTDATA_PREFIX), challengeBase64, bytes(clientDataSuffix));
bytes32 clientHash = sha256(clientDataJSON);
bytes32 message = sha256(bytes.concat(authenticatorData, clientHash));
return FCL_Elliptic_ZZ.ecdsa_verify(message, r, s, Qx, Qy);
}
/**
* @dev Verify WebAuthN signature
* @param Qx public key point - x
* @param Qy public key point - y
* @param r signature - r
* @param s signature - s
* @param challenge https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialcreationoptions-challenge
* @param authenticatorData https://www.w3.org/TR/webauthn-2/#assertioncreationdata-authenticatordataresult
* @param clientDataPrefix https://www.w3.org/TR/webauthn-2/#clientdatajson-serialization
* @param clientDataSuffix https://www.w3.org/TR/webauthn-2/#clientdatajson-serialization
*/
function verifyP256Signature(
uint256 Qx,
uint256 Qy,
uint256 r,
uint256 s,
bytes32 challenge,
bytes memory authenticatorData,
string memory clientDataPrefix,
string memory clientDataSuffix
) internal view returns (bool) {
bytes memory challengeBase64 = bytes(Base64Url.encode(bytes.concat(challenge)));
bytes memory clientDataJSON = bytes.concat(bytes(clientDataPrefix), challengeBase64, bytes(clientDataSuffix));
bytes32 clientHash = sha256(clientDataJSON);
bytes32 message = sha256(bytes.concat(authenticatorData, clientHash));
return FCL_Elliptic_ZZ.ecdsa_verify(message, r, s, Qx, Qy);
}
function decodeP256Signature(bytes calldata packedSignature)
internal
pure
returns (
uint256 r,
uint256 s,
uint8 v,
bytes calldata authenticatorData,
bytes calldata clientDataPrefix,
bytes calldata clientDataSuffix
)
{
/*
signature layout:
1. r (32 bytes)
2. s (32 bytes)
3. v (1 byte)
4. authenticatorData length (2 byte max 65535)
5. clientDataPrefix length (2 byte max 65535)
6. authenticatorData
7. clientDataPrefix
8. clientDataSuffix
*/
uint256 authenticatorDataLength;
uint256 clientDataPrefixLength;
assembly ("memory-safe") {
let calldataOffset := packedSignature.offset
r := calldataload(calldataOffset)
s := calldataload(add(calldataOffset, 0x20))
let lengthData :=
and(
calldataload(add(calldataOffset, 0x25 /* 32+5 */ )),
0xffffffffff /* v+authenticatorDataLength+clientDataPrefixLength */
)
v := shr(0x20, /* 4*8 */ lengthData)
authenticatorDataLength := and(shr(0x10, /* 2*8 */ lengthData), 0xffff)
clientDataPrefixLength := and(lengthData, 0xffff)
}
unchecked {
uint256 _dataOffset1 = 0x45; // 32+32+1+2+2
uint256 _dataOffset2 = 0x45 + authenticatorDataLength;
authenticatorData = packedSignature[_dataOffset1:_dataOffset2];
_dataOffset1 = _dataOffset2 + clientDataPrefixLength;
clientDataPrefix = packedSignature[_dataOffset2:_dataOffset1];
clientDataSuffix = packedSignature[_dataOffset1:];
}
}
/**
* @dev Recover public key from signature
*/
function recover_p256(bytes32 userOpHash, bytes calldata packedSignature) internal view returns (bytes32) {
uint256 r;
uint256 s;
uint8 v;
bytes calldata authenticatorData;
bytes calldata clientDataPrefix;
bytes calldata clientDataSuffix;
(r, s, v, authenticatorData, clientDataPrefix, clientDataSuffix) = decodeP256Signature(packedSignature);
bytes memory challengeBase64 = bytes(Base64Url.encode(bytes.concat(userOpHash)));
bytes memory clientDataJSON;
if (clientDataPrefix.length == 0) {
clientDataJSON = bytes.concat(bytes(ClIENTDATA_PREFIX), challengeBase64, clientDataSuffix);
} else {
clientDataJSON = bytes.concat(clientDataPrefix, challengeBase64, clientDataSuffix);
}
bytes32 clientHash = sha256(clientDataJSON);
bytes32 message = sha256(bytes.concat(authenticatorData, clientHash));
return FCL_Elliptic_ZZ.ec_recover_r1(uint256(message), v, r, s);
}
function decodeRS256Signature(bytes calldata packedSignature)
internal
pure
returns (
bytes calldata n,
bytes calldata signature,
bytes calldata authenticatorData,
bytes calldata clientDataPrefix,
bytes calldata clientDataSuffix
)
{
/*
Note: currently use a fixed public exponent=0x010001. This is enough for the currently WebAuthn implementation.
signature layout:
1. n(exponent) length (2 byte max to 8192 bits key)
2. authenticatorData length (2 byte max 65535)
3. clientDataPrefix length (2 byte max 65535)
4. n(exponent) (exponent,dynamic bytes)
5. signature (signature,signature.length== n.length)
6. authenticatorData
7. clientDataPrefix
8. clientDataSuffix
*/
uint256 exponentLength;
uint256 authenticatorDataLength;
uint256 clientDataPrefixLength;
assembly ("memory-safe") {
let calldataOffset := packedSignature.offset
let lengthData :=
shr(
0xd0, // 8*(32-6), exponentLength+authenticatorDataLength+clientDataPrefixLength
calldataload(calldataOffset)
)
exponentLength := shr(0x20, /* 4*8 */ lengthData)
authenticatorDataLength := and(shr(0x10, /* 2*8 */ lengthData), 0xffff)
clientDataPrefixLength := and(lengthData, 0xffff)
}
unchecked {
uint256 _dataOffset1 = 0x06; // 2+2+2
uint256 _dataOffset2 = 0x06 + exponentLength;
n = packedSignature[_dataOffset1:_dataOffset2];
_dataOffset1 = _dataOffset2 + exponentLength;
signature = packedSignature[_dataOffset2:_dataOffset1];
_dataOffset2 = _dataOffset1 + authenticatorDataLength;
authenticatorData = packedSignature[_dataOffset1:_dataOffset2];
_dataOffset1 = _dataOffset2 + clientDataPrefixLength;
clientDataPrefix = packedSignature[_dataOffset2:_dataOffset1];
clientDataSuffix = packedSignature[_dataOffset1:];
}
}
/**
* @dev Recover public key from signature
* in current version, only support e=65537
*/
function recover_rs256(bytes32 userOpHash, bytes calldata packedSignature) internal view returns (bytes32) {
bytes calldata n;
bytes calldata signature;
bytes calldata authenticatorData;
bytes calldata clientDataPrefix;
bytes calldata clientDataSuffix;
(n, signature, authenticatorData, clientDataPrefix, clientDataSuffix) = decodeRS256Signature(packedSignature);
bytes memory challengeBase64 = bytes(Base64Url.encode(bytes.concat(userOpHash)));
bytes memory clientDataJSON;
if (clientDataPrefix.length == 0) {
clientDataJSON = bytes.concat(bytes(ClIENTDATA_PREFIX), challengeBase64, clientDataSuffix);
} else {
clientDataJSON = bytes.concat(clientDataPrefix, challengeBase64, clientDataSuffix);
}
bytes32 clientHash = sha256(clientDataJSON);
bytes32 messageHash = sha256(bytes.concat(authenticatorData, clientHash));
// Note: currently use a fixed public exponent=0x010001. This is enough for the currently WebAuthn implementation.
bytes memory e = hex"0000000000000000000000000000000000000000000000000000000000010001";
bool success = RS256Verify.RSASSA_PSS_VERIFY(n, e, messageHash, signature);
if (success) {
return keccak256(abi.encodePacked(e, n));
} else {
return bytes32(0);
}
}
/**
* @dev Recover public key from signature
* currently support: ES256(P256), RS256(e=65537)
*/
function recover(bytes32 hash, bytes calldata signature) internal view returns (bytes32) {
/*
signature layout:
1. algorithmType (1 bytes)
2. signature
algorithmType:
0x0: ES256(P256)
0x1: RS256(e=65537)
*/
uint8 algorithmType = uint8(signature[0]);
if (algorithmType == 0x0) {
return recover_p256(hash, signature[1:]);
} else if (algorithmType == 0x1) {
return recover_rs256(hash, signature[1:]);
} else {
revert("invalid algorithm type");
}
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;
// refer: https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/interfaces/IAccount.sol
import {PackedUserOperation} from "@account-abstraction/contracts/interfaces/PackedUserOperation.sol";
interface IAccount {
/**
* Validate user's signature and nonce
* the entryPoint will make the call to the recipient only if this validation call returns successfully.
* signature failure should be reported by returning SIG_VALIDATION_FAILED (1).
* This allows making a "simulation call" without a valid signature
* Other failures (e.g. nonce mismatch, or invalid signature format) should still revert to signal failure.
*
* @dev Must validate caller is the entryPoint.
* Must validate the signature and nonce
* @param userOp - The operation that is about to be executed.
* @param userOpHash - Hash of the user's request data. can be used as the basis for signature.
* @param missingAccountFunds - Missing funds on the account's deposit in the entrypoint.
* This is the minimum amount to transfer to the sender(entryPoint) to be
* able to make the call. The excess is left as a deposit in the entrypoint
* for future calls. Can be withdrawn anytime using "entryPoint.withdrawTo()".
* In case there is a paymaster in the request (or the current deposit is high
* enough), this value will be zero.
* @return validationData - Packaged ValidationData structure. use `_packValidationData` and
* `_unpackValidationData` to encode and decode.
* <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,
* otherwise, an address of an "authorizer" contract.
* <6-byte> validUntil - Last timestamp this operation is valid. 0 for "indefinite"
* <6-byte> validAfter - First timestamp this operation is valid
* If an account doesn't use time-range, it is enough to
* return SIG_VALIDATION_FAILED value (1) for signature failure.
* Note that the validation code cannot use block.timestamp (or block.number) directly.
*/
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
external
payable
returns (uint256 validationData);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title Pluggable Interface
* @dev This interface provides functionalities for initializing and deinitializing wallet-related plugins or modules
*/
interface IPluggable is IERC165 {
/**
* @notice Initializes a specific module or plugin for the wallet with the provided data
* @param data Initialization data required for the module or plugin
*/
function Init(bytes calldata data) external;
/*
NOTE: All implemention must ensure that the DeInit() function can be covered by 100,000 gas in all scenarios.
*/
/**
* @notice Deinitializes a specific module or plugin from the wallet
*/
function DeInit() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// fork from: OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides a set of functions to operate with Base64Url strings (with all trailing '=' characters omitted).
* see:
* 1. https://www.w3.org/TR/webauthn-2/#sctn-dependencies
* 2. https://datatracker.ietf.org/doc/html/rfc4648
*
*
* _Available since v4.5._
*/
library Base64Url {
/**
* @dev Base64Url Encoding/Decoding Table
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
/**
* @dev Converts a `bytes` to its Bytes64Url `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
*/
uint256 dataLen;
assembly {
dataLen := mload(data)
}
if (dataLen == 0) return "";
// Loads the table into memory
string memory table = _TABLE;
uint256 encodedLen;
assembly {
encodedLen := mul(4, div(dataLen, 3)) //4 * (dataLen / 3);
let padding := mod(dataLen, 3)
if gt(padding, 0) { encodedLen := add(add(encodedLen, padding), 1) }
}
// Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
// and split into 4 numbers of 6 bits.
string memory result = new string(encodedLen);
/// @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, dataLen)
} 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
}
}
return result;
}
}//********************************************************************************************/
// ___ _ ___ _ _ _ _
// | __| _ ___ __| |_ / __|_ _ _ _ _ __| |_ ___ | | (_) |__
// | _| '_/ -_|_-< ' \ | (__| '_| || | '_ \ _/ _ \ | |__| | '_ \
// |_||_| \___/__/_||_| \___|_| \_, | .__/\__\___/ |____|_|_.__/
// |__/|_|
///* Copyright (C) 2022 - Renaud Dubois - This file is part of FCL (Fresh CryptoLib) project
///* License: This software is licensed under MIT License
///* This Code may be reused including license and copyright notice.
///* See LICENSE file at the root folder of the project.
///* FILE: FCL_elliptic.sol
///*
///*
///* DESCRIPTION: modified XYZZ system coordinates for EVM elliptic point multiplication
///* optimization
///*
//**************************************************************************************/
//* WARNING: this code SHALL not be used for non prime order curves for security reasons.
// Code is optimized for a=-3 only curves with prime order, constant like -1, -2 shall be replaced
// if ever used for other curve than sec256R1
// reference: https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_elliptic.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library FCL_Elliptic_ZZ {
// Set parameters for curve sec256r1.
// address of the ModExp precompiled contract (Arbitrary-precision exponentiation under modulo)
address constant MODEXP_PRECOMPILE = 0x0000000000000000000000000000000000000005;
//curve prime field modulus
uint256 constant p = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
//short weierstrass first coefficient
uint256 constant a = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
//short weierstrass second coefficient
uint256 constant b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B;
//generating point affine coordinates
uint256 constant gx = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296;
uint256 constant gy = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5;
//curve order (number of points)
uint256 constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551;
/* -2 mod p constant, used to speed up inversion and doubling (avoid negation)*/
uint256 constant minus_2 = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFD;
/* -2 mod n constant, used to speed up inversion*/
uint256 constant minus_2modn = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC63254F;
uint256 constant minus_1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
//P+1 div 4
uint256 constant pp1div4 = 0x3fffffffc0000000400000000000000000000000400000000000000000000000;
//arbitrary constant to express no quadratic residuosity
uint256 constant _NOTSQUARE = 0xFFFFFFFF00000002000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
uint256 constant _NOTONCURVE = 0xFFFFFFFF00000003000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
/**
* /* inversion mod n via a^(n-2), use of precompiled using little Fermat theorem
*/
function FCL_nModInv(uint256 u) internal view returns (uint256 result) {
assembly {
let pointer := mload(0x40)
// Define length of base, exponent and modulus. 0x20 == 32 bytes
mstore(pointer, 0x20)
mstore(add(pointer, 0x20), 0x20)
mstore(add(pointer, 0x40), 0x20)
// Define variables base, exponent and modulus
mstore(add(pointer, 0x60), u)
mstore(add(pointer, 0x80), minus_2modn)
mstore(add(pointer, 0xa0), n)
// Call the precompiled contract 0x05 = ModExp
if iszero(staticcall(not(0), 0x05, pointer, 0xc0, pointer, 0x20)) { revert(0, 0) }
result := mload(pointer)
}
}
/**
* /* @dev inversion mod nusing little Fermat theorem via a^(n-2), use of precompiled
*/
function FCL_pModInv(uint256 u) internal view returns (uint256 result) {
assembly {
let pointer := mload(0x40)
// Define length of base, exponent and modulus. 0x20 == 32 bytes
mstore(pointer, 0x20)
mstore(add(pointer, 0x20), 0x20)
mstore(add(pointer, 0x40), 0x20)
// Define variables base, exponent and modulus
mstore(add(pointer, 0x60), u)
mstore(add(pointer, 0x80), minus_2)
mstore(add(pointer, 0xa0), p)
// Call the precompiled contract 0x05 = ModExp ̰
if iszero(staticcall(not(0), 0x05, pointer, 0xc0, pointer, 0x20)) { revert(0, 0) }
result := mload(pointer)
}
}
/**
* /* @dev Convert from XYZZ rep to affine rep
*/
/* https://hyperelliptic.org/EFD/g1p/auto-shortw-xyzz-3.html#addition-add-2008-s*/
function ecZZ_SetAff(uint256 x, uint256 y, uint256 zz, uint256 zzz)
internal
view
returns (uint256 x1, uint256 y1)
{
uint256 zzzInv = FCL_pModInv(zzz); //1/zzz
y1 = mulmod(y, zzzInv, p); //Y/zzz
uint256 _b = mulmod(zz, zzzInv, p); //1/z
zzzInv = mulmod(_b, _b, p); //1/zz
x1 = mulmod(x, zzzInv, p); //X/zz
}
/**
* @dev Sutherland2008 add a ZZ point with a normalized point and greedy formulae
* warning: assume that P1(x1,y1)!=P2(x2,y2), true in multiplication loop with prime order (cofactor 1)
*/
function ecZZ_AddN(uint256 x1, uint256 y1, uint256 zz1, uint256 zzz1, uint256 x2, uint256 y2)
internal
pure
returns (uint256 P0, uint256 P1, uint256 P2, uint256 P3)
{
unchecked {
if (y1 == 0) {
return (x2, y2, 1, 1);
}
assembly {
y1 := sub(p, y1)
y2 := addmod(mulmod(y2, zzz1, p), y1, p)
x2 := addmod(mulmod(x2, zz1, p), sub(p, x1), p)
P0 := mulmod(x2, x2, p) //PP = P^2
P1 := mulmod(P0, x2, p) //PPP = P*PP
P2 := mulmod(zz1, P0, p) ////ZZ3 = ZZ1*PP
P3 := mulmod(zzz1, P1, p) ////ZZZ3 = ZZZ1*PPP
zz1 := mulmod(x1, P0, p) //Q = X1*PP
P0 := addmod(addmod(mulmod(y2, y2, p), sub(p, P1), p), mulmod(minus_2, zz1, p), p) //R^2-PPP-2*Q
P1 := addmod(mulmod(addmod(zz1, sub(p, P0), p), y2, p), mulmod(y1, P1, p), p) //R*(Q-X3)
}
//end assembly
} //end unchecked
return (P0, P1, P2, P3);
}
/**
* @dev Check if the curve is the zero curve in affine rep.
*/
// uint256 x, uint256 y)
function ecAff_IsZero(uint256, uint256 y) internal pure returns (bool flag) {
return (y == 0);
}
/**
* @dev Check if a point in affine coordinates is on the curve (reject Neutral that is indeed on the curve).
*/
function ecAff_isOnCurve(uint256 x, uint256 y) internal pure returns (bool) {
if (0 == x || x == p || 0 == y || y == p) {
return false;
}
unchecked {
uint256 LHS = mulmod(y, y, p); // y^2
uint256 RHS = addmod(mulmod(mulmod(x, x, p), x, p), mulmod(x, a, p), p); // x^3+ax
RHS = addmod(RHS, b, p); // x^3 + a*x + b
return LHS == RHS;
}
}
/**
* @dev Add two elliptic curve points in affine coordinates.
*/
function ecAff_add(uint256 x0, uint256 y0, uint256 x1, uint256 y1) internal view returns (uint256, uint256) {
uint256 zz0;
uint256 zzz0;
if (ecAff_IsZero(x0, y0)) return (x1, y1);
if (ecAff_IsZero(x1, y1)) return (x0, y0);
(x0, y0, zz0, zzz0) = ecZZ_AddN(x0, y0, 1, 1, x1, y1);
return ecZZ_SetAff(x0, y0, zz0, zzz0);
}
/**
* @dev Computation of uG+vQ using Strauss-Shamir's trick, G basepoint, Q public key
* Returns only x for ECDSA use
*
*/
function ecZZ_mulmuladd_S_asm(
uint256 Q0,
uint256 Q1, //affine rep for input point Q
uint256 scalar_u,
uint256 scalar_v
) internal view returns (uint256 X) {
uint256 zz;
uint256 zzz;
uint256 Y;
uint256 index = 255;
uint256 H0;
uint256 H1;
unchecked {
if (scalar_u == 0 && scalar_v == 0) return 0;
(H0, H1) = ecAff_add(gx, gy, Q0, Q1); //will not work if Q=P, obvious forbidden private key
assembly {
for { let T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1)) } eq(T4, 0) {
index := sub(index, 1)
T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
} {}
zz := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
switch zz
case 1 {
X := gx
Y := gy
}
case 2 {
X := Q0
Y := Q1
}
case 3 {
X := H0
Y := H1
}
index := sub(index, 1)
zz := 1
zzz := 1
for {} gt(minus_1, index) { index := sub(index, 1) } {
// inlined EcZZ_Dbl
let T1 := mulmod(2, Y, p) //U = 2*Y1, y free
let T2 := mulmod(T1, T1, p) // V=U^2
let T3 := mulmod(X, T2, p) // S = X1*V
T1 := mulmod(T1, T2, p) // W=UV
let T4 := mulmod(3, mulmod(addmod(X, sub(p, zz), p), addmod(X, zz, p), p), p) //M=3*(X1-ZZ1)*(X1+ZZ1)
zzz := mulmod(T1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free
X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
T2 := mulmod(T4, addmod(X, sub(p, T3), p), p) //-M(S-X3)=M(X3-S)
Y := addmod(mulmod(T1, Y, p), T2, p) //-Y3= W*Y1-M(S-X3), we replace Y by -Y to avoid a sub in ecAdd
{
//value of dibit
T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
if iszero(T4) {
Y := sub(p, Y) //restore the -Y inversion
continue
} // if T4!=0
switch T4
case 1 {
T1 := gx
T2 := gy
}
case 2 {
T1 := Q0
T2 := Q1
}
case 3 {
T1 := H0
T2 := H1
}
if iszero(zz) {
X := T1
Y := T2
zz := 1
zzz := 1
continue
}
// inlined EcZZ_AddN
//T3:=sub(p, Y)
//T3:=Y
let y2 := addmod(mulmod(T2, zzz, p), Y, p) //R
T2 := addmod(mulmod(T1, zz, p), sub(p, X), p) //P
//special extremely rare case accumulator where EcAdd is replaced by EcDbl, no need to optimize this
//todo : construct edge vector case
if iszero(y2) {
if iszero(T2) {
T1 := mulmod(minus_2, Y, p) //U = 2*Y1, y free
T2 := mulmod(T1, T1, p) // V=U^2
T3 := mulmod(X, T2, p) // S = X1*V
let TT1 := mulmod(T1, T2, p) // W=UV
y2 := addmod(X, zz, p)
TT1 := addmod(X, sub(p, zz), p)
y2 := mulmod(y2, TT1, p) //(X-ZZ)(X+ZZ)
T4 := mulmod(3, y2, p) //M
zzz := mulmod(TT1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free
X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
T2 := mulmod(T4, addmod(T3, sub(p, X), p), p) //M(S-X3)
Y := addmod(T2, mulmod(T1, Y, p), p) //Y3= M(S-X3)-W*Y1
continue
}
}
T4 := mulmod(T2, T2, p) //PP
let TT1 := mulmod(T4, T2, p) //PPP, this one could be spared, but adding this register spare gas
zz := mulmod(zz, T4, p)
zzz := mulmod(zzz, TT1, p) //zz3=V*ZZ1
let TT2 := mulmod(X, T4, p)
T4 := addmod(addmod(mulmod(y2, y2, p), sub(p, TT1), p), mulmod(minus_2, TT2, p), p)
Y := addmod(mulmod(addmod(TT2, sub(p, T4), p), y2, p), mulmod(Y, TT1, p), p)
X := T4
}
} //end loop
let T := mload(0x40)
mstore(add(T, 0x60), zz)
//(X,Y)=ecZZ_SetAff(X,Y,zz, zzz);
//T[0] = inverseModp_Hard(T[0], p); //1/zzz, inline modular inversion using precompile:
// Define length of base, exponent and modulus. 0x20 == 32 bytes
mstore(T, 0x20)
mstore(add(T, 0x20), 0x20)
mstore(add(T, 0x40), 0x20)
// Define variables base, exponent and modulus
//mstore(add(pointer, 0x60), u)
mstore(add(T, 0x80), minus_2)
mstore(add(T, 0xa0), p)
// Call the precompiled contract 0x05 = ModExp
if iszero(staticcall(not(0), 0x05, T, 0xc0, T, 0x20)) { revert(0, 0) }
//Y:=mulmod(Y,zzz,p)//Y/zzz
//zz :=mulmod(zz, mload(T),p) //1/z
//zz:= mulmod(zz,zz,p) //1/zz
X := mulmod(X, mload(T), p) //X/zz
} //end assembly
} //end unchecked
return X;
}
/**
* @dev ECDSA verification, given , signature, and public key.
*/
function ecdsa_verify(bytes32 message, uint256 r, uint256 s, uint256 Q0, uint256 Q1) internal view returns (bool) {
if (r == 0 || r >= n || s == 0 || s >= n) {
return false;
}
if (!ecAff_isOnCurve(Q0, Q1)) {
return false;
}
uint256 sInv = FCL_nModInv(s);
uint256 scalar_u = mulmod(uint256(message), sInv, n);
uint256 scalar_v = mulmod(r, sInv, n);
uint256 x1;
x1 = ecZZ_mulmuladd_S_asm(Q0, Q1, scalar_u, scalar_v);
assembly {
x1 := addmod(x1, sub(n, r), n)
}
//return true;
return x1 == 0;
}
function ec_Decompress(uint256 x, uint256 parity) internal view returns (uint256 y) {
uint256 y2 = mulmod(x, mulmod(x, x, p), p); //x3
y2 = addmod(b, addmod(y2, mulmod(x, a, p), p), p); //x3+ax+b
y = SqrtMod(y2);
if (y == _NOTSQUARE) {
return _NOTONCURVE;
}
if ((y & 1) != (parity & 1)) {
y = p - y;
}
}
/// @notice Calculate one modular square root of a given integer. Assume that p=3 mod 4.
/// @dev Uses the ModExp precompiled contract at address 0x05 for fast computation using little Fermat theorem
/// @param self The integer of which to find the modular inverse
/// @return result The modular inverse of the input integer. If the modular inverse doesn't exist, it revert the tx
function SqrtMod(uint256 self) internal view returns (uint256 result) {
assembly ("memory-safe") {
// load the free memory pointer value
let pointer := mload(0x40)
// Define length of base (Bsize)
mstore(pointer, 0x20)
// Define the exponent size (Esize)
mstore(add(pointer, 0x20), 0x20)
// Define the modulus size (Msize)
mstore(add(pointer, 0x40), 0x20)
// Define variables base (B)
mstore(add(pointer, 0x60), self)
// Define the exponent (E)
mstore(add(pointer, 0x80), pp1div4)
// We save the point of the last argument, it will be override by the result
// of the precompile call in order to avoid paying for the memory expansion properly
let _result := add(pointer, 0xa0)
// Define the modulus (M)
mstore(_result, p)
// Call the precompiled ModExp (0x05) https://www.evm.codes/precompiled#0x05
if iszero(
staticcall(
not(0), // amount of gas to send
MODEXP_PRECOMPILE, // target
pointer, // argsOffset
0xc0, // argsSize (6 * 32 bytes)
_result, // retOffset (we override M to avoid paying for the memory expansion)
0x20 // retSize (32 bytes)
)
) { revert(0, 0) }
result := mload(_result)
// result :=addmod(result,0,p)
}
if (mulmod(result, result, p) != self) {
result = _NOTSQUARE;
}
return result;
}
/**
* @dev Computation of uG+vQ using Strauss-Shamir's trick, G basepoint, Q public key
* Returns affine representation of point (normalized)
*
*/
function ecZZ_mulmuladd(
uint256 Q0,
uint256 Q1, //affine rep for input point Q
uint256 scalar_u,
uint256 scalar_v
) internal view returns (uint256 X, uint256 Y) {
uint256 zz;
uint256 zzz;
uint256 index = 255;
uint256[2] memory H;
unchecked {
if (scalar_u == 0 && scalar_v == 0) return (0, 0);
(H[0], H[1]) = ecAff_add(gx, gy, Q0, Q1); //will not work if Q=P, obvious forbidden private key
assembly {
for { let T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1)) } eq(T4, 0) {
index := sub(index, 1)
T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
} {}
zz := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
switch zz
case 1 {
X := gx
Y := gy
}
case 2 {
X := Q0
Y := Q1
}
case 3 {
Y := mload(add(H, 32))
X := mload(H)
}
index := sub(index, 1)
zz := 1
zzz := 1
for {} gt(minus_1, index) { index := sub(index, 1) } {
// inlined EcZZ_Dbl
let T1 := mulmod(2, Y, p) //U = 2*Y1, y free
let T2 := mulmod(T1, T1, p) // V=U^2
let T3 := mulmod(X, T2, p) // S = X1*V
T1 := mulmod(T1, T2, p) // W=UV
let T4 := mulmod(3, mulmod(addmod(X, sub(p, zz), p), addmod(X, zz, p), p), p) //M=3*(X1-ZZ1)*(X1+ZZ1)
zzz := mulmod(T1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free
X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
T2 := mulmod(T4, addmod(X, sub(p, T3), p), p) //-M(S-X3)=M(X3-S)
Y := addmod(mulmod(T1, Y, p), T2, p) //-Y3= W*Y1-M(S-X3), we replace Y by -Y to avoid a sub in ecAdd
{
//value of dibit
T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
if iszero(T4) {
Y := sub(p, Y) //restore the -Y inversion
continue
} // if T4!=0
switch T4
case 1 {
T1 := gx
T2 := gy
}
case 2 {
T1 := Q0
T2 := Q1
}
case 3 {
T1 := mload(H)
T2 := mload(add(H, 32))
}
if iszero(zz) {
X := T1
Y := T2
zz := 1
zzz := 1
continue
}
// inlined EcZZ_AddN
//T3:=sub(p, Y)
//T3:=Y
let y2 := addmod(mulmod(T2, zzz, p), Y, p) //R
T2 := addmod(mulmod(T1, zz, p), sub(p, X), p) //P
//special extremely rare case accumulator where EcAdd is replaced by EcDbl, no need to optimize this
//todo : construct edge vector case
if iszero(y2) {
if iszero(T2) {
T1 := mulmod(minus_2, Y, p) //U = 2*Y1, y free
T2 := mulmod(T1, T1, p) // V=U^2
T3 := mulmod(X, T2, p) // S = X1*V
T1 := mulmod(T1, T2, p) // W=UV
y2 := addmod(X, zz, p) //X+ZZ
let TT1 := addmod(X, sub(p, zz), p) //X-ZZ
y2 := mulmod(y2, TT1, p) //(X-ZZ)(X+ZZ)
T4 := mulmod(3, y2, p) //M
zzz := mulmod(TT1, zzz, p) //zzz3=W*zzz1
zz := mulmod(T2, zz, p) //zz3=V*ZZ1, V free
X := addmod(mulmod(T4, T4, p), mulmod(minus_2, T3, p), p) //X3=M^2-2S
T2 := mulmod(T4, addmod(T3, sub(p, X), p), p) //M(S-X3)
Y := addmod(T2, mulmod(T1, Y, p), p) //Y3= M(S-X3)-W*Y1
continue
}
}
T4 := mulmod(T2, T2, p) //PP
let TT1 := mulmod(T4, T2, p) //PPP, this one could be spared, but adding this register spare gas
zz := mulmod(zz, T4, p)
zzz := mulmod(zzz, TT1, p) //zz3=V*ZZ1
let TT2 := mulmod(X, T4, p)
T4 := addmod(addmod(mulmod(y2, y2, p), sub(p, TT1), p), mulmod(minus_2, TT2, p), p)
Y := addmod(mulmod(addmod(TT2, sub(p, T4), p), y2, p), mulmod(Y, TT1, p), p)
X := T4
}
} //end loop
let T := mload(0x40)
mstore(add(T, 0x60), zzz)
//(X,Y)=ecZZ_SetAff(X,Y,zz, zzz);
//T[0] = inverseModp_Hard(T[0], p); //1/zzz, inline modular inversion using precompile:
// Define length of base, exponent and modulus. 0x20 == 32 bytes
mstore(T, 0x20)
mstore(add(T, 0x20), 0x20)
mstore(add(T, 0x40), 0x20)
// Define variables base, exponent and modulus
//mstore(add(pointer, 0x60), u)
mstore(add(T, 0x80), minus_2)
mstore(add(T, 0xa0), p)
// Call the precompiled contract 0x05 = ModExp
if iszero(staticcall(not(0), 0x05, T, 0xc0, T, 0x20)) { revert(0, 0) }
Y := mulmod(Y, mload(T), p) //Y/zzz
zz := mulmod(zz, mload(T), p) //1/z
zz := mulmod(zz, zz, p) //1/zz
X := mulmod(X, zz, p) //X/zz
} //end assembly
} //end unchecked
return (X, Y);
}
function ec_recover_r1(uint256 h, uint256 v, uint256 r, uint256 s) internal view returns (bytes32) {
if (r == 0 || r >= n || s == 0 || s >= n) {
return 0;
}
uint256 y = ec_Decompress(r, v - 27);
uint256 rinv = FCL_nModInv(r);
uint256 u1 = mulmod(n - addmod(0, h, n), rinv, n); //-hr^-1
uint256 u2 = mulmod(s, rinv, n); //sr^-1
uint256 Qx;
uint256 Qy;
(Qx, Qy) = ecZZ_mulmuladd(r, y, u1, u2);
return keccak256(abi.encodePacked(Qx, Qy));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
/**
* @title RS256Verify
* @author https://github.com/jayden-sudo
*
* The code strictly follows the RSASSA-PKCS1-v1_5 signature verification operation steps outlined in RFC 8017.
* It takes a signature, message, and public key as inputs and verifies if the signature is valid for the
* given message using the provided public key.
* reference: https://datatracker.ietf.org/doc/html/rfc8017#section-8.1.2
*
* This code has passed the complete tests of the `Algorithm Validation Testing Requirements`:https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Digital-Signatures#rsa2vs
* `FIPS 186-4` https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/dss/186-3rsatestvectors.zip
*
* LICENSE: MIT
* Copyright (c) 2023 Jayden
*/
library RS256Verify {
// If the length of S is not k octets, output "invalid signature" and stop.
error InvalidSignature();
// must be an integer multiple of 32.
error InvalidLength();
// output "signature representative out of range" and stop.
error SignatureRepresentativeOutOfRange();
/**
*
* @param n signer's RSA public key - n
* @param e signer's RSA public key - e
* @param H H = sha256(M) - message digest
* @param S signature to be verified, an octet string of length k, where k is the length in octets of the RSA modulus n
*/
function RSASSA_PSS_VERIFY(bytes memory n, bytes memory e, bytes32 H, bytes memory S)
internal
view
returns (bool)
{
uint256 k = n.length;
// 1. Length checking: If the length of S is not k octets, output "invalid signature" and stop.
if (k != S.length) {
revert InvalidSignature();
}
bytes4 _InvalidSignature = InvalidSignature.selector;
bytes4 _InvalidLength = InvalidLength.selector;
bytes4 _SignatureRepresentativeOutOfRange = SignatureRepresentativeOutOfRange.selector;
// 2. RSA verification:
/*
a. Convert the signature S to an integer signature representative s (see Section 4.2):
s = OS2IP (S).
*/
/*
c. Convert the message representative m to an encoded message
EM of length k octets (see Section 4.1):
EM = I2OSP (m, k).
*/
// bytes memory EM = m;
/*
1. Encode the algorithm ID for the hash function and the hash
value into an ASN.1 value of type DigestInfo (see
Appendix A.2.4) with the DER, where the type DigestInfo has
the syntax
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING
}
The first field identifies the hash function and the second
contains the hash value. Let T be the DER encoding of the
DigestInfo value (see the notes below), and let tLen be the
length in octets of T.
2. If emLen < tLen + 11, output "intended encoded message length
too short" and stop.
3. Generate an octet string PS consisting of emLen - tLen - 3
octets with hexadecimal value 0xff. The length of PS will be
at least 8 octets.
4. Concatenate PS, the DER encoding T, and other padding to form
the encoded message EM as
EM = 0x00 || 0x01 || PS || 0x00 || T.
5. Output EM.
SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
*/
/*
1. Encode the algorithm ID for the hash function and the hash
value into an ASN.1 value of type DigestInfo (see
Appendix A.2.4) with the DER, where the type DigestInfo has
the syntax
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING
}
The first field identifies the hash function and the second
contains the hash value. Let T be the DER encoding of the
DigestInfo value (see the notes below), and let tLen be the
length in octets of T.
2. If emLen < tLen + 11, output "intended encoded message length
too short" and stop.
3. Generate an octet string PS consisting of emLen - tLen - 3
octets with hexadecimal value 0xff. The length of PS will be
at least 8 octets.
4. Concatenate PS, the DER encoding T, and other padding to form
the encoded message EM as
EM = 0x00 || 0x01 || PS || 0x00 || T.
5. Output EM.
SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
*/
uint256 PS_ByteLen = k - 54; //k - 19 - 32 - 3, 32: SHA-256 hash length
uint256 _cursor;
assembly ("memory-safe") {
// inline RSAVP1 begin
/*
b. Apply the RSAVP1 verification primitive (Section 5.2.2) to
the RSA public key (n, e) and the signature representative
s to produce an integer message representative m:
m = RSAVP1 ((n, e), s).
If RSAVP1 outputs "signature representative out of range",output "invalid signature" and stop.
*/
// bytes memory EM = RSAVP1(n, e, S);
let EM
{
/*
Steps:
1. If the signature representative s is not between 0 and n - 1,
output "signature representative out of range" and stop.
2. Let m = s^e mod n.
3. Output m.
*/
// To simplify the calculations, k must be an integer multiple of 32.
if mod(k, 0x20) {
mstore(0x00, _InvalidLength)
revert(0x00, 4)
}
let _k := div(k, 0x20)
for { let i := 0 } lt(i, _k) { i := add(i, 0x01) } {
// 1. If the signature representative S is not between 0 and n - 1, output "signature representative out of range" and stop.
let _n := mload(add(add(n, 0x20), mul(i, 0x20)))
let _s := mload(add(add(S, 0x20), mul(i, 0x20)))
if lt(_s, _n) {
// break
i := k
}
if gt(_s, _n) {
// signature representative out of range
mstore(0x00, _SignatureRepresentativeOutOfRange)
revert(0x00, 4)
}
if eq(_s, _n) {
if eq(i, sub(_k, 0x01)) {
// signature representative out of range
mstore(0x00, _SignatureRepresentativeOutOfRange)
revert(0x00, 4)
}
}
}
// 2. Let m = s^e mod n.
let e_length := mload(e)
EM := mload(0x40)
mstore(EM, k)
mstore(add(EM, 0x20), e_length)
mstore(add(EM, 0x40), k)
let _cursor_inline := add(EM, 0x60)
// copy s begin
for { let i := 0 } lt(i, k) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(S, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy s end
// copy e begin
// To simplify the calculations, e must be an integer multiple of 32.
if mod(e_length, 0x20) {
mstore(0x00, _InvalidLength)
revert(0x00, 4)
}
for { let i := 0 } lt(i, e_length) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(e, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy e end
// copy n begin
for { let i := 0 } lt(i, k) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(n, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy n end
// Call the precompiled contract 0x05 = ModExp
if iszero(staticcall(not(0), 0x05, EM, _cursor_inline, add(EM, 0x20), k)) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
mstore(EM, k)
mstore(0x40, add(add(EM, 0x20), k))
}
// inline RSAVP1 end
if sub(mload(add(EM, 0x20)), 0x0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) {
// |_______________________ 0x1E bytes _______________________|
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
let paddingLen := sub(PS_ByteLen, 0x1E)
let _times := div(paddingLen, 0x20)
_cursor := add(EM, 0x40)
for { let i := 0 } lt(i, _times) { i := add(i, 1) } {
if sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, mload(_cursor)) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
_cursor := add(_cursor, 0x20)
}
let _remainder := mod(paddingLen, 0x20)
if _remainder {
let _shift := mul(0x08, sub(0x20, _remainder))
if sub(
0x0000000000000000000000000000000000000000000000000000000000000000,
shl(_shift, not(shr(_shift, mload(_cursor))))
) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
}
// SHA-256 T : (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
// EM = 0x00 || 0x01 || PS || 0x00 || T.
_cursor := add(EM, add(0x22, PS_ByteLen /* 0x20+1+1+PS_ByteLen */ ))
// 0x003031300d060960864801650304020105000420
// |______________ 0x14 bytes _______________|
if sub(0x003031300d060960864801650304020105000420, shr(0x60, /* 8*12 */ mload(_cursor))) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
}
bytes32 _H;
assembly ("memory-safe") {
_H := mload(add(_cursor, 0x14))
}
return H == _H;
}
/**
*
* @param n signer's RSA public key - n
* @param e signer's RSA public key - e
* @param M message whose signature is to be verified, an octet string
* @param S signature to be verified, an octet string of length k, where k is the length in octets of the RSA modulus n
*/
function RSASSA_PSS_VERIFY(bytes memory n, bytes memory e, bytes memory M, bytes memory S)
internal
view
returns (bool)
{
uint256 k = n.length;
// 1. Length checking: If the length of S is not k octets, output "invalid signature" and stop.
if (k != S.length) {
revert InvalidSignature();
}
bytes4 _InvalidSignature = InvalidSignature.selector;
bytes4 _InvalidLength = InvalidLength.selector;
bytes4 _SignatureRepresentativeOutOfRange = SignatureRepresentativeOutOfRange.selector;
// 2. RSA verification:
/*
a. Convert the signature S to an integer signature representative s (see Section 4.2):
s = OS2IP (S).
*/
/*
c. Convert the message representative m to an encoded message
EM of length k octets (see Section 4.1):
EM = I2OSP (m, k).
*/
// bytes memory EM = m;
/*
1. Encode the algorithm ID for the hash function and the hash
value into an ASN.1 value of type DigestInfo (see
Appendix A.2.4) with the DER, where the type DigestInfo has
the syntax
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING
}
The first field identifies the hash function and the second
contains the hash value. Let T be the DER encoding of the
DigestInfo value (see the notes below), and let tLen be the
length in octets of T.
2. If emLen < tLen + 11, output "intended encoded message length
too short" and stop.
3. Generate an octet string PS consisting of emLen - tLen - 3
octets with hexadecimal value 0xff. The length of PS will be
at least 8 octets.
4. Concatenate PS, the DER encoding T, and other padding to form
the encoded message EM as
EM = 0x00 || 0x01 || PS || 0x00 || T.
5. Output EM.
SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
*/
/*
1. Encode the algorithm ID for the hash function and the hash
value into an ASN.1 value of type DigestInfo (see
Appendix A.2.4) with the DER, where the type DigestInfo has
the syntax
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING
}
The first field identifies the hash function and the second
contains the hash value. Let T be the DER encoding of the
DigestInfo value (see the notes below), and let tLen be the
length in octets of T.
2. If emLen < tLen + 11, output "intended encoded message length
too short" and stop.
3. Generate an octet string PS consisting of emLen - tLen - 3
octets with hexadecimal value 0xff. The length of PS will be
at least 8 octets.
4. Concatenate PS, the DER encoding T, and other padding to form
the encoded message EM as
EM = 0x00 || 0x01 || PS || 0x00 || T.
5. Output EM.
SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
*/
uint256 PS_ByteLen = k - 54; //k - 19 - 32 - 3, 32: SHA-256 hash length
uint256 _cursor;
assembly ("memory-safe") {
// inline RSAVP1 begin
/*
b. Apply the RSAVP1 verification primitive (Section 5.2.2) to
the RSA public key (n, e) and the signature representative
s to produce an integer message representative m:
m = RSAVP1 ((n, e), s).
If RSAVP1 outputs "signature representative out of range",output "invalid signature" and stop.
*/
// bytes memory EM = RSAVP1(n, e, S);
let EM
{
/*
Steps:
1. If the signature representative s is not between 0 and n - 1,
output "signature representative out of range" and stop.
2. Let m = s^e mod n.
3. Output m.
*/
// To simplify the calculations, k must be an integer multiple of 32.
if mod(k, 0x20) {
mstore(0x00, _InvalidLength)
revert(0x00, 4)
}
let _k := div(k, 0x20)
for { let i := 0 } lt(i, _k) { i := add(i, 0x01) } {
// 1. If the signature representative S is not between 0 and n - 1, output "signature representative out of range" and stop.
let _n := mload(add(add(n, 0x20), mul(i, 0x20)))
let _s := mload(add(add(S, 0x20), mul(i, 0x20)))
if lt(_s, _n) {
// break
i := k
}
if gt(_s, _n) {
// signature representative out of range
mstore(0x00, _SignatureRepresentativeOutOfRange)
revert(0x00, 4)
}
if eq(_s, _n) {
if eq(i, sub(_k, 0x01)) {
// signature representative out of range
mstore(0x00, _SignatureRepresentativeOutOfRange)
revert(0x00, 4)
}
}
}
// 2. Let m = s^e mod n.
let e_length := mload(e)
EM := mload(0x40)
mstore(EM, k)
mstore(add(EM, 0x20), e_length)
mstore(add(EM, 0x40), k)
let _cursor_inline := add(EM, 0x60)
// copy s begin
for { let i := 0 } lt(i, k) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(S, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy s end
// copy e begin
// To simplify the calculations, e must be an integer multiple of 32.
if mod(e_length, 0x20) {
mstore(0x00, _InvalidLength)
revert(0x00, 4)
}
for { let i := 0 } lt(i, e_length) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(e, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy e end
// copy n begin
for { let i := 0 } lt(i, k) { i := add(i, 0x20) } {
mstore(_cursor_inline, mload(add(add(n, 0x20), i)))
_cursor_inline := add(_cursor_inline, 0x20)
}
// copy n end
// Call the precompiled contract 0x05 = ModExp
if iszero(staticcall(not(0), 0x05, EM, _cursor_inline, add(EM, 0x20), k)) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
mstore(EM, k)
mstore(0x40, add(add(EM, 0x20), k))
}
// inline RSAVP1 end
if sub(mload(add(EM, 0x20)), 0x0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) {
// |_______________________ 0x1E bytes _______________________|
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
let paddingLen := sub(PS_ByteLen, 0x1E)
let _times := div(paddingLen, 0x20)
_cursor := add(EM, 0x40)
for { let i := 0 } lt(i, _times) { i := add(i, 1) } {
if sub(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, mload(_cursor)) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
_cursor := add(_cursor, 0x20)
}
let _remainder := mod(paddingLen, 0x20)
if _remainder {
let _shift := mul(0x08, sub(0x20, _remainder))
if sub(
0x0000000000000000000000000000000000000000000000000000000000000000,
shl(_shift, not(shr(_shift, mload(_cursor))))
) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
}
// SHA-256 T : (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H.
// EM = 0x00 || 0x01 || PS || 0x00 || T.
_cursor := add(EM, add(0x22, PS_ByteLen /* 0x20+1+1+PS_ByteLen */ ))
// 0x003031300d060960864801650304020105000420
// |______________ 0x14 bytes _______________|
if sub(0x003031300d060960864801650304020105000420, shr(0x60, /* 8*12 */ mload(_cursor))) {
mstore(0x00, _InvalidSignature)
revert(0x00, 4)
}
}
bytes32 _H;
assembly ("memory-safe") {
_H := mload(add(_cursor, 0x14))
}
return sha256(M) == _H;
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.5;
/**
* User Operation struct
* @param sender - The sender account of this request.
* @param nonce - Unique value the sender uses to verify it is not a replay.
* @param initCode - If set, the account contract will be created by this constructor/
* @param callData - The method call to execute on this account.
* @param accountGasLimits - Packed gas limits for validateUserOp and gas limit passed to the callData method call.
* @param preVerificationGas - Gas not calculated by the handleOps method, but added to the gas paid.
* Covers batch overhead.
* @param gasFees - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.
* @param paymasterAndData - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data
* The paymaster will pay for the transaction instead of the sender.
* @param signature - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.
*/
struct PackedUserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
bytes32 accountGasLimits;
uint256 preVerificationGas;
bytes32 gasFees;
bytes paymasterAndData;
bytes signature;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
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 success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
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 success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
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.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return a == 0 ? 0 : (a - 1) / b + 1;
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* 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²⁵⁶ and mod 2²⁵⁶ - 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²⁵⁶ + 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²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(denominator == 0 ? Panic.DIVISION_BY_ZERO : Panic.UNDER_OVERFLOW);
}
///////////////////////////////////////////////
// 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
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⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// 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²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, 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;
}
}
/**
* @dev 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) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, expect 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Ferma's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return x < 0 ? (n - uint256(-x)) : uint256(x); // Wrap the result if it's negative.
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked has failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
/// @solidity memory-safe-assembly
assembly {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @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;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @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;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @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/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// 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/bool 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);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
/// @solidity memory-safe-assembly
assembly {
u := iszero(iszero(b))
}
}
}{
"remappings": [
"@soulwallet-core/=lib/soulwallet-core/",
"@source/=contracts/",
"@arbitrum/nitro-contracts/=lib/nitro-contracts/",
"@solady/=lib/solady/",
"@solenv/=lib/solenv/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@account-abstraction/=lib/account-abstraction/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"account-abstraction/=lib/account-abstraction/contracts/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"nitro-contracts/=lib/nitro-contracts/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solady/=lib/solady/src/",
"solenv/=lib/solenv/",
"solidity-stringutils/=lib/solenv/lib/solidity-stringutils/",
"soulwallet-core/=lib/soulwallet-core/"
],
"optimizer": {
"enabled": true,
"runs": 100000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true,
"libraries": {}
}Contract ABI
API[{"inputs":[],"name":"INVALID_SIGNTYPE","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"DeInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"Init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"rawHash","type":"bytes32"},{"internalType":"bytes","name":"validatorSignature","type":"bytes"}],"name":"validateSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"initCode","type":"bytes"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes32","name":"accountGasLimits","type":"bytes32"},{"internalType":"uint256","name":"preVerificationGas","type":"uint256"},{"internalType":"bytes32","name":"gasFees","type":"bytes32"},{"internalType":"bytes","name":"paymasterAndData","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct PackedUserOperation","name":"","type":"tuple"},{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"bytes","name":"validatorSignature","type":"bytes"}],"name":"validateUserOp","outputs":[{"internalType":"uint256","name":"validationData","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6080806040523461001657612d40908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c90816301ffc9a71461006a575080638c1dcf3714610065578063971604c614610060578063986370b61461005b5763d39462211461005657600080fd5b6102a0565b610222565b61017c565b61012b565b346100f55760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f5576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036100f1577f0f757470000000000000000000000000000000000000000000000000000000001460805260206080f35b5080fd5b80fd5b9181601f840112156101265782359167ffffffffffffffff8311610126576020838186019501011161012657565b600080fd5b346101265760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101265760043567ffffffffffffffff81116101265761017a9036906004016100f8565b005b346101265760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101265760043573ffffffffffffffffffffffffffffffffffffffff8116036101265760443567ffffffffffffffff8111610126576101f86101ef60209236906004016100f8565b906024356102d1565b7fffffffff0000000000000000000000000000000000000000000000000000000060405191168152f35b34610126577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6060813601126101265760043567ffffffffffffffff91828211610126576101209136030112610126576044359081116101265761029861028f60209236906004016100f8565b906024356104c6565b604051908152f35b346101265760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261012657005b916102db91610824565b91939260ff81168061040257506102f29390610aae565b156103dc5761030361030791610b6f565b1590565b6103b75780610336575b507f1626ba7e0000000000000000000000000000000000000000000000000000000090565b61033f90610bf3565b610360610355604083015165ffffffffffff1690565b65ffffffffffff1690565b4211908115610399575b506103755738610311565b7ffffffffe0000000000000000000000000000000000000000000000000000000090565b602001516103af915065ffffffffffff16610355565b42103861036a565b507fffffffff0000000000000000000000000000000000000000000000000000000090565b50507fffffffff0000000000000000000000000000000000000000000000000000000090565b6001810361045f575060408051602081019586529081018690526102f2949061045681606081015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826109c3565b51902090610aae565b6002810361047257506102f29390610aae565b60030361049c5760408051602081019586529081018690526102f29490610456816060810161042a565b60046040517f8ba6972a000000000000000000000000000000000000000000000000000000008152fd5b916104d091610824565b9192839460ff821680156000146105455750610520945061051a907f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b90610aae565b1561053e5761030361053191610b6f565b6105385790565b50600190565b5050600190565b600181036105a857506040805160208101928352908101959095526105209461051a9190610576816060810161042a565b5190207f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b600281036105bc5750610520945090610aae565b60030361049c5760408051602081019283529081019590955261052094610456816060810161042a565b156105ed57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f76616c696461746f72207369676e617475726520746f6f2073686f72740000006044820152fd5b906001116101265790600190565b906021116101265760010190602090565b909291928360211161012657831161012657602101917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf0190565b909291928360011161012657831161012657600101917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b906062116101265760210190604190565b906042116101265760010190604190565b90939293848311610126578411610126578101920390565b7fff00000000000000000000000000000000000000000000000000000000000000903581811693926001811061074f57505050565b60010360031b82901b16169150565b1561076557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f696e76616c69642076616c696461746f72207369676e6174757265206c656e6760448201527f74680000000000000000000000000000000000000000000000000000000000006064820152fd5b3590602081106107f7575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060200360031b1b1690565b909161083360018410156105e6565b61084f610849610843858561064b565b9061071a565b60f81c90565b9260ff84168061087757508061086a6042610872931461075e565b6000936106f1565b90915b565b600181036108a95750806108906062610872931461075e565b6108a361089d8286610659565b906107e9565b936106e0565b600281036108cc5750806108c3608161087293101561075e565b806000946106a5565b6003036108f857806108e460a161087293101561075e565b806108f261089d8287610659565b9461066a565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f696e76616c69642076616c696461746f72207369676e617475726520747970656044820152606490fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6060810190811067ffffffffffffffff8211176109a257604052565b610957565b6040810190811067ffffffffffffffff8211176109a257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176109a257604052565b67ffffffffffffffff81116109a257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192610a4a82610a04565b91610a5860405193846109c3565b829481845281830111610126578281602093846000960137010152565b60041115610a7f57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90919060ff1680158015610b59575b15610b1f5750610ad290610ad8933691610a3e565b90610d43565b50610ae281610a75565b15610b035773ffffffffffffffffffffffffffffffffffffffff6000911691565b73ffffffffffffffffffffffffffffffffffffffff6001911691565b60028194939414908115610b4e575b501561049c57610b3d92610c72565b80610b485790600090565b90600190565b600391501438610b2e565b5060018114610abd565b6040513d6000823e3d90fd5b604051907feeac39d80000000000000000000000000000000000000000000000000000000082526004820152602081602481335afa908115610bee57600091610bb6575090565b6020813d602011610be6575b81610bcf602093836109c3565b810103126100f157519081151582036100f5575090565b3d9150610bc2565b610b63565b6040516060810181811067ffffffffffffffff8211176109a2576000916040918252828152826020820152015265ffffffffffff808260a01c168015610c6b575b60405192610c4184610986565b73ffffffffffffffffffffffffffffffffffffffff8116845260d01c602084015216604082015290565b5080610c34565b908215610d1457803560f81c80610c9b575082610c9893610c92926106a5565b9161100e565b90565b600103610cb65782610c9893610cb0926106a5565b91610f19565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f696e76616c696420616c676f726974686d2074797065000000000000000000006044820152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8151919060418303610d7457610d6d92506020820151906060604084015193015160001a906110b4565b9192909190565b505060009160029190565b9060405191602083015260208252610875826109a7565b908092918237016000815290565b9081519160005b838110610dbc575050016000815290565b8060208092840101518185015201610dab565b919284610df761087595979693976020896040519a8b98838a01378701019060008252610da4565b9182370160008152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836109c3565b604051906020820182811067ffffffffffffffff8211176109a25760405260008252565b60405190610e5c82610986565b602482527f65223a22000000000000000000000000000000000000000000000000000000006040837f7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6760208201520152565b90926108759281610df7610ecd97966040519889966020880190610da4565b90610da4565b604090610875929493858351968793602085013782019060208201520360208101855201836109c3565b60405190610f0a826109a7565b60208252620100016020830152565b610f4a6020610f7292610f31610f4596600096611145565b949a989d979c969b9192959e909399610d7f565b611269565b90801587146110005750610f669350610f61610e4f565b610eae565b60405191828092610da4565b039060025afa15610bee57610f91610f66602093600093845191610ed3565b039060025afa15610bee57610fc693610fcc9160005190610fb0610efd565b968791610fbe36888a610a3e565b943691610a3e565b926113cb565b15610ff857610ff29061042a604051938492610fec602085018098610da4565b91610d96565b51902090565b505050600090565b61100994610dcf565b610f66565b60258201359261ffff91828560101c16928360450192836045116101265780841161012657610f4560009382610f4a61106561105b8b60209a60458f61106d9b8f91160101988992610702565b939096818d610702565b949093610d7f565b039060025afa15610bee57600061108f610f6660209383519060458701610ed3565b039060025afa15610bee57610c989160ff602083013592359160201c1660005161173d565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161113957926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa15610bee57805173ffffffffffffffffffffffffffffffffffffffff81161561113057918190565b50809160019190565b50505060009160039190565b908135918260f01c9261ffff906006938585019384861161012657818511610126578581019761087283898001976111b26111858b8b0180938589610702565b9b909b9a8a8a60e01c160161119f8282018095878b610702565b9b909b9a60d01c16010180928488610702565b96909695610702565b604051906111c882610986565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b9061122482610a04565b61123160405191826109c3565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061125f8294610a04565b0190602036910137565b80518015611309576112796111bb565b60039060029061129c6003850460021b60038606806112ff575b5095949561121a565b9460208601908501945b8581106112b65750505050505090565b8460049101918251600190603f9082828260121c16880101518453828282600c1c16880101518385015382828260061c16880101518885015316850101518682015301906112a6565b0160010138611293565b5050610c98610e2b565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffca820191821161134057565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b907fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63255191820391821161134057565b907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91820391821161134057565b91929082519282518403611713576113e284611313565b93600090601f81166116eb5760058160051c835b81811061163d575050508351906040519581875260209485880193808552604089019784895260608a019387905b8987831061162857505050601f82166116005791859285949288915b8a8284106115e5575050505086905b888583106115ca575050508860057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156115a25780865285018301604052517ffffe0000000000000000000000000000000000000000000000000000000000010161157a57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe2600085820160051c5b80821061156557505081908508908161154b575b50505001602281015160601c723031300d0609608648016503040201050004200361152157603601511490565b7f8baa579f0000000000000000000000000000000000000000000000000000000060005260046000fd5b0360031b9051811c19901b600003611521573880806114f4565b909380511961152157830193600101906114e0565b807f8baa579f0000000000000000000000000000000000000000000000000000000060049252fd5b6004837f8baa579f000000000000000000000000000000000000000000000000000000008152fd5b8183018101518452869550879450928301929091019061144f565b81840181015186528897508996509485019490920191611440565b6004877f947d5a84000000000000000000000000000000000000000000000000000000008152fd5b82968183948194010151815201950190611424565b80831b6020808289010151918a0101518181106116e3575b8181116116bb571461166a575b6001016113f6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82018103611662576004857feda7c610000000000000000000000000000000000000000000000000000000008152fd5b6004877feda7c610000000000000000000000000000000000000000000000000000000008152fd5b859250611655565b6004827f947d5a84000000000000000000000000000000000000000000000000000000008152fd5b60046040517f8baa579f000000000000000000000000000000000000000000000000000000008152fd5b9180158015611837575b801561182f575b8015611805575b6117fc577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe5820191821161134057610ff29361042a936117d461179b6117dd9585611861565b916117a5856119e5565b90817fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325519384809360000861136f565b09930992611a92565b6040939193519283916020830195869091604092825260208201520190565b50505050600090565b507fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551841015611755565b50831561174e565b507fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551811015611747565b91907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff808481807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc81980991818180099009087f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b0860c06000602060405181815281808201528160408201528460608201527f3fffffffc0000000400000000000000000000000400000000000000000000000608082015260a0810193849189835260057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156100f557505193848009036119bd575b7fffffffff00000002000000000000000000000000ffffffffffffffffffffffff831461199757600116600183160361198d57565b90610c989061139d565b507fffffffff00000003000000000000000000000000ffffffffffffffffffffffff9150565b7fffffffff00000002000000000000000000000000ffffffffffffffffffffffff9250611958565b60405190602082526020808301526020604083015260608201527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f60808201527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63255160a082015260208160c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa15610126575190565b60405190611a8b826109a7565b6040368337565b600094938593929060ff90611aa5611a7e565b94801580612b5d575b612b4c57611abc8486612b65565b939087856020839a01525281811c60028460fe1c16015b15612b1457600182821c16600284831c60011b160180600114612ac85780600214612ab857600314612aa9575b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909695929194939601936001966001965b867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff11611c08575050505050505060405190606082015260208152602080820152602060408201527fffffffff00000001000000000000000000000000fffffffffffffffffffffffd60808201527fffffffff00000001000000000000000000000000ffffffffffffffffffffffff928360a083015260208260c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1561012657838080935180950980099009930990565b909192939495989a967fffffffff00000001000000000000000000000000ffffffffffffffffffffffff886002099b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8d800991827fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8184099e8f947fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109927fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8d8208908d7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff90600309917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9084099b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109927fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff828009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108809e7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff819a8309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff910898858c1c600116878d1c60011b600216018015612a575780600114612a0d5780600214612a03576003146129fa575b82156129c8577fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91828f92818e8e9209089283918186858203920908938115612447575b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8580097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91099b847fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91099a847fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8580097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9082097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09857fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff848009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff03907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8680097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089c7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8380097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff0390807fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108987fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff905b01959493929190611b32565b915050821561245857818e91611f58565b98809b9d9a92507fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91507fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8b7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff908a09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8981038b087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8a8c08907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff910999897fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109977fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8b7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8c7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109987fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff826003097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff83600309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089a7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff817fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109918b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff90600309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9061243b565b9c5099600199508998507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff915061243b565b50508183611f14565b5050508587611f14565b5050507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c2967f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5611f14565b50505097967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9c9a9c039b61243b565b92985094955085948892611b00565b5093985093955085938893611b00565b507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f599507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c2969750611b00565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600160028184841c169185841c901b1601611ad3565b505050505050509050600090600090565b508115611aae565b908015612cc2576001929183917f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d697fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8094818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b92090894090882808280099182099183827f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c29609927fffffffff00000001000000000000000000000000fffffffffffffffffffffffd91858086850981848103818580090808926040519060208252602080830152602060408301528784600109606083015260808201528660a082015260208160c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156101265786958680969481808080988197519c8d9160010909800988099b09948203900809080990565b50507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296907f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59056fea26469706673582212203c6644cf6f58b262fedd81032b09dd1542a5a88ec5592f8d2f4bdce20947ee3f64736f6c63430008170033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b6000803560e01c90816301ffc9a71461006a575080638c1dcf3714610065578063971604c614610060578063986370b61461005b5763d39462211461005657600080fd5b6102a0565b610222565b61017c565b61012b565b346100f55760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f5576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036100f1577f0f757470000000000000000000000000000000000000000000000000000000001460805260206080f35b5080fd5b80fd5b9181601f840112156101265782359167ffffffffffffffff8311610126576020838186019501011161012657565b600080fd5b346101265760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101265760043567ffffffffffffffff81116101265761017a9036906004016100f8565b005b346101265760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101265760043573ffffffffffffffffffffffffffffffffffffffff8116036101265760443567ffffffffffffffff8111610126576101f86101ef60209236906004016100f8565b906024356102d1565b7fffffffff0000000000000000000000000000000000000000000000000000000060405191168152f35b34610126577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6060813601126101265760043567ffffffffffffffff91828211610126576101209136030112610126576044359081116101265761029861028f60209236906004016100f8565b906024356104c6565b604051908152f35b346101265760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261012657005b916102db91610824565b91939260ff81168061040257506102f29390610aae565b156103dc5761030361030791610b6f565b1590565b6103b75780610336575b507f1626ba7e0000000000000000000000000000000000000000000000000000000090565b61033f90610bf3565b610360610355604083015165ffffffffffff1690565b65ffffffffffff1690565b4211908115610399575b506103755738610311565b7ffffffffe0000000000000000000000000000000000000000000000000000000090565b602001516103af915065ffffffffffff16610355565b42103861036a565b507fffffffff0000000000000000000000000000000000000000000000000000000090565b50507fffffffff0000000000000000000000000000000000000000000000000000000090565b6001810361045f575060408051602081019586529081018690526102f2949061045681606081015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826109c3565b51902090610aae565b6002810361047257506102f29390610aae565b60030361049c5760408051602081019586529081018690526102f29490610456816060810161042a565b60046040517f8ba6972a000000000000000000000000000000000000000000000000000000008152fd5b916104d091610824565b9192839460ff821680156000146105455750610520945061051a907f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b90610aae565b1561053e5761030361053191610b6f565b6105385790565b50600190565b5050600190565b600181036105a857506040805160208101928352908101959095526105209461051a9190610576816060810161042a565b5190207f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b600281036105bc5750610520945090610aae565b60030361049c5760408051602081019283529081019590955261052094610456816060810161042a565b156105ed57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f76616c696461746f72207369676e617475726520746f6f2073686f72740000006044820152fd5b906001116101265790600190565b906021116101265760010190602090565b909291928360211161012657831161012657602101917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf0190565b909291928360011161012657831161012657600101917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b906062116101265760210190604190565b906042116101265760010190604190565b90939293848311610126578411610126578101920390565b7fff00000000000000000000000000000000000000000000000000000000000000903581811693926001811061074f57505050565b60010360031b82901b16169150565b1561076557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f696e76616c69642076616c696461746f72207369676e6174757265206c656e6760448201527f74680000000000000000000000000000000000000000000000000000000000006064820152fd5b3590602081106107f7575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060200360031b1b1690565b909161083360018410156105e6565b61084f610849610843858561064b565b9061071a565b60f81c90565b9260ff84168061087757508061086a6042610872931461075e565b6000936106f1565b90915b565b600181036108a95750806108906062610872931461075e565b6108a361089d8286610659565b906107e9565b936106e0565b600281036108cc5750806108c3608161087293101561075e565b806000946106a5565b6003036108f857806108e460a161087293101561075e565b806108f261089d8287610659565b9461066a565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f696e76616c69642076616c696461746f72207369676e617475726520747970656044820152606490fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6060810190811067ffffffffffffffff8211176109a257604052565b610957565b6040810190811067ffffffffffffffff8211176109a257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176109a257604052565b67ffffffffffffffff81116109a257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192610a4a82610a04565b91610a5860405193846109c3565b829481845281830111610126578281602093846000960137010152565b60041115610a7f57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90919060ff1680158015610b59575b15610b1f5750610ad290610ad8933691610a3e565b90610d43565b50610ae281610a75565b15610b035773ffffffffffffffffffffffffffffffffffffffff6000911691565b73ffffffffffffffffffffffffffffffffffffffff6001911691565b60028194939414908115610b4e575b501561049c57610b3d92610c72565b80610b485790600090565b90600190565b600391501438610b2e565b5060018114610abd565b6040513d6000823e3d90fd5b604051907feeac39d80000000000000000000000000000000000000000000000000000000082526004820152602081602481335afa908115610bee57600091610bb6575090565b6020813d602011610be6575b81610bcf602093836109c3565b810103126100f157519081151582036100f5575090565b3d9150610bc2565b610b63565b6040516060810181811067ffffffffffffffff8211176109a2576000916040918252828152826020820152015265ffffffffffff808260a01c168015610c6b575b60405192610c4184610986565b73ffffffffffffffffffffffffffffffffffffffff8116845260d01c602084015216604082015290565b5080610c34565b908215610d1457803560f81c80610c9b575082610c9893610c92926106a5565b9161100e565b90565b600103610cb65782610c9893610cb0926106a5565b91610f19565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f696e76616c696420616c676f726974686d2074797065000000000000000000006044820152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8151919060418303610d7457610d6d92506020820151906060604084015193015160001a906110b4565b9192909190565b505060009160029190565b9060405191602083015260208252610875826109a7565b908092918237016000815290565b9081519160005b838110610dbc575050016000815290565b8060208092840101518185015201610dab565b919284610df761087595979693976020896040519a8b98838a01378701019060008252610da4565b9182370160008152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836109c3565b604051906020820182811067ffffffffffffffff8211176109a25760405260008252565b60405190610e5c82610986565b602482527f65223a22000000000000000000000000000000000000000000000000000000006040837f7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6760208201520152565b90926108759281610df7610ecd97966040519889966020880190610da4565b90610da4565b604090610875929493858351968793602085013782019060208201520360208101855201836109c3565b60405190610f0a826109a7565b60208252620100016020830152565b610f4a6020610f7292610f31610f4596600096611145565b949a989d979c969b9192959e909399610d7f565b611269565b90801587146110005750610f669350610f61610e4f565b610eae565b60405191828092610da4565b039060025afa15610bee57610f91610f66602093600093845191610ed3565b039060025afa15610bee57610fc693610fcc9160005190610fb0610efd565b968791610fbe36888a610a3e565b943691610a3e565b926113cb565b15610ff857610ff29061042a604051938492610fec602085018098610da4565b91610d96565b51902090565b505050600090565b61100994610dcf565b610f66565b60258201359261ffff91828560101c16928360450192836045116101265780841161012657610f4560009382610f4a61106561105b8b60209a60458f61106d9b8f91160101988992610702565b939096818d610702565b949093610d7f565b039060025afa15610bee57600061108f610f6660209383519060458701610ed3565b039060025afa15610bee57610c989160ff602083013592359160201c1660005161173d565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161113957926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa15610bee57805173ffffffffffffffffffffffffffffffffffffffff81161561113057918190565b50809160019190565b50505060009160039190565b908135918260f01c9261ffff906006938585019384861161012657818511610126578581019761087283898001976111b26111858b8b0180938589610702565b9b909b9a8a8a60e01c160161119f8282018095878b610702565b9b909b9a60d01c16010180928488610702565b96909695610702565b604051906111c882610986565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b9061122482610a04565b61123160405191826109c3565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061125f8294610a04565b0190602036910137565b80518015611309576112796111bb565b60039060029061129c6003850460021b60038606806112ff575b5095949561121a565b9460208601908501945b8581106112b65750505050505090565b8460049101918251600190603f9082828260121c16880101518453828282600c1c16880101518385015382828260061c16880101518885015316850101518682015301906112a6565b0160010138611293565b5050610c98610e2b565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffca820191821161134057565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b907fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63255191820391821161134057565b907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91820391821161134057565b91929082519282518403611713576113e284611313565b93600090601f81166116eb5760058160051c835b81811061163d575050508351906040519581875260209485880193808552604089019784895260608a019387905b8987831061162857505050601f82166116005791859285949288915b8a8284106115e5575050505086905b888583106115ca575050508860057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156115a25780865285018301604052517ffffe0000000000000000000000000000000000000000000000000000000000010161157a57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe2600085820160051c5b80821061156557505081908508908161154b575b50505001602281015160601c723031300d0609608648016503040201050004200361152157603601511490565b7f8baa579f0000000000000000000000000000000000000000000000000000000060005260046000fd5b0360031b9051811c19901b600003611521573880806114f4565b909380511961152157830193600101906114e0565b807f8baa579f0000000000000000000000000000000000000000000000000000000060049252fd5b6004837f8baa579f000000000000000000000000000000000000000000000000000000008152fd5b8183018101518452869550879450928301929091019061144f565b81840181015186528897508996509485019490920191611440565b6004877f947d5a84000000000000000000000000000000000000000000000000000000008152fd5b82968183948194010151815201950190611424565b80831b6020808289010151918a0101518181106116e3575b8181116116bb571461166a575b6001016113f6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82018103611662576004857feda7c610000000000000000000000000000000000000000000000000000000008152fd5b6004877feda7c610000000000000000000000000000000000000000000000000000000008152fd5b859250611655565b6004827f947d5a84000000000000000000000000000000000000000000000000000000008152fd5b60046040517f8baa579f000000000000000000000000000000000000000000000000000000008152fd5b9180158015611837575b801561182f575b8015611805575b6117fc577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe5820191821161134057610ff29361042a936117d461179b6117dd9585611861565b916117a5856119e5565b90817fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325519384809360000861136f565b09930992611a92565b6040939193519283916020830195869091604092825260208201520190565b50505050600090565b507fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551841015611755565b50831561174e565b507fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551811015611747565b91907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff808481807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc81980991818180099009087f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b0860c06000602060405181815281808201528160408201528460608201527f3fffffffc0000000400000000000000000000000400000000000000000000000608082015260a0810193849189835260057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156100f557505193848009036119bd575b7fffffffff00000002000000000000000000000000ffffffffffffffffffffffff831461199757600116600183160361198d57565b90610c989061139d565b507fffffffff00000003000000000000000000000000ffffffffffffffffffffffff9150565b7fffffffff00000002000000000000000000000000ffffffffffffffffffffffff9250611958565b60405190602082526020808301526020604083015260608201527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f60808201527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63255160a082015260208160c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa15610126575190565b60405190611a8b826109a7565b6040368337565b600094938593929060ff90611aa5611a7e565b94801580612b5d575b612b4c57611abc8486612b65565b939087856020839a01525281811c60028460fe1c16015b15612b1457600182821c16600284831c60011b160180600114612ac85780600214612ab857600314612aa9575b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909695929194939601936001966001965b867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff11611c08575050505050505060405190606082015260208152602080820152602060408201527fffffffff00000001000000000000000000000000fffffffffffffffffffffffd60808201527fffffffff00000001000000000000000000000000ffffffffffffffffffffffff928360a083015260208260c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1561012657838080935180950980099009930990565b909192939495989a967fffffffff00000001000000000000000000000000ffffffffffffffffffffffff886002099b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8d800991827fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8184099e8f947fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109927fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8d8208908d7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff90600309917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9084099b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109927fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff828009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108809e7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff819a8309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff910898858c1c600116878d1c60011b600216018015612a575780600114612a0d5780600214612a03576003146129fa575b82156129c8577fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91828f92818e8e9209089283918186858203920908938115612447575b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8580097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91099b847fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91099a847fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8580097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9082097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09857fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff848009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff03907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8680097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089c7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8380097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff907fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09917fffffffff00000001000000000000000000000000ffffffffffffffffffffffff818009907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff0390807fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108987fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff905b01959493929190611b32565b915050821561245857818e91611f58565b98809b9d9a92507fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91507fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8b7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff908a09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8981038b087fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8a8c08907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff910999897fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109977fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8b7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8c7fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109987fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff826003097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff83600309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089a7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff817fffffffff00000001000000000000000000000000fffffffffffffffffffffffd097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91097fffffffff00000001000000000000000000000000ffffffffffffffffffffffff827fffffffff00000001000000000000000000000000fffffffffffffffffffffffd09907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109918b7fffffffff00000001000000000000000000000000ffffffffffffffffffffffff037fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9108907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff90600309907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9109907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff91089a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9061243b565b9c5099600199508998507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff915061243b565b50508183611f14565b5050508587611f14565b5050507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c2967f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5611f14565b50505097967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff907fffffffff00000001000000000000000000000000ffffffffffffffffffffffff9c9a9c039b61243b565b92985094955085948892611b00565b5093985093955085938893611b00565b507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f599507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c2969750611b00565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600160028184841c169185841c901b1601611ad3565b505050505050509050600090600090565b508115611aae565b908015612cc2576001929183917f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d697fffffffff00000001000000000000000000000000ffffffffffffffffffffffff8094818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b92090894090882808280099182099183827f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c29609927fffffffff00000001000000000000000000000000fffffffffffffffffffffffd91858086850981848103818580090808926040519060208252602080830152602060408301528784600109606083015260808201528660a082015260208160c08160057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa156101265786958680969481808080988197519c8d9160010909800988099b09948203900809080990565b50507f6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296907f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59056fea26469706673582212203c6644cf6f58b262fedd81032b09dd1542a5a88ec5592f8d2f4bdce20947ee3f64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.