ERC-20
Overview
Max Total Supply
11,791,549 AP
Holders
1,079,486
Market
Price
$0.00 @ 0.000000 ETH
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
AqPoint
Compiler Version
v0.8.20+commit.a1b79de6
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; import { ERC20, ERC20Burnable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; interface IMintable { function mint(address to, uint256 value) external; } contract AqPoint is ERC20Burnable, AccessControl, IMintable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant WHITELIST = keccak256("WHITELIST"); constructor() ERC20("zAce Point", "AP") { _grantRole(MINTER_ROLE, _msgSender()); _grantRole(WHITELIST, _msgSender()); } function transfer( address to, uint256 value ) public override onlyRole(WHITELIST) returns (bool) { return super.transfer(to, value); } function transferFrom( address from, address to, uint256 value ) public override onlyRole(WHITELIST) returns (bool) { return super.transferFrom(from, to, value); } function mint( address to, uint256 value ) public override onlyRole(MINTER_ROLE) { _mint(to, value); } function addMinter(address account) public onlyRole(MINTER_ROLE) { _grantRole(MINTER_ROLE, account); } function addWhitelist(address account) public onlyRole(MINTER_ROLE) { _grantRole(WHITELIST, account); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqModuleErrors } from "./AqModuleErrors.sol"; contract AqModuleCore is AqModuleErrors { /// @custom:storage-location erc7201:ace-quest.module struct ModuleStorage { // mod hash => mod address mapping(bytes32 => address) _modules; // function sigHash => mod hash mapping(bytes4 => bytes32) _modInterfaces; } // keccak256(abi.encode(uint256(keccak256("ace-quest.module")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ModulesStorageLocation = 0x3619734fad8f6b303a1cd5b2fe8b4f2bac0a6b120c1b4ab21b3a2db144ca6900; event ModuleUpdated(string name, address module); event ModuleFunctionAttached(string name, bytes4 sig); event ModuleFunctionDetached(bytes4 sig); function _getModuleStorage() private pure returns (ModuleStorage storage $) { assembly { $.slot := ModulesStorageLocation } } function _getModuleAddress(bytes4 sig) internal view returns (address) { ModuleStorage storage $ = _getModuleStorage(); return $._modules[$._modInterfaces[sig]]; } function _setModule( string memory modName, address modAddress, bytes4[] memory modInterfaces ) internal { ModuleStorage storage $ = _getModuleStorage(); bytes32 modHash = keccak256(bytes(modName)); if (modAddress == address(0)) { revert InvalidModuleAddress( modName, $._modules[modHash], modAddress ); } $._modules[modHash] = modAddress; emit ModuleUpdated(modName, modAddress); _attachInterfaces(modName, modInterfaces); } function _unsetModule( string memory modName, bytes4[] memory interfaces ) internal { ModuleStorage storage $ = _getModuleStorage(); bytes32 modHash = keccak256(bytes(modName)); if ($._modules[modHash] == address(0)) { revert ModuleNotExists(modName); } delete $._modules[modHash]; emit ModuleUpdated(modName, address(0)); _detachInterfaces(interfaces); } function _attachInterfaces( string memory modName, bytes4[] memory modInterfaces ) internal { ModuleStorage storage $ = _getModuleStorage(); bytes32 modHash = keccak256(bytes(modName)); for (uint256 i = 0; i < modInterfaces.length; i++) { $._modInterfaces[modInterfaces[i]] = modHash; emit ModuleFunctionAttached(modName, modInterfaces[i]); } } function _detachInterfaces( bytes4[] memory modInterfaces ) internal { ModuleStorage storage $ = _getModuleStorage(); for (uint256 i = 0; i < modInterfaces.length; i++) { delete $._modInterfaces[modInterfaces[i]]; emit ModuleFunctionDetached(modInterfaces[i]); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface AqModuleErrors { error InvalidModuleAddress( string modName, address prevModAddress, address nextModAddress ); error ModuleNotExists(string modName); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.20; import {ERC20} from "../ERC20.sol"; import {Context} from "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys a `value` amount of tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 value) public virtual { _burn(_msgSender(), value); } /** * @dev Destroys a `value` amount of tokens from `account`, deducting from * the caller's allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `value`. */ function burnFrom(address account, uint256 value) public virtual { _spendAllowance(account, _msgSender(), value); _burn(account, value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: 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[EIP-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[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-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 EIP-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 EIP-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 (EIP-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: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.20; import {ECDSA} from "./ECDSA.sol"; import {IERC1271} from "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Safe Wallet (previously Gnosis Safe). */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature); return (error == ECDSA.RecoverError.NoError && recovered == signer) || isValidERC1271SignatureNow(signer, hash, signature); } /** * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated * against the signer smart contract using ERC1271. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidERC1271SignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (bool success, bytes memory result) = signer.staticcall( abi.encodeCall(IERC1271.isValidSignature, (hash, signature)) ); return (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP 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; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/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 { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// 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 pragma solidity ^0.8.20; import { AqAccountCoreInterface } from "./AqAccountInterface.sol"; contract AqAccountCore is AqAccountCoreInterface { // @custom:storage-location erc7201:ace-quest.account struct AccountStorage { /** @dev deputy-account -> main-account */ mapping(address => AccountBinding) _bindings; /** * @dev Referal code: [....Base bytes (base on address)][Counter] */ mapping(bytes32 => address) _codeAccounts; mapping(address => string) _accountCodes; mapping(bytes6 => uint32) _codeCounts; } // keccak256(abi.encode(uint256(keccak256("ace-quest.account")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccountStorageLocation = 0x79287f8320a821f8c30c8e1dfed77b1ee74ecb38c07735b9bfd496cf9301f400; function _getAccountStorage() private pure returns (AccountStorage storage $) { assembly { $.slot := AccountStorageLocation } } function __AqAccount_init_unchained() internal { // } function _msgOwner() internal view returns (address) { return _mainAccount(msg.sender); } function _mainAccount(address account) internal view returns (address) { AccountStorage storage $ = _getAccountStorage(); if ($._bindings[account].mainAccount == address(0)) return account; if ( // Bind forever $._bindings[account].timeout == 0 || // Not over timeout $._bindings[account].timeout >= block.timestamp ) { return $._bindings[account].mainAccount; } return account; } function _bindAccount( address mainAccount, address deputyAccount, uint64 timeout ) internal { AccountStorage storage $ = _getAccountStorage(); if ( mainAccount == address(0) || // Use _unbindAccount instead deputyAccount == address(0) || mainAccount == deputyAccount ) revert InvalidOpration(mainAccount, deputyAccount); if (timeout > 0 && timeout < block.timestamp) revert InvalidTimeout(timeout); // Main account already bound if (_mainAccount(mainAccount) != mainAccount) revert InvalidAccountBinding( mainAccount, $._bindings[mainAccount].mainAccount, $._bindings[mainAccount].timeout ); $._bindings[deputyAccount] = AccountBinding({ mainAccount: mainAccount, timeout: timeout }); emit AccountAuthorized(mainAccount, deputyAccount, timeout); } function _unbindAccount(address deputy) internal { AccountStorage storage $ = _getAccountStorage(); if ($._bindings[deputy].mainAccount == address(0)) revert InvalidOpration( deputy, address(0) ); delete $._bindings[deputy]; emit AccountAuthorized(address(0), deputy, 0); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IAccountErrors } from "../AqErrors.sol"; interface AqAccountCoreInterface is IAccountErrors { struct AccountBinding { address mainAccount; // 20 bytes uint64 timeout; // 8 bytes -> 0: bind forever until unbind } event AccountAuthorized( address indexed mainAddress, address indexed deputyAddress, uint64 timeout ); event CancelAccountAuthorization( address indexed mainAddress, address indexed deputyAddress ); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { AqCore } from "../AqCore.sol"; contract AqCommonAdmin is AqCore { event EmergencyWithdrawn(address token, address to, uint256 amount); /** @dev Only for other tokens that accidentally transferred to this contract. */ function emergencyWithdraw( address token, address to, uint256 amount ) external onlyAdmin { if (token == address(0)) { Address.sendValue(payable(to), amount); } else { SafeERC20.safeTransfer(IERC20(token), to, amount); } emit EmergencyWithdrawn(token, to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqCore } from "../AqCore.sol"; contract AqGameAdmin is AqCore { function createTable( string memory name, uint8 seats, uint256 sbAmount, uint256 bbAmount, uint256 anteAmount, uint256 initialBuyin, uint256 minBuyin, uint256 maxBuyin ) external onlyAdmin returns (uint32 tableId) { tableId = _openNewTable(); _setBlinds(tableId, sbAmount, bbAmount, anteAmount); _setBuyins(tableId, initialBuyin, minBuyin, maxBuyin); _setTableSeats(tableId, seats); _setTableName(tableId, name); } function removeTable(uint32 tableId) external onlyAdmin { _closeTable(tableId); } function setTableName( uint32 tableId, string memory name ) external onlyAdmin { _setTableName(tableId, name); } function setTableSeats( uint32 tableId, uint8 seats ) external onlyAdmin { _setTableSeats(tableId, seats); } function setBlinds( uint32 tableId, uint256 sbAmount, uint256 bbAmount, uint256 anteAmount ) external onlyAdmin onlyPendingTable(tableId) { _setBlinds(tableId, sbAmount, bbAmount, anteAmount); } function setBuyins( uint32 tableId, uint256 initialBuyin, uint256 minBuyin, uint256 maxBuyin ) external onlyAdmin { _setBuyins(tableId, initialBuyin, minBuyin, maxBuyin); } function setHoldemAllInRaiseRatio(uint32 ratio) external onlyAdmin { _setHoldemAllinRaiseRatio(ratio); } function setHoldemShuffleTimeout(uint32 timeout) external onlyAdmin { _setHoldemShuffleTimeout(timeout); } function setHoldemRevealTimeout(uint32 timeout) external onlyAdmin { _setHoldemRevealTimeout(timeout); } function setHoldemBetTimeout(uint32 timeout) external onlyAdmin { _setHoldemBetTimeout(timeout); } function setHoldemShowdownTimeout(uint32 timeout) external onlyAdmin { _setHoldemShowdownTimeout(timeout); } function setHoldemEndTimeout(uint32 timeout) external onlyAdmin { _setHoldemEndTimeout(timeout); } function setShuffleVerifier(address verifier) external onlyAdmin { _setShuffleVerifier(verifier); } function setRevealVerifier(address verifier) external onlyAdmin { _setRevealVerifier(verifier); } function setCashAddress(address cash) external onlyAdmin { _setVaultCashToken(cash); } function setCashReferralReturnRate(ReferralReturnRate[] memory rates) external onlyAdmin { _setCashReferralReturnRate(rates); } function setPointReferralReturnRate(ReferralReturnRate[] memory rates) external onlyAdmin { _setPointReferralReturnRate(rates); } function setDailyTasks(BasicTask[] memory tasks) external onlyAdmin { _setDailyTasks(tasks); } function setWeeklyTasks(BasicTask[] memory tasks) external onlyAdmin { _setWeeklyTasks(tasks); } function setCheckinRewards(uint256[] memory rewards) external onlyAdmin { _setCheckinRewards(rewards); } function setTaskReward(address pt) external onlyAdmin { _setTaskRewardToken(pt); } function setTaskDayConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) external onlyAdmin { _setDayConfig(duration, shiftPlus, shiftMinus); } function setTaskWeekConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) external onlyAdmin { _setWeekConfig(duration, shiftPlus, shiftMinus); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { AqCore } from "../AqCore.sol"; contract AqModuleAdmin is AqCore, UUPSUpgradeable { function setModule( string calldata modName, address modAddress, bytes4[] memory modInterfaces ) external onlyAdmin { _setModule(modName, modAddress, modInterfaces); } function unsetModule( string calldata modName, bytes4[] memory modInterfaces ) external onlyAdmin { _unsetModule(modName, modInterfaces); } function attachInterfaces( string calldata modName, bytes4[] memory modInterfaces ) external onlyAdmin { _attachInterfaces(modName, modInterfaces); } function detachInterfaces( bytes4[] memory modInterfaces ) external onlyAdmin { _detachInterfaces(modInterfaces); } function upgradeTo(address newImplementation) external payable { upgradeToAndCall(newImplementation, new bytes(0)); } function _authorizeUpgrade(address) internal override onlyAdmin {} }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { AqCommonAdmin } from "./admin/AqCommonAdmin.sol"; import { AqGameAdmin } from "./admin/AqGameAdmin.sol"; import { AqModuleAdmin } from "./admin/AqModuleAdmin.sol"; contract AqAdmin is AqModuleAdmin, AqGameAdmin, AqCommonAdmin { /* .8. ,o888888o. 8 8888888888 .888. 8888 `88. 8 8888 :88888. ,8 8888 `8. 8 8888 . `88888. 88 8888 8 8888 .8. `88888. 88 8888 8 888888888888 .8`8. `88888. 88 8888 8 8888 .8' `8. `88888. 88 8888 8 8888 .8' `8. `88888.`8 8888 .8' 8 8888 .888888888. `88888. 8888 ,88' 8 8888 .8' `8. `88888. `8888888P' 8 888888888888 ,o888888o. 8 8888 88 8 8888888888 d888888o. 8888888 8888888888 . 8888 `88. 8 8888 88 8 8888 .`8888:' `88. 8 8888 ,8 8888 `8b 8 8888 88 8 8888 8.`8888. Y8 8 8888 88 8888 `8b 8 8888 88 8 8888 `8.`8888. 8 8888 88 8888 88 8 8888 88 8 888888888888 `8.`8888. 8 8888 88 8888 `8. 88 8 8888 88 8 8888 `8.`8888. 8 8888 88 8888 `8,8P 8 8888 88 8 8888 `8.`8888. 8 8888 `8 8888 ;8P ` 8888 ,8P 8 8888 8b `8.`8888. 8 8888 ` 8888 ,88'8. 8888 ,d8P 8 8888 `8b. ;8.`8888 8 8888 `8888888P' `8. `Y88888P' 8 888888888888 `Y8888P ,88P' 8 8888 */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; uint256 constant DENO = 1e6;
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { AqModuleCore } from "@ace-quest/modular-proxy/AqModuleCore.sol"; import { AqAccountCore } from "./account/AqAccountCore.sol"; import { AqHoldemCore } from "./holdem/AqHoldemCore.sol"; import { AqLobbyCore } from "./lobby/AqLobbyCore.sol"; import { AqPlayerCore } from "./player/AqPlayerCore.sol"; import { AqReferralCore } from "./referral/AqReferralCore.sol"; import { AqRoleCore } from "./role/AqRoleCore.sol"; import { AqShuffleCore } from "./shuffle/AqShuffleCore.sol"; import { AqTableCore } from "./table/AqTableCore.sol"; import { AqTaskCore } from "./task/AqTaskCore.sol"; import { AqVaultCore } from "./vault/AqVaultCore.sol"; import { AqCoreInterface } from "./AqInterfaces.sol"; import { IMintable } from "./AqPoint.sol"; /** * Helper contract to resolve inheritance issue. * * Puts functions here if they are used by both lobby & tables */ abstract contract AqCore is AqAccountCore, AqHoldemCore, AqLobbyCore, AqPlayerCore, AqReferralCore, AqRoleCore, AqShuffleCore, AqTableCore, AqTaskCore, AqVaultCore, AqModuleCore, ERC20Upgradeable, ReentrancyGuardUpgradeable, AqCoreInterface { function _exchangeToExactChips( address player, uint256 chipsAmount ) internal returns (uint256 cashRequired) { cashRequired = _toCashAmount(chipsAmount); _transferCashIn(player, cashRequired); _mint(player, chipsAmount); } function _exchangeFromExactCash( address player, uint256 cashAmount ) internal returns (uint256 chipsAmount) { chipsAmount = _toChipsAmount(cashAmount); _transferCashIn(player, cashAmount); _mint(player, chipsAmount); } function _exchangeFromExactChips( address player, uint256 chipsAmount ) internal returns (uint256 cashAmount) { cashAmount = _toCashAmount(chipsAmount); uint256 balance = balanceOf(player); if (balance < chipsAmount) revert InsufficientChips(player, chipsAmount, balance); _burn(player, chipsAmount); _transferCashOut(player, cashAmount); } function _transferCashIn(address player, uint256 cashAmount) internal { address cash = _getVaultCashToken(); if (cash == address(0)) { if (msg.value < cashAmount) revert InsufficientCash(player, cashAmount, msg.value); } else { if (IERC20(cash).allowance(player, address(this)) < cashAmount) revert InsufficientCashAllowance(player, cashAmount, IERC20(cash).allowance(player, address(this))); if (IERC20(cash).balanceOf(player) < cashAmount) revert InsufficientCashBalance(player, cashAmount, IERC20(cash).balanceOf(player)); SafeERC20.safeTransferFrom( IERC20(cash), player, address(this), cashAmount ); } emit Deposit(cash, player, cashAmount); } function _transferCashOut( address player, uint256 cashAmount ) internal { address cash = _getVaultCashToken(); if (cash == address(0)) { Address.sendValue(payable(player), cashAmount); } else { SafeERC20.safeTransfer( IERC20(cash), player, cashAmount ); } emit Withdraw(cash, player, cashAmount); } function _transferPoints(address account, uint256 amount) internal { IMintable(_getTaskRewardToken()).mint(account, amount); } function _clearKeptChip(uint256 chipAmount) internal { _burn(address(this), chipAmount); _increaseAccumulatedFee(_toCashAmount(chipAmount)); } function _clearPlayerChips( address player, uint256 feeChips ) internal returns (uint256 refundCashAmount) { uint256 balance = balanceOf(player); if (balance < feeChips) feeChips = balance; if (feeChips > 0) { _burn(player, feeChips); _increaseAccumulatedFee(_toCashAmount(feeChips)); } return balance > feeChips ? _exchangeFromExactChips(player, balance - feeChips) : 0; } // Simple version of checking unusual-end, for lobby reset only // Players inside a game should check table state instead function _isTableUnusualEnd(uint32 tableId) internal view returns ( bool isUnusualEnd, uint64 endTimeout, bool canReset ) { if (_gameStage(tableId) == GameStage.UnusualEnd) return ( true, _gameStageTimeout(tableId), block.timestamp > _gameStageTimeout(tableId) ); (isUnusualEnd, endTimeout) = _isZkStageOvertime(tableId); canReset = isUnusualEnd && block.timestamp > endTimeout; } function _beforeNewGame(uint32 /* tableId */, uint256 lastGameId) internal override { if (lastGameId > 0) _clearHoldemGame(lastGameId); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IGlobals { enum PlayerStatus { None, LobbyWaiting, __UNUSED_LOBBY_STATE_1, __UNUSED_LOBBY_STATE_2, __UNUSED_LOBBY_STATE_3, TablePlaying } struct PublicKey { uint256 x; uint256 y; } struct RevealToken { uint256 x; uint256 y; } enum PokerSuit { Unknown, // ........ 0 (Unkonwn) Spade, // ........ 1 (♠) Heart, // ........ 2 (♥) Diamond, // ........ 3 (♦) Club // ........ 4 (♣) } enum PokerRank { Unknown, // ........ 0 (Unkonwn) Ace, // ........ 1 (A) Two, // .........2 Three, // .........3 Four, // .........4 Five, // .........5 Six, // .........6 Seven, // .........7 Eight, // .........8 Nine, // .........9 Ten, // .........10 Jack, // .........11 (J) Queen, // .........12 (Q) King // .........13 (K) // AceHigh, // ......14 (A) // Joker // ...... (Joker) } struct PokerCard { PokerSuit suit; PokerRank rank; } } interface ICoreErrors { error InsufficientCash( address player, uint256 requiredAmount, uint256 actualAmount ); error InsufficientCashAllowance( address player, uint256 requiredAmount, uint256 actualAmount ); error InsufficientCashBalance( address player, uint256 requiredAmount, uint256 actualAmount ); error InsufficientChips( address player, uint256 requiredAmount, uint256 actualAmount ); } interface IAccountErrors { error InvalidOpration( address mainAccount, address deputyAccount ); error InvalidTimeout(uint64 timeout); error InvalidAccountBinding( address account, address boundAccount, uint64 boundTimeout ); } interface IHoldemErrors is IGlobals { enum GameStage { None, Shuffle, // zk:shuffle CutCards, // approve shuffle and put blind bets | submit rest players' hand cards rToken PreFlop, // 🎲 bet from BB+1 RevealFlopCards, // 🃜 🃚 🃖 > submit first 3 community cards Flop, // 🎲 bet from SB RevealTurnCards, // 🃜 🃚 🃖 🃁 > submit 4th community card Turn, // 🎲 bet from SB RevealRiverCards, // 🃜 🃚 🃖 🃁 🂭 > submit 5th community card River, // 🎲 bet from SB Showdown, // Overtime = fold -> zk reveal NormalEnd, // Claim pots | choose: stay or cashout UnusualEnd // Ponish & refunds / split pots / cashout only } error NotController(address sender); error NotPlaying(address player); error GameNotOngoing(uint256 gameId); error TableAlreadyFinished(uint32 tableId); error AlreadyShuffled(uint256 gameId); error AlreadyRevealed(uint256 gameId, uint8 cardIndex, address player); error DuplicateDeck(uint32 tableId, uint64 seriesId); error InvalidMaskedDeck(uint256 gameId); error InvalidShuffleProof(uint256 gameId); error InvalidRevealProof(uint256 gameId, uint8 cardIndex); error InvalidGameStage(GameStage currentStage); error InvalidBettingOption(); error MissingRevealToken(uint8[] cardIndexes); error NotYourTurn(); error RaiseTooSmall(uint256 minRaise); } interface ILobbyErrors is IGlobals { error PlayerAlreadyInTable(address player, uint32 tableId); error PlayerNotWaiting(address player, uint32 tableId); error PlayerHasReady(address player, uint32 tableId, uint64 readyAt); error PlayerHasLeftDueToOvertime(address player, uint32 tableId); error LineupFull(uint32 tableId, uint64 fullAt); error LineupNotFull(uint32 tableId, uint8 playerCount); error WalletInUse(address wallet); error WalletInLineup(address wallet, uint32 tableId); error InvalidAuthorizationTimeout(uint64 signedAt); error InvalidAuthorizationSignature(); error PermissionDenied(); error InvalidSettingValue(uint256 newValue); error InvalidTableStatus(uint32 tableId); } interface IPlayerErrors is IGlobals { } interface IReferralErrors is IGlobals { error AlreadyBoundReferrer(address user, address referrer); error InvalidReferrer(address referrer); error InvalidReferrerV2(address referrerV2); } interface IShuffleErrors is IGlobals { error InvalidCardID(uint256 cardHash); error InvalidDeckLength(uint256 deckLength); error DuplicatedRevealToken(uint256 gameId, uint8 cardIndex, RevealToken revealToken); } interface ITableErrors { error TableNotExists(uint32 tableId); error TableNotPending(uint32 tableId); } interface ITaskErrors { error AlreadyCheckedIn(address player, uint64 lastCheckinAt); error AlreadyClaimedTask(address player, uint8 taskId); error InvalidTaskId(uint8 taskId); error TaskNotCompleted(address player, uint8 taskId); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqCore } from "./AqCore.sol"; abstract contract AqInitializor is AqCore { function __AQ_init() internal { __AccessControl_init_unchained(); __ReentrancyGuard_init_unchained(); __ERC20_init_unchained("zAce Chip", "zChip"); __AqAccount_init_unchained(); __AqHoldem_init_unchained(); __AqLobby_init_unchained(); __AqPlayer_init_unchained(); __AqReferral_init_unchained(); __AqRole_init_unchained(); __AqShuffle_init_unchained(address(0), address(0)); __AqTable_init_unchained(); __AqTask_init_unchained(); __AqVault_init_unchained(address(0)); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./account/AqAccountInterface.sol"; import "./holdem/AqHoldemInterfaces.sol"; import "./lobby/AqLobbyInterfaces.sol"; import "./player/AqPlayerInterface.sol"; import "./referral/AqReferralInterfaces.sol"; import "./shuffle/AqShuffleInterface.sol"; import "./task/AqTaskInterfaces.sol"; import "./table/AqTableInterfaces.sol"; import { ICoreErrors } from "./AqErrors.sol"; interface AqCoreInterface is ICoreErrors { event Deposit(address token, address indexed user, uint256 amount); event Withdraw(address token, address indexed user, uint256 amount); } interface AqWebClient is AqCoreInterface, AqLobbyClientInterface, AqHoldemClientInterface, AqTableClientInterface, AqTaskClientInterface, AqReferralClientInterface, IERC20 { /* .8. ,o888888o. 8 8888888888 .888. 8888 `88. 8 8888 :88888. ,8 8888 `8. 8 8888 . `88888. 88 8888 8 8888 .8. `88888. 88 8888 8 888888888888 .8`8. `88888. 88 8888 8 8888 .8' `8. `88888. 88 8888 8 8888 .8' `8. `88888.`8 8888 .8' 8 8888 .888888888. `88888. 8888 ,88' 8 8888 .8' `8. `88888. `8888888P' 8 888888888888 ,o888888o. 8 8888 88 8 8888888888 d888888o. 8888888 8888888888 . 8888 `88. 8 8888 88 8 8888 .`8888:' `88. 8 8888 ,8 8888 `8b 8 8888 88 8 8888 8.`8888. Y8 8 8888 88 8888 `8b 8 8888 88 8 8888 `8.`8888. 8 8888 88 8888 88 8 8888 88 8 888888888888 `8.`8888. 8 8888 88 8888 `8. 88 8 8888 88 8 8888 `8.`8888. 8 8888 88 8888 `8,8P 8 8888 88 8 8888 `8.`8888. 8 8888 `8 8888 ;8P ` 8888 ,8P 8 8888 8b `8.`8888. 8 8888 ` 8888 ,88'8. 8888 ,d8P 8 8888 `8b. ;8.`8888 8 8888 `8888888P' `8. `Y88888P' 8 888888888888 `Y8888P ,88P' 8 8888 */ }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IGlobals } from "./AqErrors.sol"; import { AqModuleAdmin } from "./admin/AqModuleAdmin.sol"; import { AqHoldemRevealerInterface, AqHoldemViewInterface } from "./holdem/AqHoldemInterfaces.sol"; import { AqLobbyViews } from "./lobby/AqLobbyViews.sol"; import { AqReferralCore } from "./referral/AqReferralCore.sol"; import { AqReferralViews } from "./referral/AqReferralViews.sol"; import { AqTaskViewInterface } from "./task/AqTaskInterfaces.sol"; import { AqInitializor } from "./AqInitializor.sol"; /** * @dev Put most empty functions in standard proxy implementation * to help tx previews in explorer. */ abstract contract EmptyFunctions is IGlobals { function authorize( address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external pure {} function cancelAuthorization(address deputyAccount) external pure {} function join( uint32 tableId, PublicKey memory playerPublicKey ) external pure returns (uint8 playerCounts) {} function refund() external pure returns (uint256 refundAmount) {} function leave() external pure returns (uint256 refundAmount) {} function ready() external pure returns (bool tableStarted) {} function shuffle( uint256 gameId, uint256[4][52] calldata maskedCards, uint256[4][52] calldata shuffledCards, bytes calldata proof, uint256[] calldata pkc ) external pure {} function showCards( AqHoldemRevealerInterface.RevealTokenSubmission[] calldata reveals ) external pure {} function allinBets() external pure {} function foldBets() external pure {} function callBets() external pure {} function checkBets() external pure {} function raiseBets(uint256 raiseAmount) external pure {} function claimPots(uint32 tableId, uint8 pos) external pure returns (uint256 amount) {} function ponish() external pure {} function cashOut() external pure {} function holdemTimers() external pure returns ( uint32 shuffleTimeout, uint32 revealTimeout, uint32 betTimeout, uint32 showdownTimeout, uint32 endTimeout ) {} function table(uint32 tableId) external pure returns ( AqHoldemViewInterface.HoldemTableStatus memory status ) {} function setReferrer(address referrer) external pure {} function claimReferralCashback(address user) external pure returns (uint256) {} function refAndAuthorize( address referrer, address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external pure {} function refAndJoin(address referrer, uint32 tableId, PublicKey memory playerPublicKey) external pure returns (uint8 playerCounts) {} function refAndCheckin(address referrer) external pure {} function checkin() external pure {} function claimTaskRewards(address player, uint8[] memory taskIds) external pure returns (uint256) {} function getCheckinStatus(address player) external pure returns (AqTaskViewInterface.CheckinStatusResponse memory) {} function getTasks(address player) external pure returns (AqTaskViewInterface.TasksResponse memory) {} function createTable(string memory name, uint8 seats, uint256 sbAmount, uint256 bbAmount, uint256 anteAmount, uint256 initialBuyin, uint256 minBuyin, uint256 maxBuyin) external pure returns (uint32 tableId) {} function removeTable(uint32 tableId) external pure {} function setTableName(uint32 tableId, string memory name) external pure {} function setTableSeats(uint32 tableId, uint8 seats) external pure {} function setBlinds(uint32 tableId, uint256 sbAmount, uint256 bbAmount, uint256 anteAmount) external pure {} function setBuyins(uint32 tableId, uint256 initialBuyin, uint256 minBuyin, uint256 maxBuyin) external pure {} function setHoldemAllInRaiseRatio(uint32 ratio) external pure {} function setHoldemShuffleTimeout(uint32 timeout) external pure {} function setHoldemRevealTimeout(uint32 timeout) external pure {} function setHoldemBetTimeout(uint32 timeout) external pure {} function setHoldemShowdownTimeout(uint32 timeout) external pure {} function setHoldemEndTimeout(uint32 timeout) external pure {} function setShuffleVerifier(address verifier) external pure {} function setRevealVerifier(address verifier) external pure {} function setCashAddress(address cash) external pure {} function setCashReferralReturnRate(AqReferralCore.ReferralReturnRate[] memory rates) external pure {} function setPointReferralReturnRate(AqReferralCore.ReferralReturnRate[] memory rates) external pure {} function setDailyTasks(AqTaskViewInterface.BasicTask[] memory tasks) external pure {} function setWeeklyTasks(AqTaskViewInterface.BasicTask[] memory tasks) external pure {} function setCheckinRewards(uint256[] memory rewards) external pure {} function setTaskReward(address point) external pure {} function setTaskDayConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) external pure {} function setTaskWeekConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) external pure {} } contract AqMain is AqModuleAdmin, AqLobbyViews, AqReferralViews, AqInitializor { uint256 public constant version = 1; function initialize() public initializer { __AQ_init(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqHoldemBetInterface } from "./AqHoldemInterfaces.sol"; import { AqHoldemIntermediate } from "./AqHoldemIntermediate.sol"; contract AqHoldemBetting is AqHoldemIntermediate, AqHoldemBetInterface { function allinBets() external override { (address player, uint32 tableId, uint256 gameId, uint8 position) = _nowPlaying(); _refreshGameState(tableId); _requireBettingStage(tableId); _requirePosition(tableId, position); uint256 balance = balanceOf(player); if (balance > 0) _placeBet(tableId, player, balance); _makeAllin( tableId, gameId, player, position, balance, _getHoldemBets(player) ); _afterBets(tableId); _refreshGameTimer(tableId, player); } // TODO: submit rTokens function foldBets() external { (address player, uint32 tableId, uint256 gameId, uint8 position) = _nowPlaying(); _refreshGameState(tableId); GameStage stage = _gameStage(tableId); if (!_isBettingStage(stage) && stage != GameStage.Showdown) revert InvalidGameStage(stage); _requirePosition(tableId, position); _makeFold(tableId, gameId, position); uint8 playerCounts = _playerCounts(tableId); if (_gameFoldCount(tableId) + 1 == playerCounts) { uint8 remainPosition = 0; for (uint8 i = 1; i <= playerCounts; i++) { if (!_hasFolded(tableId, i)) { remainPosition = i; break; } } _setHoldemGameWinners( gameId, _computePotWinners( tableId, gameId, remainPosition, _getPositionPlayer(tableId, remainPosition) ) ); } _afterBets(tableId); _refreshGameTimer(tableId, player); } function callBets() external { (address player, uint32 tableId, uint256 gameId, uint8 position) = _nowPlaying(); _refreshGameState(tableId); _requireBettingStage(tableId); _requirePosition(tableId, position); HoldemGameState memory game = _gameState(tableId); uint256 bet = _getHoldemBets(player); if (bet >= game.minBet) revert InvalidBettingOption(); uint256 callAmount = game.minBet - bet; _placeBet(tableId, player, callAmount); _makeCall( tableId, gameId, position, callAmount ); _afterBets(tableId); _refreshGameTimer(tableId, player); } function checkBets() external { (address player, uint32 tableId, uint256 gameId, uint8 position) = _nowPlaying(); _refreshGameState(tableId); _requireBettingStage(tableId); _requirePosition(tableId, position); HoldemGameState memory game = _gameState(tableId); uint256 bet = _getHoldemBets(player); if (game.minBet > bet) revert InvalidBettingOption(); _makeCheck(tableId, gameId, position); _afterBets(tableId); _refreshGameTimer(tableId, player); } function raiseBets(uint256 raiseAmount) external { (address player, uint32 tableId, uint256 gameId, uint8 position) = _nowPlaying(); _refreshGameState(tableId); _requireBettingStage(tableId); _requirePosition(tableId, position); HoldemGameState memory game = _gameState(tableId); if (raiseAmount < game.lastRaise) revert RaiseTooSmall(game.lastRaise); uint256 bet = _getHoldemBets(player); uint256 callAmount = game.minBet - bet; _placeBet(tableId, player, callAmount + raiseAmount); _makeRaise( tableId, gameId, position, callAmount, raiseAmount, _getHoldemBets(player) ); _afterBets(tableId); _refreshGameTimer(tableId, player); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { BitMath } from "../libraries/BitMath.sol"; import { DENO } from "../AqConstants.sol"; import { AqHoldemCoreInterface } from "./AqHoldemInterfaces.sol"; contract AqHoldemCore is AqHoldemCoreInterface { // @custom:storage-location erc7201:ace-quest.holdem struct HoldemStorage { mapping(uint32 => uint256[3]) _blinds; // [small, big, ante] mapping(uint32 => HoldemGameState) _games; mapping(address => uint256) _bets; /** @dev bitwise card indexes that player has revealed */ mapping(address => uint64) _reveals; mapping(address => HoldemHandRanking) _hands; mapping(uint256 => uint8[52]) _revealTokenCounts; /** @dev ASC sorted all-in amounts */ mapping(uint256 => uint256[]) _allinAmounts; mapping(uint256 => HoldemPotWinner[]) _winners; /** * We preserve the deck hash to prevent the same deck being used twice. * in the same series. * * @dev keccak(deck hash) => seriesId */ mapping(bytes32 => uint64) _deckLastSeries; HoldemSettings _settings; } // keccak256(abi.encode(uint256(keccak256("ace-quest.holdem")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant HoldemStorageLocation = 0xaeab8c8f667692046c08d9c0d9411d27ad5a86ae53426657682d81084c4d2300; function _getHoldemStorage() private pure returns (HoldemStorage storage $) { assembly { $.slot := HoldemStorageLocation } } function __AqHoldem_init_unchained() internal { _setHoldemAllinRaiseRatio(100); _setHoldemShuffleTimeout(5 minutes); _setHoldemRevealTimeout(5 minutes); _setHoldemBetTimeout(10 minutes); _setHoldemShowdownTimeout(10 minutes); _setHoldemEndTimeout(30 minutes); _setWinnerFeeRatio(uint32(DENO / 10)); // 10% } /* ██████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _gameState(uint32 tableId) internal view returns (HoldemGameState memory) { return _getHoldemStorage()._games[tableId]; } function _sbAmount(uint32 tableId) internal view returns (uint256) { return _getHoldemStorage()._blinds[tableId][0]; } function _bbAmount(uint32 tableId) internal view returns (uint256) { return _getHoldemStorage()._blinds[tableId][1]; } function _anteAmount(uint32 tableId) internal view returns (uint256) { return _getHoldemStorage()._blinds[tableId][2]; } function _lastDeckSeriesId(bytes32 deckHash) internal view returns (uint64) { return _getHoldemStorage()._deckLastSeries[deckHash]; } function _gameStage(uint32 tableId) internal view returns (GameStage) { return _getHoldemStorage()._games[tableId].stage; } function _gameFoldCount(uint32 tableId) internal view returns (uint8) { return _getHoldemStorage()._games[tableId].foldedCount; } function _gameStageTimeout(uint32 tableId) internal view returns (uint64) { return _getHoldemStorage()._games[tableId].timeout; } function _actingPosition(uint32 tableId) internal view returns (uint8) { return _getHoldemStorage()._games[tableId].position; } function _hasAllin(uint32 tableId, uint8 posId) internal view returns (bool) { return _getHoldemStorage()._games[tableId].allin & uint16(1 << posId - 1) != 0; } function _hasFolded(uint32 tableId, uint8 posId) internal view returns (bool) { return _getHoldemStorage()._games[tableId].folded & uint16(1 << posId - 1) != 0; } function _hasClaimed(uint32 tableId, uint8 posId) internal view returns (bool) { return _getHoldemStorage()._games[tableId].claimed & uint16(1 << posId - 1) != 0; } function _getHoldemBets(address player) internal view returns (uint256) { return _getHoldemStorage()._bets[player]; } function _getAllinAmounts(uint256 gameId) internal view returns (uint256[] memory) { return _getHoldemStorage()._allinAmounts[gameId]; } function _toWinnerFee(uint256 amount) internal view returns (uint256) { return amount * _getHoldemSettings().winnerFeeRatio / DENO; } /** @dev Stages that players should choose a bet option */ function _isBettingStage(GameStage stage) internal pure returns (bool) { return stage == GameStage.PreFlop || stage == GameStage.Flop || stage == GameStage.Turn || stage == GameStage.River; } /** @dev Stages that players should submit reveal tokens */ function _isZkRevealStage(GameStage stage) internal pure returns (bool) { return stage == GameStage.CutCards || stage == GameStage.RevealFlopCards || stage == GameStage.RevealTurnCards || stage == GameStage.RevealRiverCards; } function _isZkStageOvertime(uint32 tableId) internal view returns ( bool overtime, uint64 nextTimeout ) { HoldemStorage storage $ = _getHoldemStorage(); if (_isZkRevealStage($._games[tableId].stage)) { overtime = block.timestamp > $._games[tableId].timeout; if (overtime) nextTimeout = $._games[tableId].timeout + $._settings.endTimeout; } return (false, 0); } function _requiredGameStage(uint32 tableId, GameStage stage) internal view { if (_gameStage(tableId) != stage) revert InvalidGameStage(_gameStage(tableId)); } function _requireBettingStage(uint32 tableId) internal view { if (!_isBettingStage(_gameStage(tableId))) revert InvalidGameStage(_gameStage(tableId)); } function _requirePosition(uint32 tableId, uint8 posId) internal view { if (_actingPosition(tableId) != posId) revert NotYourTurn(); } function _hasRevealed( address player, uint8 cardIndex ) internal view returns (bool) { HoldemStorage storage $ = _getHoldemStorage(); return $._reveals[player] & uint64(1 << cardIndex) != 0; } function _hasPositionPlayerRevealedHoleCards( uint8 posId, address player ) internal view returns (bool) { HoldemStorage storage $ = _getHoldemStorage(); uint64 playerHands = uint64(0x3 << (posId * 2 - 2)); return $._reveals[player] & playerHands == playerHands; } function _holdemStageCommunityCardCounts(GameStage stage) internal pure returns (uint8) { if (stage < GameStage.Flop) return 0; if (stage < GameStage.Turn) return 3; if (stage < GameStage.River) return 4; return 5; } /** @dev Bitwise card indexes */ function _bHoldemCardsToReveals( GameStage stage, uint8 posId, uint8 playerCounts ) internal pure returns (uint32) { unchecked { if (stage == GameStage.CutCards) { // Other's hole cards uint32 allHoleCards = uint32(0x1 << (playerCounts * 2)) - 1; uint32 playerHands = uint32(0x3 << (posId * 2 - 2)); return allHoleCards ^ playerHands; } if (stage == GameStage.RevealFlopCards) { // First 3 community cards return uint32(0x7 << (playerCounts * 2)); } if (stage == GameStage.RevealTurnCards) { // 4th community card return uint32(0x1 << (playerCounts * 2 + 3)); } if (stage == GameStage.RevealRiverCards) { // 5th community card return uint32(0x1 << (playerCounts * 2 + 4)); } if (stage == GameStage.Showdown) { // Self hole cards return uint32(0x3 << (posId * 2 - 2)); } } return 0; } /** @dev Bitwise all community card indexes */ function _bCommunityCards(uint8 playerCounts) internal pure returns (uint32) { return uint32(0x1F << (playerCounts * 2)); } function _bUnreveals( address player, uint8 playerCounts, GameStage stage, uint8 posId ) internal view returns (uint32) { HoldemStorage storage $ = _getHoldemStorage(); return _bHoldemCardsToReveals(stage, posId, playerCounts) & ~uint32($._reveals[player]); } function _toRevealCards( address player, uint8 playerCounts, GameStage stage, uint8 posId ) internal view returns (uint8[] memory cardIndexes) { return _bitwiseToCardIndexes( _bUnreveals(player, playerCounts, stage, posId) ); } function _unrevealedCommunityCards( address player, uint8 playerCounts ) internal view returns (uint8[] memory cardIndexes) { HoldemStorage storage $ = _getHoldemStorage(); uint32 bIndexes = _bCommunityCards(playerCounts); bIndexes &= ~uint32($._reveals[player]); return _bitwiseToCardIndexes(bIndexes); } function _bitwiseToCardIndexes(uint32 bIndexes) internal pure returns (uint8[] memory cardIndexes) { cardIndexes = new uint8[](BitMath.popcount32(bIndexes)); for (uint8 i = 0; i < cardIndexes.length; i++) { cardIndexes[i] = BitMath.leastSignificantBit32(bIndexes); bIndexes &= ~(uint32(1) << cardIndexes[i]); } } function _getHoldemSettings() internal view returns (HoldemSettings memory) { return _getHoldemStorage()._settings; } function _getHoldemPlayerHandRanking(address player) internal view returns (HoldemHandRanking memory) { HoldemStorage storage $ = _getHoldemStorage(); return $._hands[player]; } function _getHoldemPotWinners(uint256 gameId) internal view returns (HoldemPotWinner[] memory) { return _getHoldemStorage()._winners[gameId]; } function _computeLastActionStarts(HoldemGameState memory game) internal view returns (uint64) { if (game.timeout == 0) return 0; HoldemSettings memory settings = _getHoldemSettings(); if (game.stage == GameStage.Showdown) { return game.timeout - settings.showdownTimeout; } else if ( game.stage == GameStage.NormalEnd || game.stage == GameStage.UnusualEnd ) { return game.timeout - settings.endTimeout; } else if (_isBettingStage(game.stage)) { return game.timeout - settings.betTimeout; } else if (_isZkRevealStage(game.stage)) { return game.timeout - settings.revealTimeout; } else if (game.stage == GameStage.Shuffle) { return game.timeout - settings.shuffleTimeout; } // Unknown stage return game.timeout; } /* ███████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _updateGameState( uint32 tableId, HoldemGameState memory newState ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId] = newState; } function _setBlinds( uint32 tableId, uint256 sbAmount, uint256 bbAmount, uint256 anteAmount ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._blinds[tableId] = [sbAmount, bbAmount, anteAmount]; } function _setLastDeckSeriesId(bytes32 deckHash, uint64 seriesId) internal { HoldemStorage storage $ = _getHoldemStorage(); $._deckLastSeries[deckHash] = seriesId; } function _resetHoldemPlayer(address player) internal { HoldemStorage storage $ = _getHoldemStorage(); delete $._bets[player]; delete $._reveals[player]; delete $._hands[player]; } function _restartGameStage(uint32 tableId) internal { HoldemStorage storage $ = _getHoldemStorage(); delete $._games[tableId]; $._games[tableId].stage = GameStage.Shuffle; } function _clearHoldemGame(uint256 gameId) internal { HoldemStorage storage $ = _getHoldemStorage(); delete $._revealTokenCounts[gameId]; delete $._allinAmounts[gameId]; delete $._winners[gameId]; } function _afterShuffleStage(uint32 tableId) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId].stage = GameStage.CutCards; $._games[tableId].timeout = uint64(block.timestamp + $._settings.revealTimeout); $._games[tableId].position = 0; $._games[tableId].betMatched = 0; $._games[tableId].minBet = _bbAmount(tableId); $._games[tableId].lastRaise = _bbAmount(tableId); } function _flagDisapproved(uint32 tableId, uint8 pos) internal { HoldemStorage storage $ = _getHoldemStorage(); unchecked { $._games[tableId].disapproved |= uint16(1 << pos - 1); } } function _flagApproved(uint32 tableId, uint8 pos) internal { HoldemStorage storage $ = _getHoldemStorage(); unchecked { $._games[tableId].disapproved &= ~uint16(1 << pos - 1); } } function _flagRevealed( address player, uint256 gameId, uint8 cardIndex ) internal returns (uint8 count) { HoldemStorage storage $ = _getHoldemStorage(); $._revealTokenCounts[gameId][cardIndex] += 1; $._reveals[player] |= uint64(1 << cardIndex); return $._revealTokenCounts[gameId][cardIndex]; } function _flagShowdown( uint32 tableId, uint8 posId ) internal { HoldemStorage storage $ = _getHoldemStorage(); unchecked { $._games[tableId].showed |= uint16(1 << posId - 1); } } function _flagClaimed( uint32 tableId, uint8 pos ) internal { HoldemStorage storage $ = _getHoldemStorage(); unchecked { $._games[tableId].claimed |= uint16(1 << pos - 1); } } function _increaseHoldemBet( address player, uint256 amount ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._bets[player] += amount; } function _resetBet(address player) internal { HoldemStorage storage $ = _getHoldemStorage(); delete $._bets[player]; } function _setHoldemAllinRaiseRatio(uint32 ratio) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.allInRaiseRatio = ratio; } function _setHoldemShuffleTimeout(uint32 timeout) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.shuffleTimeout = timeout; } function _setHoldemRevealTimeout(uint32 timeout) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.revealTimeout = timeout; } function _setHoldemBetTimeout(uint32 timeout) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.betTimeout = timeout; } function _setHoldemShowdownTimeout(uint32 timeout) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.showdownTimeout = timeout; } function _setHoldemEndTimeout(uint32 timeout) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.endTimeout = timeout; } function _setWinnerFeeRatio(uint32 ratio) internal { HoldemStorage storage $ = _getHoldemStorage(); $._settings.winnerFeeRatio = ratio; } function _setHoldemPlayerHandRanking( address player, HoldemHandRanking memory ranking ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._hands[player] = ranking; } function _setHoldemGameWinners( uint256 gameId, HoldemPotWinner[] memory winners ) internal { HoldemStorage storage $ = _getHoldemStorage(); delete $._winners[gameId]; for (uint8 i = 0; i < winners.length; i++) { $._winners[gameId].push(winners[i]); } } /* ██████ ███████ ████████ ███████ ██ ██ ██ ██ ██ ██████ █████ ██ ███████ ██ ██ ██ ██ ██ ██████ ███████ ██ ███████ */ function _makeRaise( uint32 tableId, uint256 gameId, uint8 posId, uint256 callAmount, uint256 raiseAmount, uint256 totalBet ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId].betMatched = uint16(1 << posId - 1); $._games[tableId].lastRaise = raiseAmount; $._games[tableId].minBet = totalBet; emit Bet( gameId, $._games[tableId].stage, tableId, posId, BettingOption.Raise, callAmount, raiseAmount ); } function _actCheck( HoldemGameState memory game, uint8 posId ) internal pure returns (HoldemGameState memory) { game.betMatched |= uint16(1 << posId - 1); return game; } function _makeCheck( uint32 tableId, uint256 gameId, uint8 posId ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId] = _actCheck($._games[tableId], posId); emit Bet( gameId, $._games[tableId].stage, tableId, posId, BettingOption.Check, 0, 0 ); } function _actCall( HoldemGameState memory game, uint8 posId ) internal pure returns (HoldemGameState memory) { game.betMatched |= uint16(1 << posId - 1); return game; } function _makeCall( uint32 tableId, uint256 gameId, uint8 posId, uint256 callAmount ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId] = _actCall($._games[tableId], posId); emit Bet( gameId, $._games[tableId].stage, tableId, posId, BettingOption.Call, callAmount, 0 ); } function _actFold( HoldemGameState memory game, uint8 posId ) internal pure returns (HoldemGameState memory) { game.folded |= uint16(1 << posId - 1); game.foldedCount++; return game; } function _makeFold( uint32 tableId, uint256 gameId, uint8 posId ) internal { HoldemStorage storage $ = _getHoldemStorage(); $._games[tableId] = _actFold($._games[tableId], posId); emit Bet( gameId, $._games[tableId].stage, tableId, posId, BettingOption.Fold, 0, 0 ); } function _makeAllin( uint32 tableId, uint256 gameId, address player, uint8 posId, uint256 balance, uint256 totalBet ) internal { HoldemStorage storage $ = _getHoldemStorage(); unchecked { $._games[tableId].allin |= uint16(1 << posId - 1); } uint256 callAmount = $._games[tableId].minBet > $._bets[player] ? $._games[tableId].minBet - $._bets[player] : 0; uint256 raiseAmount = 0; if (balance > callAmount) { raiseAmount = balance - callAmount; uint256 minRaise = $._games[tableId].lastRaise * $._settings.allInRaiseRatio / 100; if (raiseAmount > minRaise) { $._games[tableId].lastRaise = raiseAmount; } } _updateAllinAmounts(gameId, totalBet); if ($._games[tableId].minBet < totalBet) { $._games[tableId].minBet = totalBet; $._games[tableId].betMatched = $._games[tableId].allin; } emit Bet( gameId, $._games[tableId].stage, tableId, posId, BettingOption.Allin, callAmount, raiseAmount ); } function _updateAllinAmounts( uint256 gameId, uint256 newAmount ) internal { HoldemStorage storage $ = _getHoldemStorage(); uint8 insertAt = 0; for (uint8 i = 0; i < $._allinAmounts[gameId].length; i++) { if ($._allinAmounts[gameId][i] == newAmount) return; if ($._allinAmounts[gameId][i] > newAmount) { break; } else { insertAt = i + 1; } } uint256 cachedAmount = newAmount; for (uint8 i = insertAt; i < $._allinAmounts[gameId].length; i++) { uint256 tmp = $._allinAmounts[gameId][i]; $._allinAmounts[gameId][i] = cachedAmount; cachedAmount = tmp; } $._allinAmounts[gameId].push(cachedAmount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { EdOnBN254 } from "uzkge/contracts/libraries/EdOnBN254.sol"; import { IHoldemErrors } from "../AqErrors.sol"; interface AqHoldemCoreInterface is IHoldemErrors { enum HoldemPlayerStatus { None, Active, AllIn, Folded } enum BettingOption { Check, Call, Raise, Allin, Fold } enum HandRanking { Unknown, HighCard, Pair, TwoPair, ThreeOfAKind, Straight, Flush, FullHouse, FourOfAKind, StraightFlush, RoyalFlush } struct HoldemTableSettings { uint32 id; uint8 seats; uint256 smallBlind; uint256 bigBlind; uint256 ante; uint256 initialBuyin; uint256 minBuyin; // unused uint256 maxBuyin; // unused uint256 gameSeed; } struct HoldemGameState { GameStage stage; uint8 position; uint64 timeout; uint8 foldedCount; //// bitwise flags ------------------------------------- // Position 9 8.. ..1 // 0b 0000_0000_0000_0000 uint16 folded; uint16 allin; uint16 betMatched; // Has matched current bets (allin is considered as matched) uint16 showed; // Has showed hole cards uint16 claimed; uint16 disapproved; //// bitwise flags ------------------------------------- uint256 minBet; uint256 lastRaise; uint256 lastStageBalancedBet; } struct HoldemPokerCard { PokerSuit suit; PokerRank rank; uint256[4] backface; RevealToken[] revealTokens; } struct HoldemSettings { /** * @dev When player all-in, bets over N % of last raise would be consider * as a "raise" call. */ uint32 allInRaiseRatio; uint32 shuffleTimeout; uint32 revealTimeout; uint32 betTimeout; uint32 showdownTimeout; uint32 endTimeout; uint32 winnerFeeRatio; uint32 __GAP__; } struct HoldemHandRanking { HandRanking ranking; uint64 kickers; } struct ComputedHoldemPot { uint256 amount; uint8[] positions; } struct HoldemPot { uint256 amount; uint8[] positions; uint8[] winners; HandRanking winnerHandRanking; } struct HoldemPotWinner { HandRanking ranking; uint64 kickers; uint256 sharedReward; uint8 sharedCount; uint16 positions; } event Bet( uint256 indexed gameId, GameStage stage, uint32 indexed tableId, uint8 indexed position, BettingOption option, uint256 callAmount, uint256 raiseAmount ); event ClaimedPot( uint256 indexed gameId, uint8 position, address player, uint256 amount, uint256 fee ); } interface AqHoldemShufflerInterface is AqHoldemCoreInterface { event DeckShuffled(uint256 indexed gameId, address dealer); function shuffle( uint256 gameId, uint256[4][52] calldata maskedCards, uint256[4][52] calldata shuffledCards, bytes calldata proof, uint256[] calldata pkc ) external; } interface AqHoldemRevealerInterface is AqHoldemCoreInterface { event ShowdownResult( uint256 indexed gameId, address indexed player, HandRanking handRank, uint64 kickers ); struct RevealTokenSubmission { uint8 cardIndex; RevealToken revealToken; bytes revealProof; } /** @notice Provide reveal tokens */ function showCards(RevealTokenSubmission[] calldata reveals) external; } interface AqHoldemRewardInterface is AqHoldemCoreInterface { function cashOut() external; /** * @notice Claim pots * @dev This function receive a player position, so we can accumulate claimable * pots by static call this function. */ function claimPots(uint32 tableId, uint8 pos) external returns (uint256 amount); /** @dev Only available when someone in the game flag overtime */ function ponish(uint32 tableId) external; } interface AqHoldemBetInterface is AqHoldemCoreInterface { function allinBets() external; function foldBets() external; function callBets() external; function checkBets() external; function raiseBets(uint256 raiseAmount) external; } interface AqHoldemViewInterface is AqHoldemCoreInterface { struct TexasHoldemGame { uint64 gameId; GameStage stage; uint256 minRaise; uint256 betAmount; uint256 lastStageBet; uint8 actingPosition; uint32 actingTimeout; } function holdemTimers() external view returns ( uint32 shuffleTimeout, uint32 revealTimeout, uint32 betTimeout, uint32 showdownTimeout, uint32 endTimeout ); struct HoldemPosition { uint8 pid; // 1-based address wallet; HoldemPlayerStatus status; HoldemPokerCard[] holeCards; uint256 bets; uint256 chips; /** @dev Cards that player should reveal in this stage */ uint8[] toReveals; /** @dev Player have to reveal these cards before folding */ uint8[] unrevealedCommunityCards; // uint256 pendingBuyin; } struct HoldemTableStatus { uint32 id; uint256 gameId; PublicKey gameKey; GameStage stage; HoldemPosition[] positions; HoldemPokerCard[] communityCards; HoldemPot mainPot; HoldemPot[] sidePots; uint256 minRaise; uint256 betAmount; uint256 lastStageBet; uint8 actingPosition; uint64 actingTimeStart; uint64 actingTimeout; uint256[4][] deck; uint64 timestamp; } function table(uint32 tableId) external view returns (HoldemTableStatus memory); } interface AqHoldemClientInterface is AqHoldemBetInterface, AqHoldemShufflerInterface, AqHoldemRevealerInterface, AqHoldemRewardInterface, AqHoldemViewInterface {}
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqCore } from "../AqCore.sol"; abstract contract AqHoldemIntermediate is AqCore { function _nowPlaying() internal view returns ( address player, uint32 tableId, uint256 gameId, uint8 position ) { player = _msgOwner(); tableId = _playerLastTable(player); if (tableId == 0) revert NotPlaying(player); gameId = _gameId(tableId); if (!_isTablePlaying(tableId)) revert GameNotOngoing(gameId); // Player init position is not match current table state => table already finished if (_getTableInitPosition( tableId, _playerInitPos(player) ) != player) revert TableAlreadyFinished(tableId); position = _playerPosition(player); } function _refreshGameState(uint32 tableId) internal { _updateGameState(tableId, _currentGameState(tableId)); } /** @dev Quick forward to current state, auto check/fold overtime players */ function _currentGameState(uint32 tableId) internal view returns (HoldemGameState memory game) { game = _gameState(tableId); uint8 playerCounts = _seats(tableId); uint64 current = uint64(block.timestamp); if (_isBettingStage(game.stage)) { GameStage before = game.stage; for ( ; game.stage == before && game.position > 0 && game.timeout < current; ) { address player = _getPositionPlayer(tableId, game.position); game = _getHoldemBets(player) < game.minBet ? _actFold(game, game.position) : _actCheck(game, game.position); game = _computeNext( game, playerCounts, game.position, game.timeout ); } } if (_isZkRevealStage(game.stage)) { if (game.timeout < current) { game.stage = GameStage.UnusualEnd; game.timeout = current + _getHoldemSettings().endTimeout; // TODO: flag unrevealed players!!!! } } if (game.stage == GameStage.Showdown) { for ( ; game.stage == GameStage.Showdown && game.position > 0 && game.timeout < current; ) { game = _actFold(game, game.position); game = _computeNext( game, playerCounts, game.position, game.timeout ); } } return game; } function _refreshGameTimer(uint32 tableId, address player) internal { _refreshPlayerTimer(player); _refreshTableTimer(tableId); } function _gameDeckSize(uint256 gameId) internal view returns (uint8) { uint8 playerCounts = _gamePlayerCounts(gameId); return uint8(2 * playerCounts + 5); } /** @dev For transactions had refresh game state before */ function _getHoldemPositionStatus( uint32 tableId, uint8 posId ) internal view returns (HoldemPlayerStatus) { if (posId == 0 || posId > _seats(tableId)) return HoldemPlayerStatus.None; if (_hasAllin(tableId, posId)) return HoldemPlayerStatus.AllIn; if (_hasFolded(tableId, posId)) return HoldemPlayerStatus.Folded; return HoldemPlayerStatus.Active; } /** @dev For view function calls */ function _parseHoldemGamePositionStatus( HoldemGameState memory game, uint8 posId, uint8 playerCounts ) internal pure returns (HoldemPlayerStatus) { if (posId == 0 || posId > playerCounts) return HoldemPlayerStatus.None; if (game.allin & uint16(1 << posId - 1) != 0) return HoldemPlayerStatus.AllIn; if (game.folded & uint16(1 << posId - 1) != 0) return HoldemPlayerStatus.Folded; return HoldemPlayerStatus.Active; } function _getPlayerPosition( address /* player */, uint8 initPosition, uint8 playerCounts, uint32 rounds ) internal pure returns (uint8) { if (initPosition == 0 || playerCounts == 0 || rounds == 0) return 0; return uint8( (initPosition + playerCounts - 1 - (rounds - 1) % playerCounts) % playerCounts + 1 ); } /** @dev address => positionId */ function _playerPosition(address player) internal view returns (uint8) { uint32 tableId = _playerLastTable(player); return _getPlayerPosition( player, _playerInitPos(player), // _players[player].initPosition, _playerCounts(tableId), // uint8(_seriesPlayers.length), _tableSeriesGameCounts(tableId) //_series.totalSeriesGames ); } /** * @dev players [P0, P1, P2, P3, ...] * r1 1 2 3 4 SB ----> BTN * r2 4 1 2 3 BTN ---> CO (原 SB[1] 要變成 BTN[4]) * r3 3 4 1 2 * r4 2 3 4 1 * r5 1 2 3 4 */ function _getPositionPlayer( uint32 tableId, uint8 posId ) internal view returns (address) { uint64 sGameNumber = _tableSeriesGameCounts(tableId); uint8 playerCounts = _playerCounts(tableId); // pid & round shound be 1-based if (posId < 1 || sGameNumber < 1 || posId > playerCounts) return address(0); return _getTableInitPosition( tableId, uint8((sGameNumber + posId - 2) % playerCounts) + 1 ); } function _holeCards( uint256 gameId, GameStage stage, uint8 pos ) internal view returns (HoldemPokerCard[] memory cards) { if (stage < GameStage.PreFlop) return cards; cards = new HoldemPokerCard[](2); cards[0] = _getHoldemPokerCard(gameId, pos * 2 - 2); cards[1] = _getHoldemPokerCard(gameId, pos * 2 - 1); return cards; } function _getHoldemPokerCard( uint256 gameId, uint8 cardIndex ) internal view returns (HoldemPokerCard memory card) { PokerCard memory revealed = _getPoker(gameId, cardIndex); if (revealed.suit != PokerSuit.Unknown && revealed.rank != PokerRank.Unknown) { card.suit = revealed.suit; card.rank = revealed.rank; return card; } card.backface = _getClientFormatGameCard(gameId, cardIndex); card.revealTokens = _getRevealTokens(gameId, cardIndex); return card; } function _communityCards( uint256 gameId, GameStage stage, uint8 playerCounts ) internal view returns (HoldemPokerCard[] memory cards) { uint8 counts = _holdemStageCommunityCardCounts(stage); if (counts == 0) return cards; uint8 i = 2 * playerCounts; cards = new HoldemPokerCard[](counts); for (uint8 j = 0; j < cards.length; j++) { cards[j] = _getHoldemPokerCard(gameId, i + j); } return cards; } function _getBigBlind(uint32 tableId) internal view returns ( address player, uint256 amount ) { return _seats(tableId) == 2 ? (_getPositionPlayer(tableId, 1), _bbAmount(tableId)) : (_getPositionPlayer(tableId, 2), _bbAmount(tableId)); } function _getSmallBlind(uint32 tableId) internal view returns ( address player, uint256 amount ) { return _seats(tableId) == 2 ? (_getPositionPlayer(tableId, 2), _sbAmount(tableId)) : (_getPositionPlayer(tableId, 1), _sbAmount(tableId)); } /** @dev We deal minBet & betMatched logics in _make<BetOption> methods */ function _placeBet(uint32 tableId, address player, uint256 amount) internal { _increaseHoldemBet(player, amount); _increaseTablePot(tableId, amount); _transfer(player, address(this), amount); _increaseReferralBets(player, amount); _increaseBetTask(player, uint128(amount)); } function _isAllRevealed( uint32 tableId, GameStage stage, uint8 playerCounts ) internal view returns (bool) { for (uint8 posId = 1; posId <= playerCounts; posId++) { if (_bUnreveals( _getPositionPlayer(tableId, posId), playerCounts, stage, posId ) > 0) return false; } return true; } function _enabled(uint16 flags, uint8 pos) internal pure returns (bool) { return flags & uint16(1 << pos - 1) > 0; } function _findNextPosition( uint16 bExclude, uint8 fromPos, uint8 totalPositions ) internal pure returns (uint8) { for (uint8 i = 0; i < totalPositions; i++) { uint8 pos = (fromPos + i - 1) % totalPositions + 1; if (_enabled(bExclude, pos)) continue; return pos; } return 0; } /** @dev Only for betting & showdown stages */ function _computeNext( HoldemGameState memory game, uint8 playerCounts, uint8 fromPos, uint64 fromTime ) internal view returns (HoldemGameState memory) { HoldemSettings memory _settings = _getHoldemSettings(); // The only remaining player, quick forward to the end if (game.foldedCount + 1 == playerCounts) { game.stage = GameStage.NormalEnd; game.timeout = fromTime + _settings.endTimeout; return game; } uint16 allActed = uint16(1 << playerCounts) - 1; // Showdown stage: if (game.stage == GameStage.Showdown) { // All showdown or folded -> To the end if (game.showed | game.folded == allActed) { game.stage = GameStage.NormalEnd; game.timeout = fromTime + _settings.endTimeout; } else { // Showdown by position game.position = _findNextPosition( game.showed | game.folded, fromPos, playerCounts ); game.timeout = fromTime + _settings.showdownTimeout; } return game; } if (game.betMatched | game.folded | game.allin == allActed) { game.stage = GameStage(uint8(game.stage) + 1); game.lastStageBalancedBet = game.minBet; game.betMatched = game.allin; game.timeout = game.stage == GameStage.Showdown ? fromTime + _settings.showdownTimeout : fromTime + _settings.revealTimeout; game.position = _findNextPosition( game.folded | game.allin, 1, playerCounts ); } else { game.timeout = fromTime + _settings.betTimeout; game.position = _findNextPosition( game.folded | game.allin, fromPos + 1, playerCounts ); } return game; } function _afterShowdownStateChanged( uint32 tableId, uint8 playerCounts, uint8 pos ) internal { HoldemGameState memory game = _gameState(tableId); _updateGameState(tableId, _computeNext( game, playerCounts, pos, uint64(block.timestamp) )); } /** * For CutCards | RevealFlopCards | RevealTurnCards | RevealRiverCards stages * after they revealed all required cards, we move to next stage by this method */ function _afterZkStateChanged( uint32 tableId, uint8 playerCounts ) internal { HoldemGameState memory game = _gameState(tableId); // Keep in ZK stages if (!_isAllRevealed(tableId, game.stage, playerCounts)) return; game.stage = GameStage(uint8(game.stage) + 1); game.betMatched = 0; uint8 initPos = 1; if (game.stage == GameStage.PreFlop) { initPos = _seats(tableId) == 2 ? 2 : 3; } game.position = _findNextPosition( game.folded | game.allin, initPos, playerCounts ); // Skip betting stages if remain players are all-in if (_isBettingStage(game.stage) && game.position == 0) { game.stage = GameStage(uint8(game.stage) + 1); game.timeout = game.stage == GameStage.Showdown ? uint64(block.timestamp) + _getHoldemSettings().showdownTimeout : uint64(block.timestamp) + _getHoldemSettings().revealTimeout; // If Showdown stage, we need to find the first un-folded position if (game.stage == GameStage.Showdown) { game.position = _findNextPosition( game.showed | game.folded, 1, playerCounts ); } } else { game.timeout = uint64(block.timestamp) + _getHoldemSettings().betTimeout; } _updateGameState(tableId, game); } function _afterBets(uint32 tableId) internal { HoldemGameState memory last = _gameState(tableId); _updateGameState(tableId, _computeNext( last, _seats(tableId), last.position, uint64(block.timestamp) )); } struct ComputePot { uint256 maxAllin; uint8 totalPotCounts; uint8 removals; uint256 minBet; } function _computePots( HoldemGameState memory game, uint32 tableId, uint256[] memory bets ) internal view returns ( ComputedHoldemPot memory mainPot, ComputedHoldemPot[] memory sidePots ) { uint256[] memory allins = _getAllinAmounts(_gameId(tableId)); ComputePot memory vars = ComputePot({ maxAllin: allins.length == 0 ? 0 : allins[allins.length - 1], totalPotCounts: allins.length == 0 ? 1 : uint8(allins.length), removals: 0, minBet: 0 }); if (vars.maxAllin > 0) { for (uint8 i = 0; i < bets.length; i++) { // With all-in && any bets over max all-in amounts if (bets[i] > vars.maxAllin) { vars.totalPotCounts++; break; } } } if (vars.totalPotCounts > 1) sidePots = new ComputedHoldemPot[](vars.totalPotCounts - 1); for (uint8 i = 0; i < bets.length; i++) { mainPot.amount += bets[i]; // We cache totalPots in main pot here // main pot position-players are not calculated yet if (_enabled(game.folded, i + 1) || bets[i] == 0) vars.removals++; } // Fill side pots from last index // uint256 last = 0; for (uint8 i = 0; i < sidePots.length; i++) { uint8 potIndex = uint8(sidePots.length) - 1 - i; uint256 betAmount = allins[i] - vars.minBet; sidePots[potIndex].positions = new uint8[](bets.length - vars.removals); uint8 filled = 0; for (uint8 j = 0; j < bets.length; j++) { uint8 pos = j + 1; if (_enabled(game.folded, pos) || bets[j] == 0) continue; sidePots[potIndex].positions[filled++] = pos; if (bets[j] > betAmount) { mainPot.amount -= betAmount; sidePots[potIndex].amount += betAmount; bets[j] -= betAmount; } else { mainPot.amount -= bets[j]; sidePots[potIndex].amount += bets[j]; bets[j] = 0; vars.removals++; } } vars.minBet = allins[i]; } // Update main pot mainPot.positions = new uint8[](bets.length - vars.removals); uint8 idx = 0; for (uint8 i = 0; i < bets.length; i++) { uint8 pos = i + 1; if (_enabled(game.folded, pos) || bets[i] == 0) continue; mainPot.positions[idx++] = pos; } } function _allBets(uint32 tableId) internal view returns (uint256[] memory bets) { uint8 playerCounts = _seats(tableId); bets = new uint256[](playerCounts); for (uint8 i = 0; i < playerCounts; i++) { bets[i] = _getHoldemBets(_getPositionPlayer(tableId, i + 1)); } return bets; } function _computePotWinners( uint32 tableId, uint256 gameId, uint8 position, address player ) internal view returns (HoldemPotWinner[] memory winners) { HoldemPotWinner[] memory prevWinners = _getHoldemPotWinners(gameId); (ComputedHoldemPot memory mainPot, ComputedHoldemPot[] memory sidePots) = _computePots( _gameState(tableId), tableId, _allBets(tableId) ); if (prevWinners.length < sidePots.length + 1) prevWinners = new HoldemPotWinner[](sidePots.length + 1); HoldemHandRanking memory hand = _getHoldemPlayerHandRanking(player); winners = new HoldemPotWinner[](sidePots.length + 1); // Go through all pots, 0: main pot / 1: side pot[0] ... for (uint8 i = 0; i < winners.length; i++) { bool joined; ComputedHoldemPot memory pot = i == 0 ? mainPot : sidePots[i - 1]; for (uint j = 0; j < pot.positions.length; j++) { if (pot.positions[j] == position) { joined = true; break; } } if (!joined) continue; if ( prevWinners[i].ranking == hand.ranking && prevWinners[i].kickers == hand.kickers ) { // Equal ranking, shared reward winners[i] = HoldemPotWinner({ ranking: hand.ranking, kickers: hand.kickers, sharedReward: pot.amount / (prevWinners[i].sharedCount + 1), sharedCount: prevWinners[i].sharedCount + 1, positions: prevWinners[i].positions | uint16(1 << position - 1) }); } else if ( prevWinners[i].ranking < hand.ranking || (prevWinners[i].ranking == hand.ranking && prevWinners[i].kickers < hand.kickers) ) { // New winner winners[i] = HoldemPotWinner({ ranking: hand.ranking, kickers: hand.kickers, sharedReward: pot.amount, sharedCount: 1, positions: uint16(1 << position - 1) }); } else { // No changes winners[i] = prevWinners[i]; } } } function _computeHandRanking(PokerCard[5] memory cards) internal pure returns ( HandRanking ranking, uint64 kickers ) { uint32 suits = 0; uint32 rankExists = 0; uint64 rankCounts = 0; for (uint8 i = 0; i < cards.length; i++) { uint8 _suit = uint8(cards[i].suit) - 1; // Revert if PokerSuit.Unknown uint8 _rank = uint8(cards[i].rank) - 1; // Revert if PokerRank.Unknown // 0b 0000_0000_0000_0000 // C D H S suits += uint32(1 << _suit * 4); // 0b 0000_0000_0000_0000 // AK QJT9 8765 432A rankExists |= uint32(1 << _rank) | uint32(1 << _rank + 13); rankCounts += _rank == 0 ? uint64(1 << 13 * 4) : uint64(1 << _rank * 4); } // 0x1111 => 0b 0001_0001_0001_0001 bool isFlush = (suits / 5 & 0x1111) * 5 == suits; bool isStraight = false; uint64 straightHigh = 0; for (uint8 i = 0; i < 10; i++) { isStraight = (rankExists >> i) & 0x1f == 0x1f; // 0b 11111 if (isStraight) { straightHigh = i + 5; break; } } // Royal Flush or Straight Flush if (isStraight && isFlush) { return straightHigh == 14 ? (HandRanking.RoyalFlush, 14) : (HandRanking.StraightFlush, straightHigh); } // 4 of a kind if (rankCounts / 4 & 0x11111111111110 > 0) { // 2 ~ High Ace for (uint8 i = 1; i < 14; i++) { uint64 bits = uint64(1 << i * 4); if (rankCounts < bits) break; if ((((rankCounts - bits) / 4) & 0x11111111111110) * 4 == rankCounts - bits) { kickers += i + 1; } if (rankCounts & 4 * bits == 4 * bits) { kickers += uint64(i + 1) * 100; } } return (HandRanking.FourOfAKind, kickers); } // Full House uint64 test3ofAKind = rankCounts >> 1 & rankCounts; if (test3ofAKind > 0) { uint64 removed3ofAKind = rankCounts - test3ofAKind * 3; uint64 testExtraPair = removed3ofAKind / 2 & 0x11111111111110; if (testExtraPair > 0) { for (uint8 i = 1; i < 14; i++) { if (test3ofAKind >> i * 4 == 1) { kickers += uint64(i + 1) * 100; } if (testExtraPair >> i * 4 == 1) { kickers += i + 1; } } return (HandRanking.FullHouse, kickers); } } if (isFlush) { return ( HandRanking.Flush, rankCounts ); } if (isStraight) { return ( HandRanking.Straight, straightHigh ); } // 3 of a kind if (test3ofAKind > 0) { uint64 removed3ofAKind = rankCounts - test3ofAKind * 3; for (uint8 i = 1; i < 14; i++) { if (test3ofAKind >> i * 4 == 1) { kickers += uint64(i + 1) * 10000; } if ((removed3ofAKind >> i * 4) & 1 == 1) { kickers += kickers % 100 == 0 ? uint64(i + 1) : uint64(i + 1) * 100; } } return ( HandRanking.ThreeOfAKind, kickers ); } // Find pairs & rest kickers uint8[2] memory pairs; for (uint8 i = 1; i < 14; i++) { uint64 bits = uint64(1 << i * 4); if (rankCounts < bits) break; if (rankCounts & 2 * bits == 2 * bits) { pairs[ pairs[0] == 0 ? 0 : 1 ] = i + 1; } if (rankCounts & bits == bits) { for (uint8 j = 0; j < 5; j++) { uint64 trimDigits = uint64(100 ** j); if (kickers / trimDigits % 100 == 0) { kickers += uint64(i + 1) * trimDigits; break; } } } } if (pairs[1] > 0) { // 2 pair return (HandRanking.TwoPair, uint64(pairs[1]) * 10000 + uint64(pairs[0]) * 100 + kickers); } else if (pairs[0] > 0) { // 1 pair return (HandRanking.Pair, uint64(pairs[0]) * 1000000 + kickers); } return (HandRanking.HighCard, kickers); } function _findBestHandRanking( uint32 tableId, uint8 pos ) internal view returns (HoldemHandRanking memory best) { PokerCard[7] memory cards; uint8 playerCounts = _seats(tableId); uint256 gameId = _gameId(tableId); // fill community cards for (uint8 i = 0; i < 5; i++) { cards[i] = _getPoker(gameId, i + 2 * playerCounts); } // fill hole cards cards[5] = _getPoker(gameId, pos * 2 - 2); cards[6] = _getPoker(gameId, pos * 2 - 1); // C(7, 5) = 21 -> Remove 2 cards from all 7 cards for (uint8 i = 0; i < 6; i++) { for (uint8 j = i + 1; j < 7; j++) { PokerCard[5] memory subset; for (uint8 k = 0; k < 7; k++) { if (k == i || k == j) continue; if (k < i) { subset[k] = cards[k]; } else if (k < j) { subset[k - 1] = cards[k]; } else { subset[k - 2] = cards[k]; } } (HandRanking ranking, uint64 kickers) = _computeHandRanking(subset); if (ranking > best.ranking) { best.ranking = ranking; best.kickers = kickers; } else if (ranking == best.ranking && kickers > best.kickers) { best.kickers = kickers; } } } } function _cacheHandRanking(uint32 tableId, uint8 pos, address player) internal { _setHoldemPlayerHandRanking(player, _findBestHandRanking(tableId, pos)); } function _cachePotWinners( uint32 tableId, uint8 pos, uint256 gameId, address player ) internal { _setHoldemGameWinners( gameId, _computePotWinners( tableId, gameId, pos, player ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqHoldemRevealerInterface } from "./AqHoldemInterfaces.sol"; import { AqHoldemIntermediate } from "./AqHoldemIntermediate.sol"; contract AqHoldemRevealer is AqHoldemIntermediate, AqHoldemRevealerInterface { // function reportRevealError( // uint256 gameId, // uint8 cardIndex, // address player, // bytes calldata rProof // ) external override { // _reportRevealError(gameId, cardIndex, player, rProof); // } function showCards( RevealTokenSubmission[] calldata rSubmits ) external override { ( address player, uint32 tableId, uint256 gameId, uint8 position ) = _nowPlaying(); _refreshGameState(tableId); GameStage stage = _gameStage(tableId); uint8 seats = _seats(tableId); bool holeCardShown = _hasPositionPlayerRevealedHoleCards(position, player); for (uint256 i = 0; i < rSubmits.length; i++) { if (stage < GameStage.Showdown) { if ( rSubmits[i].cardIndex == position * 2 - 2 || rSubmits[i].cardIndex == position * 2 - 1 ) continue; // skip hole cards before showdown } _submitRevealToken( gameId, player, rSubmits[i].cardIndex, rSubmits[i].revealToken, rSubmits[i].revealProof, seats ); } if (!holeCardShown && _hasPositionPlayerRevealedHoleCards(position, player)) { _flagShowdown(tableId, position); _cacheHandRanking(tableId, position, player); emit ShowdownResult( gameId, player, _getHoldemPlayerHandRanking(player).ranking, _getHoldemPlayerHandRanking(player).kickers ); _cachePotWinners(tableId, position, gameId, player); holeCardShown = true; } if (stage == GameStage.Showdown) { if (_actingPosition(tableId) == position && holeCardShown) _afterShowdownStateChanged(tableId, seats, position); } else if (_isZkRevealStage(stage)) { if (stage == GameStage.CutCards) _placeBlinds(tableId, player); if (_isAllRevealed(tableId, stage, seats)) _afterZkStateChanged(tableId, seats); } // else: betting stages or ends -> do nothing _refreshGameTimer(tableId, player); } function _placeBlinds(uint32 tableId, address player) internal { uint256 bets = _getHoldemBets(player); uint256 amount = 0; (address bbPlayer, uint256 bbAmount) = _getBigBlind(tableId); if (player == bbPlayer) { amount = bbAmount; } else { (address sbPlayer, uint256 sbAmount) = _getSmallBlind(tableId); amount = player == sbPlayer ? sbAmount : _anteAmount(tableId); } if (bets < amount) _placeBet(tableId, player, amount - bets); } function _submitRevealToken( uint256 gameId, address player, uint8 cardIndex, RevealToken memory rToken, bytes calldata rProof, uint8 playerCount ) internal { if (_hasRevealed(player, cardIndex)) revert AlreadyRevealed(gameId, cardIndex, player); uint8 counts = _flagRevealed(player, gameId, cardIndex); if (counts == playerCount) { // gas used around: 100k -> may throw InvalidCardID _revealCard(gameId, cardIndex, rToken); } else { // Optimized for gas usage -> Players send report if they found invalid reveal proof!! // if (!_isValidReveal(gameId, cardIndex, player, rToken, rProof)) // revert InvalidRevealProof(gameId, cardIndex); _addRevealToken(player, gameId, cardIndex, rToken, rProof); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { AqHoldemRewardInterface } from "./AqHoldemInterfaces.sol"; import { AqHoldemIntermediate } from "./AqHoldemIntermediate.sol"; contract AqHoldemReward is AqHoldemIntermediate, AqHoldemRewardInterface { /* ███████ ██ ██ ████████ ███████ ██████ ███ ██ █████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ █████ ███ ██ █████ ██████ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██ ██ ██ ███████ ██ ██ ██ ████ ██ ██ ███████ ███████ */ /** @dev For players normally end the game flows only */ function cashOut() external override { ( address player, uint32 tableId, /* uint256 gameId */, uint8 position ) = _nowPlaying(); if (tableId == 0 || position == 0 || _hasLeft(tableId, position)) // We should not allow cash out if player is not playing // (player could be in the middle of joining or leaving) revert NotPlaying(player); // TODO: check stage -> We allow every one to cash out any stage now for testing _afterPlayerLeave(tableId, position, player); _refreshGameTimer(tableId, player); // TODO: ignore those who doesn't complete ZKs _increaseCompletedGameTask(player); if (_hasAllLeft(tableId)) _endTableSeries(tableId); } function claimPots(uint32 tableId, uint8 pos) external override returns (uint256 amount) { if (pos == 0 || pos > _seats(tableId)) return 0; _refreshGameState(tableId); _requiredGameStage(tableId, GameStage.NormalEnd); if (_hasClaimed(tableId, pos) || _hasFolded(tableId, pos)) return 0; uint256 gameId = _gameId(tableId); address player = _getPositionPlayer(tableId, pos); if (_getHoldemPotWinners(gameId).length == 0) { // stage at NormalEnd, but no pot winners, means the game ends by overtime _setHoldemGameWinners( gameId, _computePotWinners( tableId, gameId, pos, player ) ); } /////// Start claim pots /////// HoldemGameState memory game = _gameState(tableId); if (game.foldedCount + 1 == _seats(tableId)) { // Case 1: the only player left, win all pots amount = _pots(tableId); } else { HoldemPotWinner[] memory _potWinners = _getHoldemPotWinners(gameId); for (uint8 i = 0; i < _potWinners.length; i++) { if (_enabled(_potWinners[i].positions, pos)) { amount += _potWinners[i].sharedReward; } } } if (amount > 0) { uint256 fee = _toWinnerFee(amount); amount -= fee; _transfer(address(this), player, amount); _clearKeptChip(fee); emit ClaimedPot(gameId, pos, player, amount, fee); _increaseWonGameTask(player); } _flagClaimed(tableId, pos); return amount; } function ponish(uint32 tableId) external override { _refreshGameState(tableId); _requiredGameStage(tableId, GameStage.UnusualEnd); // TODO make _refreshGameState flag unreveal players // TODO split those players balances, and return them to players } /* ██ ███ ██ ████████ ███████ ██████ ███ ██ █████ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ ██████ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ███████ ██ ██ ██ ████ ██ ██ ███████ ███████ */ function _afterPlayerLeave(uint32 tableId, uint8 pos, address player) internal { if (balanceOf(player) > 0) _exchangeFromExactChips(player, balanceOf(player)); _clearPlayerStatus(player); _flagPlayerLeft(tableId, pos); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqHoldemShufflerInterface } from "./AqHoldemInterfaces.sol"; import { AqHoldemIntermediate } from "./AqHoldemIntermediate.sol"; contract AqHoldemShuffler is AqHoldemIntermediate, AqHoldemShufflerInterface { function shuffle( uint256 gameId, uint256[4][52] calldata maskedCards, uint256[4][52] calldata shuffledCards, bytes calldata proof, uint256[] calldata pkc ) external override { if (!_isGameOngoing(gameId)) revert GameNotOngoing(gameId); if (_hasShuffled(gameId)) revert AlreadyShuffled(gameId); uint32 tableId = _getTableIdByGameId(gameId); _requiredGameStage(tableId, GameStage.Shuffle); uint64 seriesId = _getSeriesIdByGameId(gameId); _checkDuplicateDeck(tableId, seriesId, proof); // For N > 1 times shuffle, maskedCards should be latest deck if (_hasShuffled(gameId) && !_compareDeck(gameId, shuffledCards)) revert InvalidMaskedDeck(gameId); if (!_isValidShuffle(maskedCards, shuffledCards, proof, pkc)) revert InvalidShuffleProof(gameId); address dealer = _msgOwner(); _setDeck(gameId, shuffledCards, _gameDeckSize(gameId)); _increasePlayerShuffleCounts(dealer); emit DeckShuffled(gameId, dealer); _afterShuffleStage(tableId); } function _isDuplicateDeck( uint64 _seriesId, bytes memory _deckProof ) internal view returns (bool) { uint64 last = _lastDeckSeriesId(keccak256(_deckProof)); return last != 0 && last == _seriesId; } function _checkDuplicateDeck( uint32 tableId, uint64 seriesId, bytes memory proof ) internal { if (_isDuplicateDeck(seriesId, proof)) revert DuplicateDeck(tableId, seriesId); _setLastDeckSeriesId(keccak256(proof), seriesId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { BitMath } from "../libraries/BitMath.sol"; import { AqHoldemIntermediate } from "./AqHoldemIntermediate.sol"; import { AqHoldemViewInterface } from "./AqHoldemInterfaces.sol"; contract AqHoldemViews is AqHoldemIntermediate, AqHoldemViewInterface { function table(uint32 tableId) external view override returns (HoldemTableStatus memory t) { t.id = tableId; if (_isTablePlaying(tableId)) { uint8 seats = _seats(tableId); uint256[] memory allBets = new uint256[](seats); HoldemGameState memory game = _currentGameState(tableId); t.gameId = _gameId(tableId); t.gameKey = _getGameKey(tableId); t.stage = game.stage; t.positions = new HoldemPosition[](seats); for (uint8 i = 0; i < seats; i++) { t.positions[i].pid = i + 1; t.positions[i].status = _parseHoldemGamePositionStatus(game, i + 1, seats); t.positions[i].wallet = _getPositionPlayer(tableId, i + 1); t.positions[i].holeCards = _holeCards( t.gameId, t.stage, i + 1 ); t.positions[i].bets = _getHoldemBets(t.positions[i].wallet); t.positions[i].chips = balanceOf(t.positions[i].wallet); t.positions[i].toReveals = _toRevealCards( t.positions[i].wallet, seats, t.stage, i + 1 ); t.positions[i].unrevealedCommunityCards = _unrevealedCommunityCards( t.positions[i].wallet, seats ); allBets[i] = t.positions[i].bets; } t.communityCards = _communityCards( t.gameId, t.stage, seats ); (ComputedHoldemPot memory mainPot, ComputedHoldemPot[] memory sidePots) = _computePots(game, tableId, allBets); t.mainPot.amount = mainPot.amount; t.mainPot.positions = mainPot.positions; t.sidePots = new HoldemPot[](sidePots.length); for (uint8 i = 0; i < sidePots.length; i++) { t.sidePots[i].amount = sidePots[i].amount; t.sidePots[i].positions = sidePots[i].positions; } // Only normal end stage got winners if (t.stage == GameStage.NormalEnd) { HoldemPotWinner[] memory winners = _getHoldemPotWinners(t.gameId); if (winners.length == 0) { // Timeout case -> no cached winners uint8 remainPosition = 0; uint8 playerCounts = _seats(tableId); for (uint8 posId = 1; posId <= playerCounts; posId++) { if (game.folded & uint16(1 << posId - 1) == 0) { remainPosition = posId; break; } } winners = _computePotWinners(tableId, t.gameId, remainPosition, _getPositionPlayer(tableId, remainPosition)); } if (winners.length > 0) { t.mainPot.winnerHandRanking = winners[0].ranking; t.mainPot.winners = _parsePositions(winners[0].positions); for (uint i = 0; i < sidePots.length; i++) { t.sidePots[i].winnerHandRanking = winners[i + 1].ranking; t.sidePots[i].winners = _parsePositions(winners[i + 1].positions); } } } t.minRaise = game.lastRaise; t.betAmount = game.minBet; t.lastStageBet = game.lastStageBalancedBet; t.actingPosition = game.position; t.actingTimeStart = _computeLastActionStarts(game); t.actingTimeout = game.timeout; t.deck = _getDeck(t.gameId); } t.timestamp = uint64(block.timestamp); } function holdemTimers() external view override returns ( uint32 shuffleTimeout, uint32 revealTimeout, uint32 betTimeout, uint32 showdownTimeout, uint32 endTimeout ) { HoldemSettings memory settings = _getHoldemSettings(); shuffleTimeout = settings.shuffleTimeout; revealTimeout = settings.revealTimeout; betTimeout = settings.betTimeout; showdownTimeout = settings.showdownTimeout; endTimeout = settings.endTimeout; } function _parsePositions(uint16 pos) internal pure returns (uint8[] memory positions) { uint8 count = BitMath.popcount32(pos); positions = new uint8[](count); for (uint8 i = 0; i < count; i++) { uint8 p = BitMath.leastSignificantBit16(pos); pos &= uint16(~(1 << p)); positions[i] = p + 1; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; library AddressArrays { function positionOf(address[] memory list, address addr) internal pure returns (uint256) { for (uint256 i = 0; i < list.length; i++) { if (list[i] == addr) return i + 1; } return 0; } function has(address[] memory list, address addr) internal pure returns (bool) { return positionOf(list, addr) > 0; } function shuffle(address[] memory list, uint256 seed) internal pure returns (address[] memory) { for (uint8 i = 0; i < list.length; i++) { uint8 pos = uint8( uint256(keccak256( abi.encodePacked(list[i], seed) )) % (list.length - i) ) + i; address player = list[pos]; list[pos] = list[i]; list[i] = player; } return list; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * References: * + https://solidity-by-example.org/bitwise/ * + https://github.com/estarriolvetch/solidity-bits/blob/main/contracts/Popcount.sol */ library BitMath { uint32 private constant m1x32 = 0x55555555; uint32 private constant m2x32 = 0x33333333; uint32 private constant m4x32 = 0xF0F0F0F; uint32 private constant h01x32 = 0x1010101; function popcount32(uint32 x) internal pure returns (uint8) { unchecked { x -= ((x >> 1) & m1x32); x = (x & m2x32) + (x >> 2 & m2x32); return uint8(((x + (x >> 4)) & m4x32) * h01x32 >> 24); } } uint64 private constant m1x64 = 0x5555555555555555; uint64 private constant m2x64 = 0x3333333333333333; uint64 private constant m4x64 = 0xF0F0F0F0F0F0F0F; uint64 private constant h01x64 = 0x101010101010101; function popcount64(uint64 x) internal pure returns (uint8) { unchecked { x -= ((x >> 1) & m1x64); x = (x & m2x64) + (x >> 2 & m2x64); return uint8(((x + (x >> 4)) & m4x64) * h01x64 >> 56); } } uint256 private constant m1 = 0x5555555555555555555555555555555555555555555555555555555555555555; uint256 private constant m2 = 0x3333333333333333333333333333333333333333333333333333333333333333; uint256 private constant m4 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F; uint256 private constant h01 = 0x0101010101010101010101010101010101010101010101010101010101010101; function popcount256(uint256 x) internal pure returns (uint16) { if (x == type(uint256).max) return 256; unchecked { x -= (x >> 1) & m1; // put count of each 2 bits into those 2 bits x = (x & m2) + ((x >> 2) & m2); // put count of each 4 bits into those 4 bits x = (x + (x >> 4)) & m4; // put count of each 8 bits into those 8 bits x = (x * h01) >> 248; // returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ... } return uint16(x); } function leastSignificantBit16(uint16 x) internal pure returns (uint8 r) { require(x > 0); r = 15; if (x & type(uint8).max > 0) r -= 8; else x >>= 8; if (x & 0xF > 0) r -= 4; else x >>= 4; if (x & 0x3 > 0) r -= 2; else x >>= 2; if (x & 0x1 > 0) r -= 1; } function leastSignificantBit32(uint32 x) internal pure returns (uint8 r) { require(x > 0); r = 31; if (x & type(uint16).max > 0) r -= 16; else x >>= 16; if (x & type(uint8).max > 0) r -= 8; else x >>= 8; if (x & 0xF > 0) r -= 4; else x >>= 4; if (x & 0x3 > 0) r -= 2; else x >>= 2; if (x & 0x1 > 0) r -= 1; } function leastSignificantBit64(uint64 x) internal pure returns (uint8 r) { require(x > 0); r = 63; if (x & type(uint32).max > 0) { r -= 32; } else { x >>= 32; } if (x & type(uint16).max > 0) { r -= 16; } else { x >>= 16; } if (x & type(uint8).max > 0) { r -= 8; } else { x >>= 8; } if (x & 0xF > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } function leastSignificantBit256(uint256 x) internal pure returns (uint8 r) { require(x > 0); r = 255; if (x & type(uint128).max > 0) { r -= 128; } else { x >>= 128; } if (x & type(uint64).max > 0) { r -= 64; } else { x >>= 64; } if (x & type(uint32).max > 0) { r -= 32; } else { x >>= 32; } if (x & type(uint16).max > 0) { r -= 16; } else { x >>= 16; } if (x & type(uint8).max > 0) { r -= 8; } else { x >>= 8; } if (x & 0xF > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqLobbyWallets } from "./AqLobbyWallets.sol"; import { AqLobbyLineups } from "./AqLobbyLineups.sol"; contract AqLobby is AqLobbyWallets, AqLobbyLineups { /* ░▀▀█░█░█░█▀█░█░█░█▀▀░█▀▄ ░▄▀░░░█░░█▀▀░█▀█░█▀▀░█▀▄ ░▀▀▀░░▀░░▀░░░▀░▀░▀▀▀░▀░▀ ░░░░█▀▀░█▀█░█▄█░█▀▀░█▀▀ ░░░░█░█░█▀█░█░█░█▀▀░▀▀█ ░░░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀ */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { DENO } from "../AqConstants.sol"; import { AqTableCore } from "../table/AqTableCore.sol"; import { AqLobbyCoreInterface } from "./AqLobbyInterfaces.sol"; contract AqLobbyCore is AqLobbyCoreInterface { // @custom:storage-location erc7201:ace-quest.lobby struct LobbyStorage { LobbySettings _settings; mapping(uint32 => uint8) _readyCounters; } // keccak256(abi.encode(uint256(keccak256("ace-quest.lobby")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant LobbyStorageLocation = 0xcc16e18411ff8b1e47dfab40e80e7026c695a84dbd7de7869cff0b5c64edb200; function _getLobbyStorage() private pure returns (LobbyStorage storage $) { assembly { $.slot := LobbyStorageLocation } } function __AqLobby_init_unchained() internal { _setReadyTime(60 seconds); _setMaxSignatureTime(10 minutes); _setNonReadyPenalty(uint32(DENO / 20)); // 5% } /* ██████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _maxSignatureTimeout() internal view returns (uint32) { return _getLobbyStorage()._settings.SIGNATURE_TIMEOUT; } function _readyTimeout() internal view returns (uint32) { return _getLobbyStorage()._settings.READY_TIMEOUT; } function _readyCounts(uint32 tableId) internal view returns (uint8) { return _getLobbyStorage()._readyCounters[tableId]; } function _toNonReadyPenalty(uint256 amount) internal view returns (uint256) { return amount * _getLobbyStorage()._settings.PENALTY_NO_READY / DENO; } /* ███████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _resetReadyCounter(uint32 tableId) internal { LobbyStorage storage $ = _getLobbyStorage(); delete $._readyCounters[tableId]; } function _increaseReadyCounter(uint32 tableId) internal returns (uint8) { LobbyStorage storage $ = _getLobbyStorage(); return ++$._readyCounters[tableId]; } function _setReadyTime(uint32 readyTimeout) internal { LobbyStorage storage $ = _getLobbyStorage(); if ($._settings.READY_TIMEOUT == readyTimeout) revert InvalidSettingValue(readyTimeout); $._settings.READY_TIMEOUT = readyTimeout; } function _setNonReadyPenalty(uint32 rate_) internal { LobbyStorage storage $ = _getLobbyStorage(); if ($._settings.PENALTY_NO_READY == rate_ || rate_ > DENO) revert InvalidSettingValue(rate_); $._settings.PENALTY_NO_READY = rate_; } function _setMaxSignatureTime(uint32 signTimeout) internal { LobbyStorage storage $ = _getLobbyStorage(); if ($._settings.SIGNATURE_TIMEOUT == signTimeout) revert InvalidSettingValue(signTimeout); $._settings.SIGNATURE_TIMEOUT = signTimeout; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILobbyErrors } from "../AqErrors.sol"; interface AqLobbyCoreInterface is ILobbyErrors { struct LobbySettings { uint32 READY_TIMEOUT; uint32 SIGNATURE_TIMEOUT; uint32 PENALTY_NO_READY; uint160 __gap__; } event PlayerJoined( uint32 indexed tableId, address indexed player ); event PlayerLeft( uint32 indexed tableId, address indexed player, address indexed sender ); event StartTableFailure( uint32 indexed tableId, address indexed tableAddress, address indexed starter, address[] players ); } interface AqLobbyWalletInterface is AqLobbyCoreInterface { /** * @notice Authorize deputy-account to operate as main-account * * @dev flow: * 1. deputy account sign a message with timestamp to permit main account to bind it * * ```typescript * const now = Date.now() / 1000 | 0 * const message = `As ${mainWallet.address.toLowerCase()} -- ${now}` * const sign = await deputyWallet.signMessage(message) * ``` * * 2. Main account send this transaction with deputy's signature to bind * deputy operation with this account */ function authorize( address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external payable; /** * @dev Accept from: owner, deputy account, or main account */ function cancelAuthorization( address deputyAccount ) external; } interface AqLobbyLineupInterface is AqLobbyCoreInterface { function join( uint32 tableId, PublicKey memory playerPublicKey ) external payable returns (uint8 waitingPlayerCounts); function leave() external returns (uint256 refundAmount); function ready() external returns (bool tableStarted); function refund() external returns (uint256 refundAmount); } interface AqLobbyViewInterface is AqLobbyCoreInterface { enum PendingLobbyActionType { None, __UNUSED_01_, __UNUSED_02_, Ready } enum TableStatus { Idle, Playing, Closed } struct TableWaiting { address player; PublicKey publicKey; } struct PendingLobbyAction { PendingLobbyActionType act; // 0: None, 1: Shuffle, 2: Reveal, 3: Ready address[] users; uint64 timeout; } struct Table { uint32 id; address table; uint8 seats; uint8 activePlayers; TableStatus status; TableWaiting[] waitings; PendingLobbyAction pendingAction; uint256 initialBuyin; uint256 bbAmount; uint256 sbAmount; uint256 anteAmount; } function tables() external view returns (Table[] memory); function isPlayerPlaying(address player) external view returns ( bool playing, uint32 lastTableId, address mainWallet ); function tablePlaying(uint32 tableId) external view returns (bool); function wallet(address deputyAccount) external view returns (address); function lobbyTimers() external view returns ( uint32 readyTimeout, uint32 signatureTimeout, uint32 tableNoResponseTimeout ); } interface AqLobbyClientInterface is AqLobbyWalletInterface, AqLobbyLineupInterface, AqLobbyViewInterface {}
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { AqCore } from "../AqCore.sol"; abstract contract AqLobbyIntermediate is AqCore { /** * @notice Return the waiting player addresses, * will filter out those non-readyed players if this line is overtimed. */ function _waitings(uint32 tableId) internal view returns (address[] memory) { // Table not pending (playing or timeout-closed) -> must be empty if (!_isTablePending(tableId)) return new address[](0); // Table no response -> must empty cause next player join will reset it if (_isTableNoResponse(tableId)) return new address[](0); uint64 lastFull = _tableLastFullAt(tableId); // The line-up has been full after the latest game // & current time is overtime bool hasOvertimed = lastFull > _tableLastStartAt(tableId) && lastFull + _readyTimeout() < block.timestamp; address[] memory lastWaitings = _getTablePlayers(tableId); // The only case table players != waiting players is overtime-ed // And no next player joined (will reset if next player joined) if (hasOvertimed) { uint8 counts = _readyCounts(tableId); uint8 found = 0; address[] memory list = new address[](counts); for (uint256 i = 0; i < lastWaitings.length && found < counts; i++) { address player = lastWaitings[i]; if (_lastReadyAt(player) >= lastFull) { list[found++] = player; } } return list; } return lastWaitings; } function _isPlayerOvertime(address player) internal view returns ( uint32 tableId, bool isOvertime ) { tableId = _playerLastTable(player); // Player not in a table if (tableId == 0) return (0, false); // Player in a game (not in a line-up) if (_getPlayerStatus(player) != PlayerStatus.LobbyWaiting) return (0, false); uint64 lastFull = _tableLastFullAt(tableId); uint64 lastStart = _tableLastStartAt(tableId); // Table waitings not full after the latest game -> not overtime if (lastStart > lastFull) return (tableId, false); uint64 overtimeAt = lastFull + _readyTimeout(); isOvertime = overtimeAt < block.timestamp && _lastReadyAt(player) < lastFull; } function _playerLobbyStatus(address player) internal view returns ( address mainWallet, uint32 lastTableId, bool playing ) { mainWallet = _mainAccount(player); lastTableId = _playerLastTable(mainWallet); playing = _isTablePlaying(lastTableId) && _tableHasPlayer(lastTableId, mainWallet); } function _authorize( address mainWallet, address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) internal { if ( signedAt > block.timestamp || signedAt + _maxSignatureTimeout() < block.timestamp ) revert InvalidAuthorizationTimeout(signedAt); if (!SignatureChecker.isValidSignatureNow( deputyAccount, MessageHashUtils.toEthSignedMessageHash( bytes.concat( "As ", bytes(Strings.toHexString(mainWallet)), " -- ", bytes(Strings.toString(signedAt)) ) ), deputySignature )) revert InvalidAuthorizationSignature(); if (balanceOf(deputyAccount) > 0 || _playerLastTable(deputyAccount) > 0) { if (!unsafeIgnoreCurrentAuthorization) revert WalletInUse(deputyAccount); } _bindAccount(mainWallet, deputyAccount, authorizeTimeout); if (msg.value > 0) Address.sendValue(deputyAccount, msg.value); } function _joinLineup( uint32 tableId, address player, PublicKey memory playerPublicKey ) internal returns (uint8 playerCounts) { (bool isEnd, uint64 endTimeout, bool canReset) = _isTableUnusualEnd(tableId); if (isEnd) { if (canReset) _stopUnusualEndTable(tableId, endTimeout); else revert InvalidTableStatus(tableId); } // Stop no response table & log it to player's record if (_isTableNoResponse(tableId)) { _stopNoResponseTable(tableId); _increasePlayerStopNoResponseTables(player); } if (!_isTablePending(tableId)) revert TableNotPending(tableId); // Clean player self status if (_getPlayerStatus(player) == PlayerStatus.LobbyWaiting) { // Player in a line-up (maybe not in the same table) (uint32 lastTableId, bool isOvertime) = _isPlayerOvertime(player); if (isOvertime) { if (lastTableId == tableId) { uint8 clearedCounts = _clearNonReadyPlayers(tableId, player); _resetReadyCounter(tableId); if (clearedCounts > 1) _increasePlayerRemoveNotReadyPlayers(player, clearedCounts - 1); } else { // Remove player from other table _removeTableWaiting(lastTableId, player, player); } } else { revert PlayerAlreadyInTable(player, lastTableId); } } else { // Player in a game if (_playerLastTable(player) != 0) revert PlayerAlreadyInTable(player, _playerLastTable(player)); } // Clean table line-up status if (_isTableFull(tableId)) { uint8 clearedCounts = _clearNonReadyPlayers(tableId, player); if (clearedCounts > 0) { _resetReadyCounter(tableId); _increasePlayerRemoveNotReadyPlayers(player, clearedCounts); } else { revert LineupFull(tableId, _tableLastFullAt(tableId)); } } if (balanceOf(player) > 0) _clearPlayerChips(player, balanceOf(player)); _exchangeToExactChips(player, _initBI(tableId)); _setPublicKey(player, playerPublicKey); _resetHoldemPlayer(player); bool isFull; (playerCounts, isFull) = _addTableWaiting(tableId, player); _afterPlayerJoinTable(tableId, player, playerCounts, isFull); return playerCounts; } function _addTableWaiting( uint32 tableId, address player ) internal returns (uint8 playerCounts, bool isFull) { (playerCounts, isFull) = _addTablePlayer(tableId, player); _setPlayerWaiting(player, tableId); emit PlayerJoined( tableId, player ); } function _clearNonReadyPlayers( uint32 tableId, address cleaner ) internal returns (uint8 clearedCounts) { address[] memory list = _getTablePlayers(tableId); uint64 fullAt = _tableLastFullAt(tableId); uint64 overtimeAt = fullAt + _readyTimeout(); if (overtimeAt > block.timestamp) return 0; uint256 fee = _toNonReadyPenalty(_initBI(tableId)); for (uint256 i = 0; i < list.length; i++) { uint64 readyAt = _lastReadyAt(list[i]); if (readyAt < fullAt) { _removeTableWaiting(tableId, list[i], cleaner); _clearPlayerChips(list[i], fee); clearedCounts++; } } if (clearedCounts > 0) _resetTableFullTimer(tableId); return clearedCounts; } function _removeTableWaiting(uint32 tableId, address player, address sender) internal { _removeTablePlayerPreservingOrder(tableId, player); _clearPlayerStatus(player); emit PlayerLeft( tableId, player, sender ); } function _startGameTable(uint32 tableId, address starter) internal { address[] memory players = _getTablePlayers(tableId); _increasePlayerStartNewTables(starter); _newSeries(tableId, players); } function _newSeries( uint32 tableId, address[] memory players ) internal returns (uint64 seriesId) { seriesId = _startTableSeries(tableId); PublicKey[] memory playerKeys = new PublicKey[](players.length); for (uint256 i = 0; i < players.length; i++) { playerKeys[i] = _getPublicKey(players[i]); _setPlayerPlaying(players[i]); } _setGameKey(tableId, playerKeys); _startTableGame(tableId); _restartGameStage(tableId); } function _afterPlayerJoinTable( uint32 tableId, address player, uint8 playerCounts, bool isFull ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AddressArrays } from "../libraries/AddressArrays.sol"; import { AqLobbyLineupInterface } from "./AqLobbyInterfaces.sol"; import { AqLobbyIntermediate } from "./AqLobbyIntermediate.sol"; abstract contract AqLobbyLineups is AqLobbyIntermediate, AqLobbyLineupInterface { /** * @inheritdoc AqLobbyLineupInterface */ function join( uint32 tableId, PublicKey memory playerPublicKey ) external override payable returns (uint8) { address player = _msgOwner(); return _joinLineup(tableId, player, playerPublicKey); } /** * @notice Refund cash to player * @dev 1. Non-ready line-up overtime -> refund with non-ready penalty * 2. If table not end -> cannot refund * 3. If table has ended -> all to fee */ function refund() external override returns (uint256 refundAmount) { address player = _msgOwner(); (, uint32 tableId, bool playing) = _playerLobbyStatus(player); if (playing) revert WalletInUse(player); // Player in a line-up -> only available if overtime if (_getPlayerStatus(player) == PlayerStatus.LobbyWaiting) { (uint32 lastTableId, bool isOvertime) = _isPlayerOvertime(player); if (isOvertime) { uint8 clearedCounts = _clearNonReadyPlayers(tableId, player); _resetReadyCounter(tableId); if (clearedCounts > 1) _increasePlayerRemoveNotReadyPlayers(player, clearedCounts - 1); return _toCashAmount( _initBI(tableId) - _toNonReadyPenalty(_initBI(tableId)) ); } else { // Use "leave" instead of "refund" revert WalletInLineup(player, lastTableId); } } _clearPlayerChips(player, balanceOf(player)); _clearPlayerStatus(player); return 0; } function leave() external override returns (uint256 refundAmount) { address player = _msgOwner(); uint32 tableId = _playerLastTable(player); // Only pending table, playing table can't leave if (!_isTablePending(tableId)) revert InvalidTableStatus(tableId); if (_getPlayerStatus(player) != PlayerStatus.LobbyWaiting) revert PlayerNotWaiting(player, tableId); (, bool isOvertime) = _isPlayerOvertime(player); // In this case, use "refund" instead of "leave" if (isOvertime) revert PlayerHasLeftDueToOvertime(player, tableId); // Auto clear non-ready players if overtime if (_isTableFull(tableId)) { uint8 clearedCounts = _clearNonReadyPlayers(tableId, player); if (clearedCounts > 0) { _resetReadyCounter(tableId); _increasePlayerRemoveNotReadyPlayers(player, clearedCounts); } else { // Ready count-down is running, can't leave revert LineupFull(tableId, _tableLastFullAt(tableId)); } } _setPlayerLeave(player); _removeTableWaiting(tableId, player, player); return _clearPlayerChips(player, 0); } /** * @inheritdoc AqLobbyLineupInterface */ function ready() external override returns (bool tableStarted) { address player = _msgOwner(); uint32 tableId = _playerLastTable(player); // The waiting list will check table status, // so we don't need to check table status here. address[] memory waitings = _orderListByTableSeed( tableId, _waitings(tableId) ); uint8 position = uint8(AddressArrays.positionOf(waitings, player)); if (position == 0) revert PlayerNotWaiting(player, tableId); // Lineup not full -> can't ready if (!_isTableFull(tableId)) revert LineupNotFull(tableId, _playerCounts(tableId)); uint64 lastFull = _tableLastFullAt(tableId); uint64 lastReady = _lastReadyAt(player); if (lastReady >= lastFull) revert PlayerHasReady(player, tableId, lastReady); uint64 joinAt = _lastJoinAt(player); // Player has called ready before (last line-up not fired) if (lastReady >= joinAt) _increasePlayerExtraReadyCounts(player); _setPlayerReady(player, position); _setTableInitPosition(tableId, position, player); uint8 counts = _increaseReadyCounter(tableId); if (counts == _playerCounts(tableId)) { _resetReadyCounter(tableId); _startGameTable(tableId, player); return true; } return false; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { AqLobbyViewInterface } from "./AqLobbyInterfaces.sol"; import { AqLobbyIntermediate } from "./AqLobbyIntermediate.sol"; abstract contract AqLobbyViews is AqLobbyIntermediate, AqLobbyViewInterface { function wallet(address deputyAccount) external view override returns (address) { return _mainAccount(deputyAccount); } function tables() external view override returns (Table[] memory) { uint32[] memory ids = _tableIds(); Table[] memory list = new Table[](ids.length); for (uint8 i = 0; i < ids.length; i++) { list[i] = _getTable(ids[i]); } return list; } function lobbyTimers() external view override returns ( uint32 readyTimeout, uint32 signatureTimeout, uint32 tableNoResponseTimeout ) { readyTimeout = _readyTimeout(); signatureTimeout = _maxSignatureTimeout(); tableNoResponseTimeout = _noResponseTimeout(); } function isPlayerPlaying(address player) external view override returns ( bool playing, uint32 lastTableId, address mainWallet ) { (mainWallet, lastTableId, playing) = _playerLobbyStatus(player); } function tablePlaying(uint32 tableId) external view override returns (bool) { return _isTablePlaying(tableId); } function _getTable(uint32 tableId) internal view returns (Table memory table) { table.id = tableId; table.table = address(this); table.seats = _seats(tableId); table.initialBuyin = _initBI(tableId); table.bbAmount = _bbAmount(tableId); table.sbAmount = _sbAmount(tableId); table.anteAmount = _anteAmount(tableId); (bool isUnusualEnd, , bool canReset) = _isTableUnusualEnd(tableId); if (isUnusualEnd) { table.status = canReset ? TableStatus.Idle : TableStatus.Closed; return table; } bool isPending = _isTablePending(tableId); if (isPending) { table.status = TableStatus.Idle; address[] memory waitings = _waitings(tableId); table.waitings = new TableWaiting[](waitings.length); for (uint256 i = 0; i < waitings.length; i++) { address player = waitings[i]; table.waitings[i] = TableWaiting({ player: player, publicKey: _getPublicKey(player) }); } if (waitings.length == table.seats) { table.pendingAction.act = PendingLobbyActionType.Ready; table.pendingAction.users = _nonReadyUsers(tableId, waitings); table.pendingAction.timeout = _tableLastFullAt(tableId) + _readyTimeout(); } return table; } else if (_isTablePlaying(tableId)) { table.status = TableStatus.Playing; table.activePlayers = _seats(tableId) - _leftPlayerCounts(tableId); } else { // Normal End -> Waiting all players cashout table.status = TableStatus.Closed; table.activePlayers = _seats(tableId) - _leftPlayerCounts(tableId); } } function _nonReadyUsers( uint32 tableId, address[] memory users ) private view returns (address[] memory) { uint64 lastFull = _tableLastFullAt(tableId); address[] memory list = new address[](_seats(tableId) - _readyCounts(tableId)); uint8 found = 0; for (uint256 i = 0; i < users.length && found < list.length; i++) { address player = users[i]; if (_lastReadyAt(player) < lastFull) { list[found++] = player; } } return list; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { AqLobbyWalletInterface } from "./AqLobbyInterfaces.sol"; import { AqLobbyIntermediate } from "./AqLobbyIntermediate.sol"; abstract contract AqLobbyWallets is AqLobbyIntermediate, AqLobbyWalletInterface { /** * @inheritdoc AqLobbyWalletInterface */ function authorize( address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external override payable { address mainWallet = msg.sender; _authorize( mainWallet, deputyAccount, authorizeTimeout, deputySignature, signedAt, unsafeIgnoreCurrentAuthorization ); } /** * @inheritdoc AqLobbyWalletInterface */ function cancelAuthorization(address deputyAccount) external override { address mainAccount = _mainAccount(deputyAccount); if ( msg.sender != mainAccount && msg.sender != deputyAccount && !isAdmin(msg.sender) ) revert PermissionDenied(); _unbindAccount(deputyAccount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqPlayerCoreInterface } from "./AqPlayerInterface.sol"; contract AqPlayerCore is AqPlayerCoreInterface { uint256 private constant RESET_PLAYER_INIT_POSITION = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFF; // @custom:storage-location erc7201:ace-quest.player struct PlayerStorage { /** @dev | [216] .... | [8] init position | [32] tableId | */ mapping(address => uint256) _lastTable; mapping(address => PlayerTimers) _timers; mapping(address => PlayerRecords) _records; mapping(address => PlayerRecords) _claimed; mapping(address => PlayerStatus) _status; } // keccak256(abi.encode(uint256(keccak256("ace-quest.player")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PlayerStorageLocation = 0xa8a465048050562721c1bb2ef0148c8df103444264c482b1f33c3475f8b4c400; function _getPlayerStorage() private pure returns (PlayerStorage storage $) { assembly { $.slot := PlayerStorageLocation } } function __AqPlayer_init_unchained() internal { // } /* ██████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _playerLastTable(address player) internal view returns (uint32) { return uint32(_getPlayerStorage()._lastTable[player]); } function _playerInitPos(address player) internal view returns (uint8) { return uint8(_getPlayerStorage()._lastTable[player] >> 32); } function _getPlayerStatus(address player) internal view returns (PlayerStatus) { return _getPlayerStorage()._status[player]; } function _lastJoinAt(address player) internal view returns (uint64) { return _getPlayerStorage()._timers[player].joinAt; } function _lastReadyAt(address player) internal view returns (uint64) { return _getPlayerStorage()._timers[player].readyAt; } function _lastLeaveAt(address player) internal view returns (uint64) { return _getPlayerStorage()._timers[player].leaveAt; } /* ███████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _clearPlayerStatus(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); delete $._lastTable[player]; delete $._status[player]; } function _setPlayerWaiting(address player, uint32 tableId) internal { PlayerStorage storage $ = _getPlayerStorage(); $._lastTable[player] = uint256(tableId); $._status[player] = PlayerStatus.LobbyWaiting; $._timers[player].lastActionAt = uint64(block.timestamp); $._timers[player].joinAt = uint64(block.timestamp); } function _setPlayerReady(address player, uint8 initPos) internal { PlayerStorage storage $ = _getPlayerStorage(); $._lastTable[player] &= RESET_PLAYER_INIT_POSITION; $._lastTable[player] |= uint256(initPos) << 32; $._timers[player].lastActionAt = uint64(block.timestamp); $._timers[player].readyAt = uint64(block.timestamp); } /** @dev Invoke this function for players who manually leave line-up by themself */ function _setPlayerLeave(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); delete $._lastTable[player]; delete $._status[player]; $._timers[player].lastActionAt = uint64(block.timestamp); $._timers[player].leaveAt = uint64(block.timestamp); } function _setPlayerPlaying(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._status[player] = PlayerStatus.TablePlaying; } function _increasePlayerStartNewTables(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._records[player].startNewTables++; } function _increasePlayerStopNoResponseTables(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._records[player].stopNoResponseTables++; } function _increasePlayerRemoveNotReadyPlayers( address player, uint8 counts ) internal { PlayerStorage storage $ = _getPlayerStorage(); $._records[player].removeNotReadyPlayers += counts; } function _increasePlayerExtraReadyCounts(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._records[player].extraReadyCounts++; } function _increasePlayerShuffleCounts(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._records[player].shuffleCounts++; } function _refreshPlayerTimer(address player) internal { PlayerStorage storage $ = _getPlayerStorage(); $._timers[player].lastActionAt = uint64(block.timestamp); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IPlayerErrors } from "../AqErrors.sol"; interface AqPlayerCoreInterface is IPlayerErrors { struct PlayerTimers { uint64 lastActionAt; uint64 joinAt; uint64 readyAt; uint64 leaveAt; } struct PlayerRecords { // Extra gas spend, log for future returns uint32 startNewTables; uint32 stopNoResponseTables; uint32 removeNotReadyPlayers; uint32 extraReadyCounts; // ready but room not start uint32 shuffleCounts; uint96 __padding; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqLobbyIntermediate } from "../lobby/AqLobbyIntermediate.sol"; import { AqTaskIntermediate } from "../task/AqTaskIntermediate.sol"; import { AqReferralActionInterface } from "./AqReferralInterfaces.sol"; import { AqReferralIntermediate } from "./AqReferralIntermediate.sol"; contract AqReferralActions is AqReferralIntermediate, AqLobbyIntermediate, AqTaskIntermediate, AqReferralActionInterface { function setReferrer(address referrer) external override { address account = _msgOwner(); _bindReferrer(account, referrer); } function claimReferralCashback(address user) external override nonReentrant returns ( uint256 cashAmount, uint256 pointAmount ) { _settleReferralBonus(user); uint256 chipAmount = _getReferralPendingCashBonus(user); if (chipAmount > 0) { _clearPendingCashBonus(user); cashAmount = _toCashAmount(chipAmount); // Burn our fee vault chip and transfer cash to the referrer _burn(address(this), chipAmount); _transferCashOut(user, cashAmount); emit CashReferralBonusClaimed(user, cashAmount); } pointAmount = _getReferralPendingPointBonus(user); if (pointAmount > 0) { _clearPendingPointBonus(user); _transferPoints(user, pointAmount); emit PointReferralBonusClaimed(user, pointAmount); } } function refAndAuthorize( address referrer, address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external override payable { address mainWallet = msg.sender; if (referrer == deputyAccount || referrer == mainWallet) revert InvalidReferrer(referrer); _bindReferrer(deputyAccount, referrer); _authorize( mainWallet, deputyAccount, authorizeTimeout, deputySignature, signedAt, unsafeIgnoreCurrentAuthorization ); } function refAndJoin( address referrer, uint32 tableId, PublicKey memory playerPublicKey ) external override payable returns (uint8 waitingPlayerCounts) { address account = _msgOwner(); _bindReferrer(account, referrer); waitingPlayerCounts = _joinLineup(tableId, account, playerPublicKey); } function refAndCheckin( address referrer ) external override { address account = _msgOwner(); _bindReferrer(account, referrer); _runCheckinFlow(account); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { DENO } from "../AqConstants.sol"; import { AqReferralCoreInterface } from "./AqReferralInterfaces.sol"; contract AqReferralCore is AqReferralCoreInterface { struct ReferralState { uint32 counts; uint256 cumulativeBets; uint256 settledBets; uint256 cumulativePoints; uint256 settledPoints; } struct ReferralReturnRate { uint32 count; uint64 rateLv1; uint64 rateLv2; } // @custom:storage-location erc7201:ace-quest.referral struct ReferralStorage { ReferralReturnRate[] _cashReturnRates; ReferralReturnRate[] _pointReturnRates; mapping(address => address) _referrers; mapping(address => uint256) _totalCashBonus; mapping(address => uint256) _claimedCashBonus; mapping(address => uint256) _totalPointBonus; mapping(address => uint256) _claimedPointBonus; mapping(address => ReferralState) _lv1Status; mapping(address => ReferralState) _lv2Status; } // keccak256(abi.encode(uint256(keccak256("ace-quest.referral")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReferralStorageLocation = 0xb07d4cdf89c585b157a7276b908da5bac7cdd12d7136d4fcf529951d22ba9100; function _getReferralStorage() private pure returns (ReferralStorage storage $) { assembly { $.slot := ReferralStorageLocation } } function __AqReferral_init_unchained() internal {} function _getReferrer(address addr) internal view returns (address) { ReferralStorage storage $ = _getReferralStorage(); return $._referrers[addr]; } function _getLv1ReferralCount(address addr) internal view returns (uint32) { ReferralStorage storage $ = _getReferralStorage(); return $._lv1Status[addr].counts; } function _getLv2ReferralCount(address addr) internal view returns (uint32) { ReferralStorage storage $ = _getReferralStorage(); return $._lv2Status[addr].counts; } function _getReferralTotalCashBonus(address addr) internal view returns (uint256) { ReferralStorage storage $ = _getReferralStorage(); return $._totalCashBonus[addr]; } function _getReferralTotalPointBonus(address addr) internal view returns (uint256) { ReferralStorage storage $ = _getReferralStorage(); return $._totalPointBonus[addr]; } /** @dev The returning amount unit is CHIP (not staking token) */ function _getReferralPendingCashBonus(address addr) internal view returns (uint256) { ReferralStorage storage $ = _getReferralStorage(); return $._totalCashBonus[addr] - $._claimedCashBonus[addr]; } function _getReferralPendingPointBonus(address addr) internal view returns (uint256) { ReferralStorage storage $ = _getReferralStorage(); return $._totalPointBonus[addr] - $._claimedPointBonus[addr]; } function _settleReferralBonus(address referrer) internal { ReferralStorage storage $ = _getReferralStorage(); if (referrer == address(0)) return; // Settle cash parts $._totalCashBonus[referrer] += _getUnsettledReferralCashBonus(referrer); $._lv1Status[referrer].settledBets = $._lv1Status[referrer].cumulativeBets; $._lv2Status[referrer].settledBets = $._lv2Status[referrer].cumulativeBets; // Settle point parts $._totalPointBonus[referrer] += _getUnsettledReferralPointBonus(referrer); $._lv1Status[referrer].settledPoints = $._lv1Status[referrer].cumulativePoints; $._lv2Status[referrer].settledPoints = $._lv2Status[referrer].cumulativePoints; } function _findCashReferralReturnRate(address user) internal view returns ( uint64 rateV1, uint64 rateV2 ) { ReferralStorage storage $ = _getReferralStorage(); uint32 invitedCounts = $._lv1Status[user].counts; for (uint256 i = 0; i < $._cashReturnRates.length; i++) { if ($._cashReturnRates[i].count > invitedCounts) return (rateV1, rateV2); rateV1 = $._cashReturnRates[i].rateLv1; rateV2 = $._cashReturnRates[i].rateLv2; } } function _findPointReferralReturnRate(address user) internal view returns ( uint64 rateV1, uint64 rateV2 ) { ReferralStorage storage $ = _getReferralStorage(); uint32 invitedCounts = $._lv1Status[user].counts; for (uint256 i = 0; i < $._pointReturnRates.length; i++) { if ($._pointReturnRates[i].count > invitedCounts) return (rateV1, rateV2); rateV1 = $._pointReturnRates[i].rateLv1; rateV2 = $._pointReturnRates[i].rateLv2; } } /** @dev The returning amount unit is CHIP (not staking token) */ function _getUnsettledReferralCashBonus(address user) internal view returns (uint256 amount) { ReferralStorage storage $ = _getReferralStorage(); uint256 lv1Diff = $._lv1Status[user].cumulativeBets - $._lv1Status[user].settledBets; uint256 lv2Diff = $._lv2Status[user].cumulativeBets - $._lv2Status[user].settledBets; (uint64 rateV1, uint64 rateV2) = _findCashReferralReturnRate(user); return lv1Diff * rateV1 / DENO + lv2Diff * rateV2 / DENO; } function _getUnsettledReferralPointBonus(address user) internal view returns (uint256 amount) { ReferralStorage storage $ = _getReferralStorage(); uint256 lv1Diff = $._lv1Status[user].cumulativePoints - $._lv1Status[user].settledPoints; uint256 lv2Diff = $._lv2Status[user].cumulativePoints - $._lv2Status[user].settledPoints; (uint64 rateV1, uint64 rateV2) = _findPointReferralReturnRate(user); return lv1Diff * rateV1 / DENO + lv2Diff * rateV2 / DENO; } function _bindReferrer(address player, address referrer) internal { ReferralStorage storage $ = _getReferralStorage(); if ($._referrers[player] != address(0)) revert AlreadyBoundReferrer(player, $._referrers[player]); if (referrer == address(0) || referrer == player) revert InvalidReferrer(referrer); address v2 = $._referrers[referrer]; if (v2 == player) revert InvalidReferrerV2(v2); _settleReferralBonus(referrer); $._referrers[player] = referrer; emit ReferralRelationSettled(player, referrer); $._lv1Status[referrer].counts++; emit ReferralLv1Added(referrer); if (v2 != address(0)) { $._lv2Status[v2].counts++; emit ReferralLv2Added(v2); } } function _increaseReferralBets(address player, uint256 amount) internal { ReferralStorage storage $ = _getReferralStorage(); address referrer = $._referrers[player]; if (referrer == address(0)) return; $._lv1Status[referrer].cumulativeBets += amount; $._lv2Status[$._referrers[referrer]].cumulativeBets += amount; } function _increaseReferralPoints(address player, uint256 amount) internal { ReferralStorage storage $ = _getReferralStorage(); address referrer = $._referrers[player]; if (referrer == address(0)) return; $._lv1Status[referrer].cumulativePoints += amount; $._lv2Status[$._referrers[referrer]].cumulativePoints += amount; } function _clearPendingCashBonus(address player) internal { ReferralStorage storage $ = _getReferralStorage(); $._claimedCashBonus[player] = $._totalCashBonus[player]; } function _clearPendingPointBonus(address player) internal { ReferralStorage storage $ = _getReferralStorage(); $._claimedPointBonus[player] = $._totalPointBonus[player]; } function _setCashReferralReturnRate(ReferralReturnRate[] memory rates) internal { ReferralStorage storage $ = _getReferralStorage(); delete $._cashReturnRates; for (uint256 i = 0; i < rates.length; i++) { $._cashReturnRates.push(rates[i]); } } function _setPointReferralReturnRate(ReferralReturnRate[] memory rates) internal { ReferralStorage storage $ = _getReferralStorage(); delete $._pointReturnRates; for (uint256 i = 0; i < rates.length; i++) { $._pointReturnRates.push(rates[i]); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IReferralErrors } from "../AqErrors.sol"; interface AqReferralCoreInterface is IReferralErrors { event ReferralRelationSettled(address indexed account, address indexed referrer); event ReferralLv1Added(address indexed referrer); event ReferralLv2Added(address indexed referrer); event CashReferralBonusClaimed(address indexed user, uint256 amount); event PointReferralBonusClaimed(address indexed user, uint256 amount); } interface AqReferralActionInterface is IReferralErrors { function setReferrer(address referrer) external; function claimReferralCashback(address user) external returns ( uint256 cashAmount, uint256 pointAmount ); function refAndAuthorize( address referrer, address payable deputyAccount, uint64 authorizeTimeout, bytes memory deputySignature, uint64 signedAt, bool unsafeIgnoreCurrentAuthorization ) external payable; function refAndJoin( address referrer, uint32 tableId, PublicKey memory playerPublicKey ) external payable returns (uint8 waitingPlayerCounts); function refAndCheckin( address referrer ) external; } interface AqReferralViewInterface is IReferralErrors { struct ReferralStatus { address referrer; uint32 lv1ReferralCount; uint32 lv2ReferralCount; uint256 pendingCashback; uint256 totalCashback; uint256 pendingPoints; uint256 totalPoints; } function getReferralStatus(address user) external view returns (ReferralStatus memory); } interface AqReferralClientInterface is AqReferralCoreInterface, AqReferralActionInterface, AqReferralViewInterface {}
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqCore } from "../AqCore.sol"; contract AqReferralIntermediate is AqCore { /* ░▀▀█░█░█░█▀█░█░█░█▀▀░█▀▄ ░▄▀░░░█░░█▀▀░█▀█░█▀▀░█▀▄ ░▀▀▀░░▀░░▀░░░▀░▀░▀▀▀░▀░▀ ░░░░█▀▀░█▀█░█▄█░█▀▀░█▀▀ ░░░░█░█░█▀█░█░█░█▀▀░▀▀█ ░░░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀ */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqReferralViewInterface } from "./AqReferralInterfaces.sol"; import { AqReferralIntermediate } from "./AqReferralIntermediate.sol"; contract AqReferralViews is AqReferralIntermediate, AqReferralViewInterface { function getReferralStatus(address user) external view returns (ReferralStatus memory status) { status.referrer = _getReferrer(user); status.lv1ReferralCount = _getLv1ReferralCount(user); status.lv2ReferralCount = _getLv2ReferralCount(user); status.pendingCashback = _toCashAmount( _getReferralPendingCashBonus(user) + _getUnsettledReferralCashBonus(user) ); status.totalCashback = _toCashAmount( _getReferralTotalCashBonus(user) + _getUnsettledReferralCashBonus(user) ); status.pendingPoints = _getReferralTotalPointBonus(user) + _getUnsettledReferralPointBonus(user); status.totalPoints = _getReferralTotalPointBonus(user) + _getUnsettledReferralPointBonus(user); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; contract AqRoleCore is AccessControlUpgradeable { modifier onlyAdmin { _checkRole(DEFAULT_ADMIN_ROLE, _msgSender()); _; } function __AqRole_init() internal { __AccessControl_init(); __AqRole_init_unchained(); } function __AqRole_init_unchained() internal { _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); } function isAdmin(address account) public view returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, account); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { EdOnBN254, MaskedCard, RevealVerifier, SLib, AqShuffleVerifierInterface, AqRevealVerifierInterface } from "./ZkShuffle.sol"; import { AqShuffleInterface } from "./AqShuffleInterface.sol"; contract AqShuffleCore is AqShuffleInterface { struct ZkShuffleSettings { address shuffleVerifier; address revealVerifier; bool skipShuffleVerification; bool skipRevealVerification; } struct RevealTokenLog { uint256 gameId; address submitter; bytes proof; uint8 deckIndex; uint8 tokenIndex; } // @custom:storage-location erc7201:ace-quest.shuffle struct ShuffleStorage { /** @dev gameId -> joint key */ mapping(uint256 => PublicKey) _gameKeys; /** @dev player -> public key */ mapping(address => PublicKey) _publicKeys; /** @dev gameId -> uint256[4][52] */ mapping(uint256 => uint256[4][]) _decks; /** @dev cardId => base index */ mapping(uint256 => uint8) _baseIndexes; /** @dev gameId -> RevealToken[][52] */ mapping(uint256 => RevealToken[][52]) _revealTokens; mapping(uint256 => PokerCard[52]) _cards; mapping(bytes32 => RevealTokenLog) _revealTokenLogs; ZkShuffleSettings _settings; } // keccak256(abi.encode(uint256(keccak256("ace-quest.shuffle")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ShuffleStorageLocation = 0x6a1e3160a6784cf29629bca95d0fa0a466da4d102afe45378b42989512220400; function _getShuffleStorage() private pure returns (ShuffleStorage storage $) { assembly { $.slot := ShuffleStorageLocation } } function __AqShuffle_init_unchained( address shuffleVerifier, address revealVerifier ) internal { _setShuffleVerifier(shuffleVerifier); _setRevealVerifier(revealVerifier); __cardIndex_init(); } /* ██████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _getCardIndex(uint256 cardId) internal view returns (uint8) { uint8 index = _getShuffleStorage()._baseIndexes[cardId]; if (index == 0) revert InvalidCardID(cardId); return index - 1; } /** @dev Use this format for on-chain verifier */ function _getVerifierFormatGameCard( uint256 gameId, uint8 idx ) internal view returns (MaskedCard memory) { ShuffleStorage storage $ = _getShuffleStorage(); return MaskedCard( $._decks[gameId][idx][0], $._decks[gameId][idx][1], $._decks[gameId][idx][2], $._decks[gameId][idx][3] ); } /** @dev Use this format for client side display */ function _getClientFormatGameCard( uint256 gameId, uint8 idx ) internal view returns (uint256[4] memory) { ShuffleStorage storage $ = _getShuffleStorage(); return $._decks[gameId][idx]; } function _getPublicKey(address player) internal view returns (PublicKey memory) { return _getShuffleStorage()._publicKeys[player]; } function _getGameKey(uint256 gameId) internal view returns (PublicKey memory) { return _getShuffleStorage()._gameKeys[gameId]; } function _getPoker( uint256 gameId, uint8 cardIndex ) internal view returns (PokerCard memory) { return _getShuffleStorage()._cards[gameId][cardIndex]; } function _getDeck( uint256 gameId ) internal view returns (uint256[4][] memory) { return _getShuffleStorage()._decks[gameId]; } function _compareDeck( uint256 gameId, uint256[4][52] calldata deck ) internal view returns (bool) { uint256[4][] memory storedDeck = _getDeck(gameId); for (uint256 i = 0; i < 52; i++) { if (storedDeck[i][0] != deck[i][0] || storedDeck[i][1] != deck[i][1] || storedDeck[i][2] != deck[i][2] || storedDeck[i][3] != deck[i][3]) { return false; } } return true; } function _getRevealTokens( uint256 gameId, uint8 cardIndex ) internal view returns (RevealToken[] memory) { return _getShuffleStorage()._revealTokens[gameId][cardIndex]; } function _hasShuffled(uint256 gameId) internal view returns (bool) { return _getShuffleStorage()._decks[gameId].length != 0; } function _isValidShuffle( uint256[4][52] calldata maskedCards, uint256[4][52] calldata shuffledCards, bytes calldata proof, uint256[] calldata pkc ) internal view returns (bool) { ShuffleStorage storage $ = _getShuffleStorage(); if ($._settings.skipShuffleVerification) return true; uint256[] memory pi = new uint256[](52 * 4 * 2); for (uint256 i = 0; i < 52; i++) { pi[i * 4 + 0] = maskedCards[i][0]; pi[i * 4 + 1] = maskedCards[i][1]; pi[i * 4 + 2] = maskedCards[i][2]; pi[i * 4 + 3] = maskedCards[i][3]; pi[i * 4 + 0 + 208] = shuffledCards[i][0]; pi[i * 4 + 1 + 208] = shuffledCards[i][1]; pi[i * 4 + 2 + 208] = shuffledCards[i][2]; pi[i * 4 + 3 + 208] = shuffledCards[i][3]; } try _shuffleVerifier().verifyShuffle(proof, pi, pkc) returns (bool valid) { return valid; } catch { return false; } } function _isValidReveal( uint256 gameId, uint8 cardIndex, address player, RevealToken memory revealToken, bytes calldata proof ) internal view returns (bool) { ShuffleStorage storage $ = _getShuffleStorage(); if ($._settings.skipRevealVerification) return true; try _revealVerifier() .verifyReveal( SLib.fromPublicKey(_getPublicKey(player)), _getVerifierFormatGameCard(gameId, cardIndex), SLib.fromRevealToken(revealToken), proof ) returns (bool isValid) { return isValid; } catch { return false; } } function _shuffleVerifier() private view returns (AqShuffleVerifierInterface) { return AqShuffleVerifierInterface(_getShuffleStorage()._settings.shuffleVerifier); } function _revealVerifier() private view returns (AqRevealVerifierInterface) { return AqRevealVerifierInterface(_getShuffleStorage()._settings.revealVerifier); } /* ███████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _setCardBaseIndex(uint256 cardId, uint8 baseIndex) internal { _getShuffleStorage()._baseIndexes[cardId] = baseIndex + 1; } function _setDeck( uint256 gameId, uint256[4][52] calldata deck, uint8 deckSize // 2 x players + 5 ) internal { ShuffleStorage storage $ = _getShuffleStorage(); $._decks[gameId] = new uint256[4][](deckSize); for (uint256 i = 0; i < deckSize; i++) { $._decks[gameId][i] = deck[i]; } } function _setGameKey( uint256 gameId, PublicKey[] memory playerKeys ) internal { _getShuffleStorage()._gameKeys[gameId] = _revealVerifier().aggregateKeys(playerKeys); } function _addRevealToken( address player, uint256 gameId, uint8 cardIndex, RevealToken memory revealToken, bytes calldata proof ) internal { ShuffleStorage storage $ = _getShuffleStorage(); bytes32 rHash = _getTokenHash(revealToken); if ($._revealTokenLogs[rHash].gameId == gameId) revert DuplicatedRevealToken(gameId, cardIndex, revealToken); $._revealTokenLogs[rHash] = RevealTokenLog({ gameId: gameId, submitter: player, proof: proof, deckIndex: cardIndex, tokenIndex: uint8($._revealTokens[gameId][cardIndex].length) }); $._revealTokens[gameId][cardIndex].push(revealToken); } function _getTokenHash(RevealToken memory rToken) internal pure returns (bytes32) { return keccak256(abi.encode(rToken)); } function _revealCard( uint256 gameId, uint8 cardIndex, RevealToken memory extraRevealToken ) internal returns (PokerCard memory poker) { ShuffleStorage storage $ = _getShuffleStorage(); $._revealTokens[gameId][cardIndex].push(extraRevealToken); EdOnBN254.Point memory card = _revealVerifier().unmask( _getVerifierFormatGameCard(gameId, cardIndex), $._revealTokens[gameId][cardIndex] ); uint8 index = _getCardIndex(card.y); poker.suit = PokerSuit(index / 13 + 1); poker.rank = PokerRank(index % 13 + 1); $._cards[gameId][cardIndex] = poker; delete $._revealTokens[gameId][cardIndex]; } function _setPublicKey(address player, PublicKey memory publicKey) internal { _getShuffleStorage()._publicKeys[player] = publicKey; } function _setShuffleVerifier(address verifier) internal { _getShuffleStorage()._settings.shuffleVerifier = verifier; } function _setRevealVerifier(address verifier) internal { _getShuffleStorage()._settings.revealVerifier = verifier; } function _clearCardIndexes(uint256[] memory cardIds) internal { ShuffleStorage storage $ = _getShuffleStorage(); for (uint256 i = 0; i < cardIds.length; i++) { delete $._baseIndexes[cardIds[i]]; } } function __cardIndex_init() internal { uint256[54] memory cardIds = [ 0x0e7e20b3cb30785b64cd6972e2ddf919db64d03d6cf01456243c5ef2fb766a65, 0x2d7690deeaa77c9d89b0ceb3c25f7bb09c44f40b4b8cf5d6fcb512c7be8fcba9, 0x13a50334ef174fd8160bb22e5f150b0ce7656c5c4a19b0ad6bc8f93fdf5fab7c, 0x02acd55fbf59ea2b7a4733ccb5568681e6445d2cba2a4ee0707c1c1d3bc27fea, 0x17fd6b5a880d0570dad7bd4da582c2ba03717615764e3955a8bf2a1b546abfa2, 0x10b37010cd0d430a2bc91ee19f30d1a3d5984605dc299953fdd1ef2fff2f1a95, 0x2a6a6ec33c00e9d9073ce5e48f45afd40cb29303bbc0367606c6f2963ec057c9, 0x27bfe4a93f3e0802f37732ef692a7ff681ce6baaacb6e1cc73e972374e58cec2, 0x2627f2b312c0f1f30b638a1ccc76c7025e94d99cc6006229432fa431044cf7aa, 0x0eb99c13f783f3416210d34a8e5fa766ae239c4c00cb9d3e81f14dc975a7a957, 0x1245109a40dc41351a708f1b7c6fb8bcf809c656b366fb1d0fa7a46991d2b977, 0x000f90cf5f6433978210b9098c0e0865d44f6bc4ab9a7c3cfa63ed7e586f8fa7, 0x2c957cd805d207f518047f6117ecd42fa98b78734efe4cb588cd409ff25aa0b8, 0x2d4b20b261ace4d99d8d80a0998133b0f5c49bad68a4a9a92e9fe2084c8dcde8, 0x23f5c25e039914df2928a715bf68c41ba91b51103d1b1aeaba9323b677b9ea8d, 0x04578915cb17f8fd142120c1bd5c0a26da6668cd746aad9ce707ccfd4464533f, 0x18d33bc856f163194090c1c6419aedbedfaf6dcfb23588ce7002d7deb6ea7623, 0x1db8329a5d644ab56185ebb02724b836c5b1d22d29a57965a0e3a43067e06a08, 0x17a87862cbcee70b0cd0c442d36e26ed763385bb2e948d8f00469d908aa07e72, 0x13fa0efab13db7078ee0aa83cf8fd476614c779e530da57c2101177e69cd68e3, 0x16d52c3e7be3ab38454acdfa2cd7a3cb7a321092f41f038a3ae4f1947bad724e, 0x14157ff39b00904e49f284a3ae75e225b995e3b123887c2ddea019e791fcf88d, 0x0967dd7bac9eb504b37cf33860d77e8ed747f54864aabb63b2487c3f249dd2d2, 0x0047239fd59b5ce078d0fa8a1f0c667b2355fb331bfcfe5fe58754cdade49f2b, 0x0f220815394d328c3a819ca5dc13219b422b8443eca0b8e6911d2b0078d1bb68, 0x04c1f519b090dac2ebff9282ca66592f8b9b6c8c2e38705740daa1230fe2b6cc, 0x169a776c4976ebb48f3c2f3eb6214f26ac70557acd6a28c95044653dee7c7306, 0x17859495fda1f3ac4d240997cfa7d61d9624006410ddc97c7060a24e9fc1053a, 0x250f584b0539ef28cb0b7a136b26a2b796fbbde5a0df8236b4775c0e713ef8c8, 0x025761ba480df2787230ecd283209f959b80a16ff631b751e2213a431a0be30c, 0x0ac3e3209fa174e4981b53a69ce6c5cbca1e217262a27826621553d15fce1317, 0x1daa7bc5da2abf17ed3a43a4a3ddec8e0ed6cc3f2a729b6bfab7f4f252f47197, 0x17e97bb5c68c80f4c0f38eebf4106b0c8ec02c6d9d678588be5f4a71b43c86fe, 0x1dcedb86bb03fa3b404afd3edaa59ceaf8122b2e9dc35c1cdc9f4c65ac6df154, 0x2f2ce3a1cddb1e92541481d30b7c43af5d0350266672632ad06728818b6affdb, 0x2c9fb046ab1f36b104b456598d00e3211fb31b0ef357d7c7de55c4a122257dbe, 0x078d7b6afe9372d90a9b9e2e5f40dc97c06bed7821c0870c8f19847cb4d6d5ce, 0x0548073474086bb9f2f2eda49f8625572f2be9d6b71bb293388e3ff9ad8fb7aa, 0x012b6918773feaa8a22ac16c2e243f2c371c98dbf13801ad0bb9f4cee4575c8d, 0x1abcecb5d562b19da37897d7db6f6227be857493300e1f38d234b43d36037b5d, 0x2fb979bcc2cc562386634c502b9425003d9c0876250b28e21996de4babe104cc, 0x173e80227d906db5ba7289d3611dae189797aa8e3e235949e76d2ce97f6f3c73, 0x022a95649ff5d46713821806b85466cf709ad85171567cf1c0692940793dd30f, 0x00fbc18c6483aef1404ac3e81cae370bb7c9548b5d76124017d522043fc19a6c, 0x1d65fcc3af60454fcb4b6a5fd74eb5c3305757a8a47ff7d07cd92e74cb2a1fbb, 0x227532d0e59b89a139600b60e96a3a8950a93dfa61e40ae623bd16f5529c0687, 0x10f119e93c8adb81acde0c8876e199a30fa0e5f96345a14ab5e6aee59ad80e12, 0x1785b53f50e8bb17af2e5394c3c12bcf8349c13b45a0f0aff2da29070e2109b2, 0x0e928ce03f8f6d07a6c818b295bbc453034e07c55f43eb85b576b22739eb4a51, 0x0d55d8fae5d67f985fe733eaf647f53f42490c2226e54bb7058031fc5e4ef58e, 0x0759e62cf2464671501c16a8534d28bc2e5721a1de966ff2ef9e924424765f41, 0x25bebd6ecfef4f2613efc455e4038489febf84079c88c787977fee2e07629b4b, 0x1464429b0e93a259cec0b660c0bb6df28cb408706eee28f4e77a5e61c931f6f5, 0x142fb87f6d0974097206facac23ea38ffa01e3e1e45003e3ec238b6516eb0b2e ]; for (uint8 i = 0; i < cardIds.length; i++) { _setCardBaseIndex(cardIds[i], i); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IShuffleErrors } from "../AqErrors.sol"; interface AqShuffleInterface is IShuffleErrors { /* ░▀▀█░█░█░█▀█░█░█░█▀▀░█▀▄ ░▄▀░░░█░░█▀▀░█▀█░█▀▀░█▀▄ ░▀▀▀░░▀░░▀░░░▀░▀░▀▀▀░▀░▀ ░░░░█▀▀░█▀█░█▄█░█▀▀░█▀▀ ░░░░█░█░█▀█░█░█░█▀▀░▀▀█ ░░░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀ */ }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import { EdOnBN254 } from "uzkge/contracts/libraries/EdOnBN254.sol"; import { ShuffleVerifier } from "uzkge/contracts/shuffle/ShuffleVerifier.sol"; import { RevealVerifier } from "uzkge/contracts/shuffle/RevealVerifier.sol"; import { VerifierKey_52 } from "uzkge/contracts/shuffle/VerifierKey_52.sol"; import { MaskedCard, RevealVerifier } from "uzkge/contracts/shuffle/RevealVerifier.sol"; // We import these keys to make sure they are compiled and available to be linked in artifacts import { VerifierKeyExtra1_52 } from "uzkge/contracts/shuffle/VerifierKeyExtra1_52.sol"; import { VerifierKeyExtra2_52 } from "uzkge/contracts/shuffle/VerifierKeyExtra2_52.sol"; import { IGlobals } from "../AqErrors.sol"; struct Card { uint256 suite; uint256 value; } interface AqShuffleVerifierInterface { function verifyShuffle( bytes calldata proof, uint256[] calldata publicKeyInput, uint256[] calldata publicKeyCommitment ) external view returns (bool); } interface AqRevealVerifierInterface is IGlobals { function aggregateKeys( PublicKey[] memory pks ) external view returns (PublicKey memory); function verifyReveal( EdOnBN254.Point memory pk, MaskedCard memory masked, EdOnBN254.Point memory rToken, bytes calldata proofBytes ) external view returns (bool); function unmask( MaskedCard memory masked, RevealToken[] memory reveals ) external view returns (EdOnBN254.Point memory); } contract ZkShuffleVerifier is ShuffleVerifier { constructor(address _vk1, address _vk2) ShuffleVerifier(_vk1, _vk2) { _verifyKey = VerifierKey_52.load; } } contract ZkRevealVerifier is RevealVerifier { function verifyUnmask( MaskedCard memory masked, EdOnBN254.Point[] memory reveals, Card memory card ) external view returns (bool) { EdOnBN254.Point memory point = unmask(masked, reveals); uint256 pointIndex = pointToCardIndex(point.y); uint256 cardIndex; if (card.value > 52) { cardIndex = card.value - 1; } else { cardIndex = (card.suite - 1) * 13 + (card.value - 1); } return cardIndex == pointIndex; } function pointToCardIndex(uint256 y) public pure returns (uint256) { uint256[54] memory cardmaps = [ 0x0e7e20b3cb30785b64cd6972e2ddf919db64d03d6cf01456243c5ef2fb766a65, 0x2d7690deeaa77c9d89b0ceb3c25f7bb09c44f40b4b8cf5d6fcb512c7be8fcba9, 0x13a50334ef174fd8160bb22e5f150b0ce7656c5c4a19b0ad6bc8f93fdf5fab7c, 0x02acd55fbf59ea2b7a4733ccb5568681e6445d2cba2a4ee0707c1c1d3bc27fea, 0x17fd6b5a880d0570dad7bd4da582c2ba03717615764e3955a8bf2a1b546abfa2, 0x10b37010cd0d430a2bc91ee19f30d1a3d5984605dc299953fdd1ef2fff2f1a95, 0x2a6a6ec33c00e9d9073ce5e48f45afd40cb29303bbc0367606c6f2963ec057c9, 0x27bfe4a93f3e0802f37732ef692a7ff681ce6baaacb6e1cc73e972374e58cec2, 0x2627f2b312c0f1f30b638a1ccc76c7025e94d99cc6006229432fa431044cf7aa, 0x0eb99c13f783f3416210d34a8e5fa766ae239c4c00cb9d3e81f14dc975a7a957, 0x1245109a40dc41351a708f1b7c6fb8bcf809c656b366fb1d0fa7a46991d2b977, 0x000f90cf5f6433978210b9098c0e0865d44f6bc4ab9a7c3cfa63ed7e586f8fa7, 0x2c957cd805d207f518047f6117ecd42fa98b78734efe4cb588cd409ff25aa0b8, 0x2d4b20b261ace4d99d8d80a0998133b0f5c49bad68a4a9a92e9fe2084c8dcde8, 0x23f5c25e039914df2928a715bf68c41ba91b51103d1b1aeaba9323b677b9ea8d, 0x04578915cb17f8fd142120c1bd5c0a26da6668cd746aad9ce707ccfd4464533f, 0x18d33bc856f163194090c1c6419aedbedfaf6dcfb23588ce7002d7deb6ea7623, 0x1db8329a5d644ab56185ebb02724b836c5b1d22d29a57965a0e3a43067e06a08, 0x17a87862cbcee70b0cd0c442d36e26ed763385bb2e948d8f00469d908aa07e72, 0x13fa0efab13db7078ee0aa83cf8fd476614c779e530da57c2101177e69cd68e3, 0x16d52c3e7be3ab38454acdfa2cd7a3cb7a321092f41f038a3ae4f1947bad724e, 0x14157ff39b00904e49f284a3ae75e225b995e3b123887c2ddea019e791fcf88d, 0x0967dd7bac9eb504b37cf33860d77e8ed747f54864aabb63b2487c3f249dd2d2, 0x0047239fd59b5ce078d0fa8a1f0c667b2355fb331bfcfe5fe58754cdade49f2b, 0x0f220815394d328c3a819ca5dc13219b422b8443eca0b8e6911d2b0078d1bb68, 0x04c1f519b090dac2ebff9282ca66592f8b9b6c8c2e38705740daa1230fe2b6cc, 0x169a776c4976ebb48f3c2f3eb6214f26ac70557acd6a28c95044653dee7c7306, 0x17859495fda1f3ac4d240997cfa7d61d9624006410ddc97c7060a24e9fc1053a, 0x250f584b0539ef28cb0b7a136b26a2b796fbbde5a0df8236b4775c0e713ef8c8, 0x025761ba480df2787230ecd283209f959b80a16ff631b751e2213a431a0be30c, 0x0ac3e3209fa174e4981b53a69ce6c5cbca1e217262a27826621553d15fce1317, 0x1daa7bc5da2abf17ed3a43a4a3ddec8e0ed6cc3f2a729b6bfab7f4f252f47197, 0x17e97bb5c68c80f4c0f38eebf4106b0c8ec02c6d9d678588be5f4a71b43c86fe, 0x1dcedb86bb03fa3b404afd3edaa59ceaf8122b2e9dc35c1cdc9f4c65ac6df154, 0x2f2ce3a1cddb1e92541481d30b7c43af5d0350266672632ad06728818b6affdb, 0x2c9fb046ab1f36b104b456598d00e3211fb31b0ef357d7c7de55c4a122257dbe, 0x078d7b6afe9372d90a9b9e2e5f40dc97c06bed7821c0870c8f19847cb4d6d5ce, 0x0548073474086bb9f2f2eda49f8625572f2be9d6b71bb293388e3ff9ad8fb7aa, 0x012b6918773feaa8a22ac16c2e243f2c371c98dbf13801ad0bb9f4cee4575c8d, 0x1abcecb5d562b19da37897d7db6f6227be857493300e1f38d234b43d36037b5d, 0x2fb979bcc2cc562386634c502b9425003d9c0876250b28e21996de4babe104cc, 0x173e80227d906db5ba7289d3611dae189797aa8e3e235949e76d2ce97f6f3c73, 0x022a95649ff5d46713821806b85466cf709ad85171567cf1c0692940793dd30f, 0x00fbc18c6483aef1404ac3e81cae370bb7c9548b5d76124017d522043fc19a6c, 0x1d65fcc3af60454fcb4b6a5fd74eb5c3305757a8a47ff7d07cd92e74cb2a1fbb, 0x227532d0e59b89a139600b60e96a3a8950a93dfa61e40ae623bd16f5529c0687, 0x10f119e93c8adb81acde0c8876e199a30fa0e5f96345a14ab5e6aee59ad80e12, 0x1785b53f50e8bb17af2e5394c3c12bcf8349c13b45a0f0aff2da29070e2109b2, 0x0e928ce03f8f6d07a6c818b295bbc453034e07c55f43eb85b576b22739eb4a51, 0x0d55d8fae5d67f985fe733eaf647f53f42490c2226e54bb7058031fc5e4ef58e, 0x0759e62cf2464671501c16a8534d28bc2e5721a1de966ff2ef9e924424765f41, 0x25bebd6ecfef4f2613efc455e4038489febf84079c88c787977fee2e07629b4b, 0x1464429b0e93a259cec0b660c0bb6df28cb408706eee28f4e77a5e61c931f6f5, 0x142fb87f6d0974097206facac23ea38ffa01e3e1e45003e3ec238b6516eb0b2e ]; uint256 pointIndex; for (uint256 i = 0; i < 54; i++) { if (cardmaps[i] == y) { pointIndex = i; break; } } return pointIndex; } } library SLib { function fromPublicKey(IGlobals.PublicKey memory publicKey) internal pure returns (EdOnBN254.Point memory) { return EdOnBN254.Point(publicKey.x, publicKey.y); } function toPublicKey(EdOnBN254.Point memory point) internal pure returns (IGlobals.PublicKey memory) { return IGlobals.PublicKey(point.x, point.y); } function fromRevealToken(IGlobals.RevealToken memory revealToken) internal pure returns (EdOnBN254.Point memory) { return EdOnBN254.Point(revealToken.x, revealToken.y); } function toRevealToken(EdOnBN254.Point memory point) internal pure returns (IGlobals.RevealToken memory) { return IGlobals.RevealToken(point.x, point.y); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqTableCoreInterface } from "./AqTableInterfaces.sol"; contract AqTableCore is AqTableCoreInterface { // @custom:storage-location erc7201:ace-quest.table struct TableStorage { uint32 _noResponseTimeout; uint32 _maxTableId; uint32[] _openTableIds; uint256 _totalSeries; uint256 _totalGames; mapping(uint32 => uint8) _seats; mapping(uint32 => uint256[3]) _buyins; // [initial, min, max] mapping(uint32 => address[]) _players; mapping(uint32 => TableTimers) _timers; mapping(uint32 => string) _names; mapping(uint32 => TableSeries) _series; mapping(uint32 => TableGame) _games; /** @dev reverse link gameId to table & series */ mapping(uint256 => GameMeta) _gameMetas; /** @dev tableId | position => address */ mapping(uint64 => address) _tableInitPositions; /** @dev update while player join or leave */ mapping(uint32 => uint256) _tableSeeds; } // keccak256(abi.encode(uint256(keccak256("ace-quest.table")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant TableStorageLocation = 0x877478df16c9d495ebd4b85c28d57b680d8e563b5db2e2216bcad52723b24b00; function _getStorage() private pure returns (TableStorage storage $) { assembly { $.slot := TableStorageLocation } } function __AqTable_init_unchained() internal { _setNoResponseTimeout(30 minutes); } /* ███ ███ ██████ ██████ ██ ███████ ██ ███████ ██████ ███████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ █████ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ███████ ██ ██ ███████ */ modifier onlyPendingTable(uint32 tableId) { if (!_isTablePending(tableId)) revert TableNotPending(tableId); _; } /* ██████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _tableCounts() internal view returns (uint256) { return _getStorage()._openTableIds.length; } function _tableIds() internal view returns (uint32[] memory) { return _getStorage()._openTableIds; } function _playerCounts(uint32 tableId) internal view returns (uint8) { return uint8(_getStorage()._players[tableId].length); } function _isGameEnded(uint32 tableId) internal view returns (bool) { return _getStorage()._games[tableId].endedAt > 0; } function _tableLastFullAt(uint32 tableId) internal view returns (uint64) { return _getStorage()._timers[tableId].fullAt; } function _tableLastStartAt(uint32 tableId) internal view returns (uint64) { return _getStorage()._timers[tableId].startAt; } function _tableLastEndAt(uint32 tableId) internal view returns (uint64) { return _getStorage()._timers[tableId].endAt; } function _isTableFull(uint32 tableId) internal view returns (bool) { return _playerCounts(tableId) >= _seats(tableId); } function _getTablePlayers(uint32 tableId) internal view returns (address[] memory) { return _getStorage()._players[tableId]; } function _isTableOpen(uint32 tableId) internal view returns (bool) { TableTimers storage $time = _getStorage()._timers[tableId]; return $time.openAt > $time.closeAt; } function _isTableClosed(uint32 tableId) internal view returns (bool) { TableTimers storage $time = _getStorage()._timers[tableId]; return $time.closeAt >= $time.openAt; } function _isTableNoResponse(uint32 tableId) internal view returns (bool) { TableStorage storage $ = _getStorage(); TableTimers storage $time = $._timers[tableId]; bool isStarted = $time.startAt > $time.endAt; return isStarted && $time.lastActionAt + _noResponseTimeout() < block.timestamp; } function _isTableStopped(uint32 tableId) internal view returns (bool) { TableTimers storage $time = _getStorage()._timers[tableId]; return $time.endAt >= $time.startAt; } function _isTablePending(uint32 tableId) internal view returns (bool) { if (!_isTableOpen(tableId)) return false; return _isTableStopped(tableId) || _isTableNoResponse(tableId); } function _isTablePlaying(uint32 tableId) internal view returns (bool) { TableTimers storage $time = _getStorage()._timers[tableId]; return _isTableOpen(tableId) && $time.startAt > $time.endAt && !_isTableNoResponse(tableId); } function _tableHasPlayer(uint32 tableId, address player) internal view returns (bool) { address[] memory players = _getStorage()._players[tableId]; for (uint256 i = 0; i < players.length; i++) { if (players[i] == player) return true; } return false; } /** * @notice Get the initial buyin amount of a table */ function _initBI(uint32 tableId) internal view returns (uint256) { return _getStorage()._buyins[tableId][0]; } /** * @notice Get the min buyin amount of a table * @dev 0 means no limit */ function _minBI(uint32 tableId) internal view returns (uint256) { return _getStorage()._buyins[tableId][1]; } /** * @notice Get the max buyin amount of a table * @dev 0 means no limit */ function _maxBI(uint32 tableId) internal view returns (uint256) { return _getStorage()._buyins[tableId][2]; } function _name(uint32 tableId) internal view returns (string memory) { return _getStorage()._names[tableId]; } function _seats(uint32 tableId) internal view returns (uint8) { return _getStorage()._seats[tableId]; } function _gamePlayerCounts(uint256 gameId) internal view returns (uint8) { return _seats(_getTableIdByGameId(gameId)); } function _leftPlayerCounts(uint32 tableId) internal view returns (uint8) { return _getStorage()._series[tableId].leftCount; } function _tableIndex(uint32 tableId) internal view returns (uint256) { TableStorage storage $ = _getStorage(); for (uint256 i = 0; i < $._openTableIds.length; i++) { if ($._openTableIds[i] == tableId) { return i; } } revert TableNotExists(tableId); } function _maxTableId() internal view returns (uint32) { return _getStorage()._maxTableId; } function _noResponseTimeout() internal view returns (uint32) { return _getStorage()._noResponseTimeout; } function _gameId(uint32 tableId) internal view returns (uint256) { return _getStorage()._games[tableId].gameId; } function _pots(uint32 tableId) internal view returns (uint256) { return _getStorage()._games[tableId].pots; } function _getTableIdByGameId(uint256 gameId) internal view returns (uint32) { TableStorage storage $ = _getStorage(); return $._gameMetas[gameId].tableId; } function _getSeriesIdByGameId(uint256 gameId) internal view returns (uint64) { TableStorage storage $ = _getStorage(); return $._gameMetas[gameId].seriesId; } function _isGameOngoing(uint256 gameId) internal view returns (bool) { TableStorage storage $ = _getStorage(); uint32 tableId = $._gameMetas[gameId].tableId; return $._games[tableId].gameId == gameId && _isTablePlaying(tableId); } function _orderListByTableSeed(uint32 tableId, address[] memory players) internal view returns (address[] memory) { uint256 seed = _getStorage()._tableSeeds[tableId]; for (uint8 i = 0; i < players.length; i++) { uint8 pIndex = uint8(uint16(seed) % (players.length - i)); seed >>= 16; address player = players[pIndex]; players[pIndex] = players[players.length - i - 1]; players[players.length - i - 1] = player; } return players; } function _getTableInitPosition(uint32 tableId, uint8 position) internal view returns (address) { return _getStorage()._tableInitPositions[uint64(tableId) << 8 | position]; } function _tableSeriesGameCounts(uint32 tableId) internal view returns (uint32) { return _getStorage()._series[tableId].gameCounts; } /** @dev Only for playing table!! */ function _tableInitialPlayers(uint32 tableId) internal view returns (address[] memory players) { TableStorage storage $ = _getStorage(); players = new address[]($._seats[tableId]); for (uint8 i = 0; i < players.length; i++) { players[i] = _getTableInitPosition(tableId, uint8(i + 1)); } } function _hasLeft(uint32 tableId, uint8 position) internal view returns (bool) { return _getStorage()._series[tableId].playerLeft & (1 << position) > 0; } /* ███████ ███████ ████████ ████████ ███████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ █████ ██ ██ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ██ ███████ */ function _increaseTablePot(uint32 tableId, uint256 amount) internal { TableStorage storage $ = _getStorage(); $._games[tableId].pots += amount; } function _endTableGame(uint32 tableId) internal { TableStorage storage $ = _getStorage(); uint256 gameId = _gameId(tableId); if (gameId == 0) return; emit TableGameEnded( tableId, _gameId(tableId), _pots(tableId) ); delete $._games[tableId]; } function _stopUnusualEndTable(uint32 tableId, uint64 endAt) internal { TableStorage storage $ = _getStorage(); uint64 seriesId = $._series[tableId].seriesId; $._timers[tableId].endAt = endAt; if (seriesId != 0) { _endTableGame(tableId); _clearTableSeries(tableId); _clearTablePlayers(tableId); emit TableSeriesStopped( tableId, seriesId, endAt ); } } function _stopNoResponseTable(uint32 tableId) internal { TableStorage storage $ = _getStorage(); uint64 seriesId = $._series[tableId].seriesId; uint64 timeout = $._timers[tableId].lastActionAt + $._noResponseTimeout; $._timers[tableId].endAt = timeout; if (seriesId != 0) { _endTableGame(tableId); _clearTableSeries(tableId); _clearTablePlayers(tableId); emit TableSeriesStopped( tableId, seriesId, timeout ); } } function _clearTableSeries(uint32 tableId) internal { delete _getStorage()._series[tableId]; } function _openTable(uint32 tableId) internal { TableStorage storage $ = _getStorage(); if (_isTableClosed(tableId)) { $._openTableIds.push(tableId); } $._timers[tableId].openAt = uint64(block.timestamp); if (tableId > _maxTableId()) { $._maxTableId = tableId; } } function _openNewTable() internal returns (uint32 id) { id = _maxTableId() + 1; _openTable(id); } function _closeTable(uint32 tableId) internal { TableStorage storage $ = _getStorage(); uint256 index = _tableIndex(tableId); $._openTableIds[index] = $._openTableIds[$._openTableIds.length - 1]; $._openTableIds.pop(); $._timers[tableId].closeAt = uint64(block.timestamp); } function _startTableGame(uint32 tableId) internal { TableStorage storage $ = _getStorage(); _beforeNewGame(tableId, $._games[tableId].gameId); $._games[tableId] = TableGame({ gameId: ++$._totalGames, pots: 0, startedAt: uint64(block.timestamp), endedAt: 0 }); $._series[tableId].gameCounts++; $._timers[tableId].lastActionAt = uint64(block.timestamp); $._gameMetas[$._totalGames] = GameMeta({ tableId: tableId, seriesId: $._series[tableId].seriesId }); emit TableGameStarted( tableId, $._series[tableId].seriesId, $._games[tableId].gameId ); _afterNewGame(tableId, $._games[tableId].gameId); } function _startTableSeries(uint32 tableId) internal returns (uint64 seriesId) { TableStorage storage $ = _getStorage(); _beforeNewSeries(tableId, $._series[tableId].seriesId); $._series[tableId] = TableSeries({ seriesId: uint64(++$._totalSeries), gameCounts: 0, playerLeft: 0, leftCount: 0 }); $._timers[tableId].startAt = uint64(block.timestamp); emit TableSeriesStarted( tableId, $._series[tableId].seriesId, $._timers[tableId].startAt, $._players[tableId] ); _afterNewSeries(tableId, $._series[tableId].seriesId); return $._series[tableId].seriesId; } function _endTableSeries(uint32 tableId) internal { TableStorage storage $ = _getStorage(); $._timers[tableId].endAt = uint64(block.timestamp); if (!_isGameEnded(tableId)) _endTableGame(tableId); if (_playerCounts(tableId) > 0) { _clearTablePlayers(tableId); } } function _setTablePlayers(uint32 tableId, address[] memory players) internal { _getStorage()._players[tableId] = players; } function _clearTablePlayers(uint32 tableId) internal { delete _getStorage()._players[tableId]; } function _addTablePlayer( uint32 tableId, address player ) internal returns ( uint8 playerCounts, bool isFull ) { TableStorage storage $ = _getStorage(); $._players[tableId].push(player); playerCounts = uint8($._players[tableId].length); isFull = _isTableFull(tableId); if (isFull) { $._timers[tableId].fullAt = uint64(block.timestamp); } _updateTableSeed(tableId); return (playerCounts, isFull); } function _updateTableSeed(uint32 tableId) internal { TableStorage storage $ = _getStorage(); uint256 last = $._tableSeeds[tableId]; $._tableSeeds[tableId] = uint256(keccak256( abi.encodePacked( block.number, last, block.timestamp ) )); } function _removeTablePlayerPreservingOrder(uint32 tableId, address player) internal { address[] storage players = _getStorage()._players[tableId]; if (players.length == 0) return; _updateTableSeed(tableId); for (uint256 i = 0; i < players.length - 1; i++) { if (players[i] == player) { players[i] = players[i + 1]; players[i + 1] = player; } } if (players[players.length - 1] == player) players.pop(); } function _setBuyins( uint32 tableId, uint256 initialBuyin, uint256 minBuyin, uint256 maxBuyin ) internal onlyPendingTable(tableId) { TableStorage storage $ = _getStorage(); $._buyins[tableId] = [initialBuyin, minBuyin, maxBuyin]; } function _setTableSeats( uint32 tableId, uint8 seats ) internal onlyPendingTable(tableId) { TableStorage storage $ = _getStorage(); $._seats[tableId] = seats; } function _setTableName(uint32 tableId, string memory name) internal { TableStorage storage $ = _getStorage(); $._names[tableId] = name; } function _setNoResponseTimeout(uint32 timeout) internal { TableStorage storage $ = _getStorage(); $._noResponseTimeout = timeout; } function _setTableInitPosition(uint32 tableId, uint8 position, address player) internal { TableStorage storage $ = _getStorage(); $._tableInitPositions[uint64(tableId) << 8 | position] = player; } function _refreshTableTimer(uint32 tableId) internal { TableStorage storage $ = _getStorage(); $._timers[tableId].lastActionAt = uint64(block.timestamp); } function _resetTableFullTimer(uint32 tableId) internal { TableStorage storage $ = _getStorage(); delete $._timers[tableId].fullAt; } function _flagPlayerLeft(uint32 tableId, uint8 position) internal { TableStorage storage $ = _getStorage(); uint16 before = $._series[tableId].playerLeft; $._series[tableId].playerLeft |= uint16(1 << position); if (before != $._series[tableId].playerLeft) $._series[tableId].leftCount++; } function _hasAllLeft(uint32 tableId) internal view returns (bool) { return _getStorage()._series[tableId].leftCount == _seats(tableId); } /* ██ ██ ██ ██████ ████████ ██ ██ █████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██████ ██ ██ ███████ ███████ */ function _beforeNewGame(uint32 tableId, uint256 lastGameId) internal virtual {} function _afterNewGame(uint32 tableId, uint256 nextGameId) internal virtual {} function _beforeNewSeries(uint32 tableId, uint64 lastSeriesId) internal virtual {} function _afterNewSeries(uint32 tableId, uint64 nextSeriesId) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ITableErrors } from "../AqErrors.sol"; interface AqTableCoreInterface is ITableErrors { struct TableTimers { // Admin actions uint64 openAt; uint64 closeAt; // Player actions uint64 lastActionAt; uint64 fullAt; uint64 startAt; uint64 endAt; } struct TableSeries { uint64 seriesId; uint32 gameCounts; uint16 playerLeft; uint8 leftCount; } struct TableGame { uint256 gameId; uint256 pots; uint64 startedAt; uint64 endedAt; } struct GameMeta { uint32 tableId; uint64 seriesId; } event TableSeriesStarted( uint32 indexed tableId, uint64 indexed seriesId, uint64 startedAt, address[] players ); event TableSeriesStopped( uint32 indexed tableId, uint64 indexed seriesId, uint64 stoppedAt ); event TableGameStarted( uint32 indexed tableId, uint64 indexed seriesId, uint256 indexed gameId ); event TableGameEnded( uint32 indexed tableId, uint256 indexed gameId, uint256 pots ); } interface AqTableClientInterface is AqTableCoreInterface {}
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqTaskActionInterface } from "./AqTaskInterfaces.sol"; import { AqTaskIntermediate } from "./AqTaskIntermediate.sol"; contract AqTaskActions is AqTaskIntermediate, AqTaskActionInterface { function checkin() external override nonReentrant { address player = _msgOwner(); _runCheckinFlow(player); } function claimTaskRewards( address player, uint8[] memory taskIds ) external override nonReentrant returns (uint256 totalClaimed) { for (uint8 i = 0; i < taskIds.length; i++) { (uint8 index, bool isWeekly) = _taskIdToIndex(taskIds[i]); if (isWeekly && _hasClaimedWeeklyTask(player, index)) revert AlreadyClaimedTask(player, taskIds[i]); if (!isWeekly && _hasClaimedDailyTask(player, index)) revert AlreadyClaimedTask(player, taskIds[i]); uint256 reward = isWeekly ? _checkWeeklyTaskReward(player, index) : _checkDailyTaskReward(player, index); if (reward == 0) revert TaskNotCompleted(player, taskIds[i]); if (isWeekly) { _flagWeeklyTaskClaimed(player, index); } else { _flagDailyTaskClaimed(player, index); } totalClaimed += reward; emit TaskCompleted(player, taskIds[i]); } _awardPoints(player, totalClaimed); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqTaskCoreInterface } from "./AqTaskInterfaces.sol"; contract AqTaskCore is AqTaskCoreInterface { struct TaskSettings { address rewardToken; uint32 dayDuration; uint32 dayShiftPlus; uint32 dayShiftMinus; uint32 weekDuration; uint32 weekShiftPlus; uint32 weekShiftMinus; } struct TaskPlayerCheckin { uint64 lastCheckinAt; uint32 consecutiveCount; uint160 __padding; } struct TaskPlayerLog { uint32 index; uint32 played; uint32 won; uint128 totalBet; uint32 bClaimed; } // @custom:storage-location erc7201:ace-quest.task struct TaskStorage { TaskSettings _settings; mapping(address => TaskPlayerCheckin) _checkins; mapping(address => TaskPlayerLog) _dailyLogs; mapping(address => TaskPlayerLog) _weeklyLogs; BasicTask[] _dailyTasks; BasicTask[] _weeklyTasks; uint256[] _checkinRewards; } uint8 private constant MaxTaskCount = 0x10; // keccak256(abi.encode(uint256(keccak256("ace-quest.task")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant TaskStorageLocation = 0xda438e010a00e4588bcd35d5e1772d216332d9f88d94c34062dc474e5961f500; function _getTaskStorage() private pure returns (TaskStorage storage $) { assembly { $.slot := TaskStorageLocation } } function __AqTask_init_unchained() internal { _setDayConfig(1 days, 0 hours, 0 hours); _setWeekConfig(7 days, 0 days, 4 days); // unix timestamp 0 is Thursday } function _setTaskRewardToken(address token) internal { TaskStorage storage $ = _getTaskStorage(); $._settings.rewardToken = token; } function _getTaskRewardToken() internal view returns (address) { TaskStorage storage $ = _getTaskStorage(); return $._settings.rewardToken; } function _setDailyTasks(BasicTask[] memory tasks) internal { TaskStorage storage $ = _getTaskStorage(); delete $._dailyTasks; for (uint256 i = 0; i < tasks.length; i++) { $._dailyTasks.push(tasks[i]); } } function _setWeeklyTasks(BasicTask[] memory tasks) internal { TaskStorage storage $ = _getTaskStorage(); delete $._weeklyTasks; for (uint256 i = 0; i < tasks.length; i++) { $._weeklyTasks.push(tasks[i]); } } function _getDailyTasks() internal view returns (BasicTask[] memory) { TaskStorage storage $ = _getTaskStorage(); return $._dailyTasks; } function _getWeeklyTasks() internal view returns (BasicTask[] memory) { TaskStorage storage $ = _getTaskStorage(); return $._weeklyTasks; } function _lastCheckinAt(address user) internal view returns (uint64) { TaskStorage storage $ = _getTaskStorage(); return $._checkins[user].lastCheckinAt; } function _checkIn( address user, uint64 timestamp ) internal returns (uint32 count, uint256 rewardAmount) { TaskStorage storage $ = _getTaskStorage(); uint64 d0 = _toLocalDay($._checkins[user].lastCheckinAt); uint64 d1 = _toLocalDay(timestamp); count = d1 == d0 + 1 && $._checkins[user].consecutiveCount < $._checkinRewards.length ? $._checkins[user].consecutiveCount + 1 : 1; rewardAmount = $._checkinRewards[count - 1]; $._checkins[user].lastCheckinAt = timestamp; $._checkins[user].consecutiveCount = count; emit Checkin(user, timestamp); } function _toLocalDay(uint256 timestamp) internal view returns (uint64) { TaskStorage storage $ = _getTaskStorage(); if (timestamp < $._settings.dayShiftMinus) return 0; return uint64((timestamp + $._settings.dayShiftPlus - $._settings.dayShiftMinus) / $._settings.dayDuration); } function _toLocalWeek(uint256 timestamp) internal view returns (uint64) { TaskStorage storage $ = _getTaskStorage(); if (timestamp < $._settings.weekShiftMinus) return 0; return uint64((timestamp + $._settings.weekShiftPlus - $._settings.weekShiftMinus) / $._settings.weekDuration); } function _setDayConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) internal { TaskStorage storage $ = _getTaskStorage(); $._settings.dayDuration = duration; $._settings.dayShiftPlus = shiftPlus; $._settings.dayShiftMinus = shiftMinus; } function _setWeekConfig(uint32 duration, uint32 shiftPlus, uint32 shiftMinus) internal { TaskStorage storage $ = _getTaskStorage(); $._settings.weekDuration = duration; $._settings.weekShiftPlus = shiftPlus; $._settings.weekShiftMinus = shiftMinus; } function _setCheckinRewards(uint256[] memory rewards) internal { TaskStorage storage $ = _getTaskStorage(); delete $._checkinRewards; for (uint256 i = 0; i < rewards.length; i++) { $._checkinRewards.push(rewards[i]); } } function _getCheckinRewards() internal view returns (uint256[] memory) { TaskStorage storage $ = _getTaskStorage(); return $._checkinRewards; } function _hasCheckedIn(address user) internal view returns (bool) { uint64 d0 = _toLocalDay(_lastCheckinAt(user)); uint64 d1 = _toLocalDay(block.timestamp); return d0 == d1; } function _getConsecutiveCheckinCount(address user) internal view returns (uint32) { TaskStorage storage $ = _getTaskStorage(); uint64 d0 = _toLocalDay(_lastCheckinAt(user)); uint64 d1 = _toLocalDay(block.timestamp); return d1 > d0 + 1 ? 0 // Today is over 1 day after the last checkin : $._checkins[user].consecutiveCount; } function _increaseCompletedGameTask(address user) internal { TaskStorage storage $ = _getTaskStorage(); uint64 dayIndex = _toLocalDay(block.timestamp); if (dayIndex == $._dailyLogs[user].index) { $._dailyLogs[user].played++; } else { delete $._dailyLogs[user]; $._dailyLogs[user].index = uint32(dayIndex); $._dailyLogs[user].played = 1; } uint64 weekIndex = _toLocalWeek(block.timestamp); if (weekIndex == $._weeklyLogs[user].index) { $._weeklyLogs[user].played++; } else { delete $._weeklyLogs[user]; $._weeklyLogs[user].index = uint32(weekIndex); $._weeklyLogs[user].played = 1; } } function _increaseWonGameTask(address user) internal { TaskStorage storage $ = _getTaskStorage(); uint64 dayIndex = _toLocalDay(block.timestamp); if (dayIndex == $._dailyLogs[user].index) { $._dailyLogs[user].won++; } else { delete $._dailyLogs[user]; $._dailyLogs[user].index = uint32(dayIndex); $._dailyLogs[user].won = 1; } uint64 weekIndex = _toLocalWeek(block.timestamp); if (weekIndex == $._weeklyLogs[user].index) { $._weeklyLogs[user].won++; } else { delete $._weeklyLogs[user]; $._weeklyLogs[user].index = uint32(weekIndex); $._weeklyLogs[user].won = 1; } } function _increaseBetTask(address user, uint128 amount) internal { TaskStorage storage $ = _getTaskStorage(); uint64 dayIndex = _toLocalDay(block.timestamp); if (dayIndex == $._dailyLogs[user].index) { $._dailyLogs[user].totalBet += amount; } else { delete $._dailyLogs[user]; $._dailyLogs[user].index = uint32(dayIndex); $._dailyLogs[user].totalBet = amount; } uint64 weekIndex = _toLocalWeek(block.timestamp); if (weekIndex == $._weeklyLogs[user].index) { $._weeklyLogs[user].totalBet += amount; } else { delete $._weeklyLogs[user]; $._weeklyLogs[user].index = uint32(weekIndex); $._weeklyLogs[user].totalBet = amount; } } function _flagDailyTaskClaimed(address user, uint8 index) internal { TaskStorage storage $ = _getTaskStorage(); $._dailyLogs[user].bClaimed |= uint32(1 << index); } function _flagWeeklyTaskClaimed(address user, uint8 index) internal { TaskStorage storage $ = _getTaskStorage(); $._weeklyLogs[user].bClaimed |= uint32(1 << index); } function _toTaskId(uint8 taskIndex, bool isWeekyTask) internal pure returns (uint8) { return uint8((isWeekyTask ? MaxTaskCount : 0) | (taskIndex % MaxTaskCount + 1)); } function _taskIdToIndex(uint8 id) internal view returns (uint8 index, bool isWeekly) { TaskStorage storage $ = _getTaskStorage(); isWeekly = id > MaxTaskCount; uint256 N = id % MaxTaskCount; if (N == 0) revert InvalidTaskId(id); if (isWeekly && N > $._weeklyTasks.length) revert InvalidTaskId(id); if (!isWeekly && N > $._dailyTasks.length) revert InvalidTaskId(id); index = uint8(N - 1); } function _getTaskDailyLog(address user) internal view returns (TaskPlayerLog memory) { TaskStorage storage $ = _getTaskStorage(); uint32 dayIndex = uint32(_toLocalDay(block.timestamp)); if ($._dailyLogs[user].index == dayIndex) { return $._dailyLogs[user]; } else { return TaskPlayerLog({ index: dayIndex, played: 0, won: 0, totalBet: 0, bClaimed: 0 }); } } function _getTaskWeeklyLog(address user) internal view returns (TaskPlayerLog memory) { TaskStorage storage $ = _getTaskStorage(); uint32 weekIndex = uint32(_toLocalWeek(block.timestamp)); if ($._weeklyLogs[user].index == weekIndex) { return $._weeklyLogs[user]; } else { return TaskPlayerLog({ index: weekIndex, played: 0, won: 0, totalBet: 0, bClaimed: 0 }); } } function _hasClaimedDailyTask(address user, uint8 index) internal view returns (bool) { uint32 bClaimed = _getTaskDailyLog(user).bClaimed; return bClaimed & uint32(1 << index) != 0; } function _hasClaimedWeeklyTask(address user, uint8 index) internal view returns (bool) { uint32 bClaimed = _getTaskWeeklyLog(user).bClaimed; return bClaimed & uint32(1 << index) != 0; } function _getDailyTaskProgress( address user, TaskType taskType ) internal view returns (uint256) { if (taskType == TaskType.GAME_COMPLETED) { return _getTaskDailyLog(user).played; } else if (taskType == TaskType.GAME_WIN) { return _getTaskDailyLog(user).won; } else if (taskType == TaskType.CUMULATIVE_BETS) { return _getTaskDailyLog(user).totalBet; } return 0; } function _getWeeklyTaskProgress( address user, TaskType taskType ) internal view returns (uint256) { if (taskType == TaskType.GAME_COMPLETED) { return _getTaskWeeklyLog(user).played; } else if (taskType == TaskType.GAME_WIN) { return _getTaskWeeklyLog(user).won; } else if (taskType == TaskType.CUMULATIVE_BETS) { return _getTaskWeeklyLog(user).totalBet; } return 0; } function _checkDailyTaskReward(address user, uint8 index) internal view returns (uint256) { TaskStorage storage $ = _getTaskStorage(); BasicTask storage target = $._dailyTasks[index]; return _getDailyTaskProgress(user, target.task) >= target.requiredValue ? target.rewardAmount : 0; } function _checkWeeklyTaskReward(address user, uint8 index) internal view returns (uint256) { TaskStorage storage $ = _getTaskStorage(); BasicTask storage target = $._weeklyTasks[index]; return _getWeeklyTaskProgress(user, target.task) >= target.requiredValue ? target.rewardAmount : 0; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ITaskErrors } from "../AqErrors.sol"; interface AqTaskCoreInterface is ITaskErrors { enum TaskType { __UNSET__, GAME_COMPLETED, GAME_WIN, CUMULATIVE_BETS } struct BasicTask { TaskType task; uint256 requiredValue; uint256 rewardAmount; } struct PlayerTask { uint8 id; TaskType task; uint256 requiredValue; uint256 currentValue; uint256 rewardAmount; bool claimed; } event Checkin(address indexed player, uint64 timestamp); event PointsAwarded(address indexed player, uint256 amount); event TaskCompleted(address indexed player, uint8 taskId); } interface AqTaskActionInterface is AqTaskCoreInterface { function checkin() external; function claimTaskRewards( address player, uint8[] memory taskIds ) external returns (uint256); } interface AqTaskViewInterface is AqTaskCoreInterface { struct TasksResponse { PlayerTask[] dailyTasks; PlayerTask[] weeklyTasks; } function getTasks(address player) external view returns (TasksResponse memory); struct CheckinStatusResponse { uint256[] rewardAmounts; uint32 consecutiveCount; uint64 lastCheckinAt; bool hasCheckedIn; } function getCheckinStatus(address player) external view returns (CheckinStatusResponse memory); } interface AqTaskClientInterface is AqTaskActionInterface, AqTaskViewInterface {}
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqCore } from "../AqCore.sol"; contract AqTaskIntermediate is AqCore { function _awardPoints(address account, uint256 amount) internal { _increaseReferralPoints(account, amount); _transferPoints(account, amount); emit PointsAwarded(account, amount); } function _runCheckinFlow(address player) internal { if (_hasCheckedIn(player)) revert AlreadyCheckedIn(player, _lastCheckinAt(player)); (/* uint32 count */, uint256 amount) = _checkIn(player, uint64(block.timestamp)); _awardPoints(player, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqTaskActions } from "./AqTaskActions.sol"; import { AqTaskViews } from "./AqTaskViews.sol"; contract AqTasks is AqTaskActions, AqTaskViews { /* ░▀▀█░█░█░█▀█░█░█░█▀▀░█▀▄ ░▄▀░░░█░░█▀▀░█▀█░█▀▀░█▀▄ ░▀▀▀░░▀░░▀░░░▀░▀░▀▀▀░▀░▀ ░░░░█▀▀░█▀█░█▄█░█▀▀░█▀▀ ░░░░█░█░█▀█░█░█░█▀▀░▀▀█ ░░░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀ */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { AqTaskIntermediate } from "./AqTaskIntermediate.sol"; import { AqTaskViewInterface } from "./AqTaskInterfaces.sol"; contract AqTaskViews is AqTaskIntermediate, AqTaskViewInterface { function getCheckinStatus(address player) external view override returns (CheckinStatusResponse memory res) { res.rewardAmounts = _getCheckinRewards(); res.lastCheckinAt = _lastCheckinAt(player); res.hasCheckedIn = _hasCheckedIn(player); res.consecutiveCount = _getConsecutiveCheckinCount(player); // Next day of max consecutive check-in rewards -> restart counts from 0 if (!res.hasCheckedIn && res.consecutiveCount >= res.rewardAmounts.length) { res.consecutiveCount = uint32(res.consecutiveCount % res.rewardAmounts.length); } } function getTasks(address player) external view override returns (TasksResponse memory res) { BasicTask[] memory dailyTasks = _getDailyTasks(); BasicTask[] memory weeklyTasks = _getWeeklyTasks(); res.dailyTasks = new PlayerTask[](dailyTasks.length); res.weeklyTasks = new PlayerTask[](weeklyTasks.length); for (uint8 i = 0; i < dailyTasks.length; i++) { res.dailyTasks[i].id = _toTaskId(i, false); res.dailyTasks[i].task = dailyTasks[i].task; res.dailyTasks[i].requiredValue = dailyTasks[i].requiredValue; res.dailyTasks[i].currentValue = _getDailyTaskProgress(player, dailyTasks[i].task); res.dailyTasks[i].rewardAmount = dailyTasks[i].rewardAmount; res.dailyTasks[i].claimed = _hasClaimedDailyTask(player, i); } for (uint8 i = 0; i < weeklyTasks.length; i++) { res.weeklyTasks[i].id = _toTaskId(i, true); res.weeklyTasks[i].task = weeklyTasks[i].task; res.weeklyTasks[i].requiredValue = weeklyTasks[i].requiredValue; res.weeklyTasks[i].currentValue = _getWeeklyTaskProgress(player, weeklyTasks[i].task); res.weeklyTasks[i].rewardAmount = weeklyTasks[i].rewardAmount; res.weeklyTasks[i].claimed = _hasClaimedWeeklyTask(player, i); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { DENO } from "../AqConstants.sol"; contract AqVaultCore { /// @custom:storage-location erc7201:ace-quest.vault struct VaultStorage { /** @dev GP or gas token (address 0) */ address _cash; /** * @dev Cash => Chips * @dev cashAmount * exchangeRate / DENO >= totalSupply * when exchangeRate = 1e6, 1 Cash can mint 1 Chip * when exchangeRate = 10e6, 1 Cash can mint 10 Chips */ uint256 _exchangeRate; /** * @dev The fees accumulated and withdrawn are recorded in cash units. */ uint256 _feeAccumulated; uint256 _feeWithdrawn; } // keccak256(abi.encode(uint256(keccak256("ace-quest.vault")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant VaultStorageLocation = 0x2fe7b919f916bb84613b1b8aa6f51f333af1525c18ac6821da2e329e8a0ceb00; function _getVaultStorage() private pure returns (VaultStorage storage $) { assembly { $.slot := VaultStorageLocation } } function __AqVault_init_unchained(address cash_) internal { _setVaultCashToken(cash_); _setVaultExchangeRate(DENO); } function _setVaultCashToken(address cash_) internal { VaultStorage storage $ = _getVaultStorage(); $._cash = cash_; } function _setVaultExchangeRate(uint256 rate_) internal { VaultStorage storage $ = _getVaultStorage(); $._exchangeRate = rate_; } function _getVaultCashToken() internal view returns (address) { VaultStorage storage $ = _getVaultStorage(); return $._cash; } function _toCashAmount(uint256 chipAmount) internal view returns (uint256) { VaultStorage storage $ = _getVaultStorage(); return chipAmount * DENO / $._exchangeRate; } function _toChipsAmount(uint256 cashAmount) internal view returns (uint256) { VaultStorage storage $ = _getVaultStorage(); return cashAmount * $._exchangeRate / DENO; } function _increaseAccumulatedFee(uint256 cashAmount) internal { VaultStorage storage $ = _getVaultStorage(); $._feeAccumulated += cashAmount; } function _withdrawAccumulatedFee(uint256 cashAmount) internal { VaultStorage storage $ = _getVaultStorage(); $._feeWithdrawn += cashAmount; } function _feesInVault() internal view returns (uint256 cashAmount) { VaultStorage storage $ = _getVaultStorage(); return $._feeWithdrawn >= $._feeAccumulated ? 0 : $._feeAccumulated - $._feeWithdrawn; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "./Utils.sol"; library BN254 { // use notation from https://datatracker.ietf.org/doc/draft-irtf-cfrg-pairing-friendly-curves/ // // Elliptic curve is defined over a prime field GF(p), with embedding degree k. // Short Weierstrass (SW form) is, for a, b \in GF(p^n) for some natural number n > 0: // E: y^2 = x^3 + a * x + b // // Pairing is defined over cyclic subgroups G1, G2, both of which are of order r. // G1 is a subgroup of E(GF(p)), G2 is a subgroup of E(GF(p^k)). // // BN family are parameterized curves with well-chosen t, // p = 36 * t^4 + 36 * t^3 + 24 * t^2 + 6 * t + 1 // r = 36 * t^4 + 36 * t^3 + 18 * t^2 + 6 * t + 1 // for some integer t. // E has the equation: // E: y^2 = x^3 + b // where b is a primitive element of multiplicative group (GF(p))^* of order (p-1). // A pairing e is defined by taking G1 as a subgroup of E(GF(p)) of order r, // G2 as a subgroup of E'(GF(p^2)), // and G_T as a subgroup of a multiplicative group (GF(p^12))^* of order r. // // BN254 is defined over a 254-bit prime order p, embedding degree k = 12. uint256 public constant P_MOD = 21888242871839275222246405745257275088696311157297823662689037894645226208583; uint256 public constant R_MOD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; struct G1Point { uint X; uint Y; } // Encoding of field elements is: X[0] * z + X[1] struct G2Point { uint[2] X; uint[2] Y; } /// @return the generator of G1 function P1() internal pure returns (G1Point memory) { return G1Point(1, 2); } /// @return the generator of G2 function P2() internal pure returns (G2Point memory) { return G2Point( [ 10857046999023057135944570762232829481370756359578518086990519993285655852781, 11559732032986387107991004021392285783925812861821192530917403151452391805634 ], [ 8495653923123431417604973247489272438418190587263600148770280649306958101930, 4082367875863433681332203403145435568316851327593401208105741076214120093531 ] ); } /// @dev check if a G1 point is Infinity /// @notice precompile bn256Add at address(6) takes (0, 0) as Point of Infinity, /// some crypto libraries (such as arkwork) uses a boolean flag to mark PoI, and /// just use (0, 1) as affine coordinates (not on curve) to represents PoI. function isInfinity(G1Point memory point) internal pure returns (bool result) { assembly { let x := mload(point) let y := mload(add(point, 0x20)) result := and(iszero(x), iszero(y)) } } /// @dev Check if y-coordinate of G1 point is negative. function isYNegative(G1Point memory point) internal pure returns (bool) { return (point.Y << 1) < P_MOD; } /// @return the negation of p, i.e. p.addition(p.negate()) should be zero. function neg(G1Point memory p) internal pure returns (G1Point memory) { if (p.X == 0 && p.Y == 0) return G1Point(0, 0); return G1Point(p.X, P_MOD - (p.Y % P_MOD)); } /// @return r the sum of two points of G1 function add(G1Point memory p1, G1Point memory p2) internal view returns (G1Point memory r) { uint[4] memory input; input[0] = p1.X; input[1] = p1.Y; input[2] = p2.X; input[3] = p2.Y; bool success; assembly { success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success); } /// @return r the product of a point on G1 and a scalar, i.e. /// p == p.scalarMul(1) and p.addition(p) == p.scalarMul(2) for all points p. function scalarMul(G1Point memory p, uint s) internal view returns (G1Point memory r) { uint[3] memory input; input[0] = p.X; input[1] = p.Y; input[2] = s; bool success; assembly { success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success); } /// @return the result of computing the pairing check /// e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 /// For example pairing([P1(), P1().negate()], [P2(), P2()]) should /// return true. function pairing(G1Point[] memory p1, G2Point[] memory p2) internal view returns (bool) { require(p1.length == p2.length); uint elements = p1.length; uint inputSize = elements * 6; uint[] memory input = new uint[](inputSize); for (uint i = 0; i < elements; i++) { input[i * 6 + 0] = p1[i].X; input[i * 6 + 1] = p1[i].Y; input[i * 6 + 2] = p2[i].X[1]; input[i * 6 + 3] = p2[i].X[0]; input[i * 6 + 4] = p2[i].Y[1]; input[i * 6 + 5] = p2[i].Y[0]; } uint[1] memory out; bool success; assembly { success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success); return out[0] != 0; } /// Convenience method for a pairing check for two pairs. function pairingProd2( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2 ) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](2); G2Point[] memory p2 = new G2Point[](2); p1[0] = a1; p1[1] = b1; p2[0] = a2; p2[1] = b2; return pairing(p1, p2); } /// Convenience method for a pairing check for three pairs. function pairingProd3( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2 ) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](3); G2Point[] memory p2 = new G2Point[](3); p1[0] = a1; p1[1] = b1; p1[2] = c1; p2[0] = a2; p2[1] = b2; p2[2] = c2; return pairing(p1, p2); } /// Convenience method for a pairing check for four pairs. function pairingProd4( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2, G1Point memory d1, G2Point memory d2 ) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](4); G2Point[] memory p2 = new G2Point[](4); p1[0] = a1; p1[1] = b1; p1[2] = c1; p1[3] = d1; p2[0] = a2; p2[1] = b2; p2[2] = c2; p2[3] = d2; return pairing(p1, p2); } function g1Serialize(G1Point memory point) internal pure returns (bytes memory) { uint256 mask = 0; // Set the 254-th bit to 1 for infinity // https://docs.rs/ark-serialize/0.3.0/src/ark_serialize/flags.rs.html#117 if (isInfinity(point)) { mask |= 0x4000000000000000000000000000000000000000000000000000000000000000; } // Set the 255-th bit to 1 for positive Y // https://docs.rs/ark-serialize/0.3.0/src/ark_serialize/flags.rs.html#118 if (!isYNegative(point)) { mask = 0x8000000000000000000000000000000000000000000000000000000000000000; } return abi.encodePacked(Utils.reverseEndianness(point.X | mask)); } function fromLeBytesModOrder(bytes memory leBytes) internal pure returns (uint256 ret) { for (uint256 i = 0; i < leBytes.length; i++) { ret = mulmod(ret, 256, R_MOD); ret = addmod(ret, uint256(uint8(leBytes[leBytes.length - 1 - i])), R_MOD); } } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity ^0.8.10; library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "./Utils.sol"; // A Twisted Edwards curve on scalar field of BN254. Also known as Baby-Jubjub. // Modified from: // https://github.com/yondonfu/sol-baby-jubjub/blob/master/contracts/CurveBabyJubJub.sol // https://github.com/arkworks-rs/curves/tree/master/ed_on_bn254 // // Curve information: // * Base field: q = 21888242871839275222246405745257275088548364400416034343698204186575808495617 // * Scalar field: r = 2736030358979909402780800718157159386076813972158567259200215660948447373041 // * Valuation(q - 1, 2) = 28 // * Valuation(r - 1, 2) = 4 // * Curve equation: ax^2 + y^2 =1 + dx^2y^2, where // * a = 1 // * d = 168696/168700 mod q // = 9706598848417545097372247223557719406784115219466060233080913168975159366771 library EdOnBN254 { uint256 internal constant Q = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 internal constant R = 2736030358979909402780800718157159386076813972158567259200215660948447373041; uint256 internal constant E_A = 1; uint256 internal constant E_D = 9706598848417545097372247223557719406784115219466060233080913168975159366771; struct Point { uint256 x; uint256 y; } function generator() internal pure returns (Point memory) { return Point( 0x2B8CFD91B905CAE31D41E7DEDF4A927EE3BC429AAD7E344D59D2810D82876C32, 0x2AAA6C24A758209E90ACED1F10277B762A7C1115DBC0E16AC276FC2C671A861F ); } function zero() internal pure returns (Point memory) { return Point(0, 1); } function eq(Point memory a1, Point memory a2) internal pure returns (bool) { return a1.x == a2.x && a1.y == a2.y; } function add(Point memory a1, Point memory a2) internal view returns (Point memory) { if (a1.x == 0 && a1.y == 0) { return a2; } if (a2.x == 0 && a2.y == 0) { return a1; } uint256 x1x2 = mulmod(a1.x, a2.x, Q); uint256 y1y2 = mulmod(a1.y, a2.y, Q); uint256 dx1x2y1y2 = mulmod(E_D, mulmod(x1x2, y1y2, Q), Q); uint256 x3Num = addmod(mulmod(a1.x, a2.y, Q), mulmod(a1.y, a2.x, Q), Q); uint256 y3Num = submod(y1y2, mulmod(E_A, x1x2, Q), Q); return Point( mulmod(x3Num, inverse(addmod(1, dx1x2y1y2, Q)), Q), mulmod(y3Num, inverse(submod(1, dx1x2y1y2, Q)), Q) ); } function double(Point memory a) internal view returns (Point memory) { return add(a, a); } function scalarMul(Point memory a, uint256 s) internal view returns (Point memory) { uint256 remaining = s; Point memory p = Point(a.x, a.y); Point memory ret = Point(0, 0); while (remaining != 0) { if ((remaining & 1) != 0) { ret = add(ret, p); } p = double(p); remaining = remaining / 2; } return ret; } function neg(Point memory a) internal pure returns (Point memory) { if (a.x == 0 && a.y == 0) return a; return Point(submod(0, a.x, Q), a.y); } function submod(uint256 _a, uint256 _b, uint256 _mod) internal pure returns (uint256) { return addmod(_a, _mod - _b, _mod); } function inverse(uint256 _a) internal view returns (uint256) { return expmod(_a, Q - 2, Q); } function expmod(uint256 _b, uint256 _e, uint256 _m) internal view returns (uint256 o) { assembly { let memPtr := mload(0x40) mstore(memPtr, 0x20) mstore(add(memPtr, 0x20), 0x20) mstore(add(memPtr, 0x40), 0x20) mstore(add(memPtr, 0x60), _b) mstore(add(memPtr, 0x80), _e) mstore(add(memPtr, 0xa0), _m) let success := staticcall(gas(), 0x05, memPtr, 0xc0, memPtr, 0x20) switch success case 0 { revert(0x0, 0x0) } default { o := mload(memPtr) } } } /// @dev Check if y-coordinate of G1 point is negative. function isYNegative(Point memory point) internal pure returns (bool) { return (point.y << 1) < Q; } function serialize(Point memory point) internal pure returns (bytes memory res) { uint256 mask = 0; // Edward curve does not have an infinity flag. // Set the 255-th bit to 1 for positive Y // See: https://github.com/arkworks-rs/algebra/blob/d6365c3a0724e5d71322fe19cbdb30f979b064c8/serialize/src/flags.rs#L148 if (!isYNegative(point)) { mask = 0x8000000000000000000000000000000000000000000000000000000000000000; } return abi.encodePacked(Utils.reverseEndianness(point.x | mask)); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "./BytesLib.sol"; import "./Utils.sol"; import "./BN254.sol"; import "./EdOnBN254.sol"; library Transcript { struct TranscriptData { bytes state; } function appendMessage(TranscriptData memory self, bytes memory message) internal pure { if (message.length < 32) { bytes memory ret = new bytes(32); uint256 start = 32 - message.length; for (uint i = 0; i < message.length; i++) { ret[start + i] = message[i]; } self.state = abi.encodePacked(self.state, ret); } else { self.state = abi.encodePacked(self.state, message); } } function appendUint256(TranscriptData memory self, uint256 u256) internal pure { self.state = abi.encodePacked(self.state, u256); } function getAndAppendChallenge(TranscriptData memory self, uint256 q) internal pure returns (uint256) { bytes32 hash = keccak256(self.state); self.state = abi.encodePacked(hash); return uint256(hash) % q; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; library Utils { function reverseEndianness(uint256 input) internal pure returns (uint256 v) { v = input; // swap bytes v = ((v & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >> 8) | ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8); // swap 2-byte long pairs v = ((v & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >> 16) | ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16); // swap 4-byte long pairs v = ((v & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000) >> 32) | ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32); // swap 8-byte long pairs v = ((v & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000) >> 64) | ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64); // swap 16-byte long pairs v = (v >> 128) | (v << 128); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; library ExternalTranscript { function load(uint256 loc, uint256 num) internal pure { assembly { mstore(loc, 2) // the length mstore(add(loc, 0x20), 0x506c6f6e6b2073687566666c652050726f6f66) mstore(add(loc, 0x40), num) } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import "../libraries/EdOnBN254.sol"; import "../libraries/Transcript.sol"; import "../verifier/ChaumPedersenDLVerifier.sol"; import "../verifier/Groth16Verifier.sol"; struct MaskedCard { uint256 e2X; uint256 e2Y; uint256 e1X; uint256 e1Y; } contract RevealVerifier is Groth16Verifier { function aggregateKeys(EdOnBN254.Point[] memory pks) public view returns (EdOnBN254.Point memory) { EdOnBN254.Point memory joint = pks[0]; for (uint i = 1; i < pks.length; i++) { joint = EdOnBN254.add(joint, pks[i]); } return joint; } function verifyReveal( EdOnBN254.Point memory pk, MaskedCard memory masked, EdOnBN254.Point memory reveal, bytes calldata proofBytes ) public view returns (bool) { require(proofBytes.length == 160, "VR001"); // decode proof to ChaumPedersenDLProof (EdOnBN254.Point, EdOnBN254.Point, Fr) EdOnBN254.Point memory a = EdOnBN254.Point( uint256(bytes32(proofBytes[0:32])), uint256(bytes32(proofBytes[32:64])) ); EdOnBN254.Point memory b = EdOnBN254.Point( uint256(bytes32(proofBytes[64:96])), uint256(bytes32(proofBytes[96:128])) ); uint256 r = uint256(bytes32(proofBytes[128:160])); ChuamPerdensenDLProof memory proof = ChuamPerdensenDLProof(a, b, r); ChuamPerdensenDLParameters memory parameters = ChuamPerdensenDLParameters( EdOnBN254.Point(masked.e1X, masked.e1Y), EdOnBN254.generator() ); return ChuamPerdensenDLVerifier.verify(parameters, "Revealing", reveal, pk, proof); } function verifyRevealWithSnark( uint256[7] calldata _pi, // _pi = [mask.e1.x, mask.e1.y, reveal.x, reveal.y, pk.x, pk.y, challenge] uint256[5] calldata _proof, uint256[8] calldata _zkproof // _zkproof = [a, b, c] ) public view returns (bool) { assembly { mstore(mload(0x40), 0x52657665616c696e67) mstore(add(mload(0x40), 0x20), 0x444c) mstore(add(mload(0x40), 0x40), calldataload(_pi)) mstore(add(mload(0x40), 0x60), calldataload(add(_pi, 0x20))) mstore( add(mload(0x40), 0x80), 19698561148652590122159747500897617769866003486955115824547446575314762165298 ) mstore( add(mload(0x40), 0xa0), 19298250018296453272277890825869354524455968081175474282777126169995084727839 ) mstore(add(mload(0x40), 0xc0), calldataload(add(_pi, 0x40))) mstore(add(mload(0x40), 0xe0), calldataload(add(_pi, 0x60))) mstore(add(mload(0x40), 0x100), calldataload(add(_pi, 0x80))) mstore(add(mload(0x40), 0x120), calldataload(add(_pi, 0xa0))) mstore(add(mload(0x40), 0x140), calldataload(_proof)) mstore(add(mload(0x40), 0x160), calldataload(add(_proof, 0x20))) mstore(add(mload(0x40), 0x180), calldataload(add(_proof, 0x40))) mstore(add(mload(0x40), 0x1a0), calldataload(add(_proof, 0x60))) let r := mod( keccak256(mload(0x40), 0x1c0), 2736030358979909402780800718157159386076813972158567259200215660948447373041 ) switch eq(r, calldataload(add(_pi, 0xc0))) case 0 { mstore(0, 0) return(0, 0x20) } case 1 { } default { mstore(0, 0) return(0, 0x20) } } return verifyProof(_zkproof, _pi); } function unmask( MaskedCard memory masked, EdOnBN254.Point[] memory reveals ) public view returns (EdOnBN254.Point memory) { EdOnBN254.Point memory aggregate = reveals[0]; for (uint i = 1; i < reveals.length; i++) { aggregate = EdOnBN254.add(aggregate, reveals[i]); } return EdOnBN254.add(EdOnBN254.Point(masked.e2X, masked.e2Y), EdOnBN254.neg(aggregate)); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import "../verifier/PlonkVerifier.sol"; import "./ExternalTranscript.sol"; import "./VerifierKey_20.sol"; abstract contract ShuffleVerifier is PlonkVerifier { address _extraVk1; address _extraVk2; function(uint256, uint256) pure _verifyKey; constructor(address _vk1, address _vk2) { _extraVk1 = _vk1; _extraVk2 = _vk2; } // Before call verifyShuffle need init: _verifyKey = VerifierKey.load; function verifyShuffle( bytes calldata _proof, uint256[] calldata _publicKeyInput, uint256[] calldata _publicKeyCommitment ) public view returns (bool) { _verifyKey(CM_Q0_X_LOC, PI_POLY_RELATED_LOC); ExternalTranscript.load(EXTERNAL_TRANSCRIPT_LENGTH_LOC, _publicKeyInput.length / 8); // The scalar field of BN254. uint256 r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; // Load the proof. assembly { let data_ptr := add(calldataload(0x04), 0x24) mstore(CM_W0_X_LOC, mod(calldataload(add(data_ptr, 0x00)), r)) mstore(CM_W0_Y_LOC, mod(calldataload(add(data_ptr, 0x20)), r)) mstore(CM_W1_X_LOC, mod(calldataload(add(data_ptr, 0x40)), r)) mstore(CM_W1_Y_LOC, mod(calldataload(add(data_ptr, 0x60)), r)) mstore(CM_W2_X_LOC, mod(calldataload(add(data_ptr, 0x80)), r)) mstore(CM_W2_Y_LOC, mod(calldataload(add(data_ptr, 0xa0)), r)) mstore(CM_W3_X_LOC, mod(calldataload(add(data_ptr, 0xc0)), r)) mstore(CM_W3_Y_LOC, mod(calldataload(add(data_ptr, 0xe0)), r)) mstore(CM_W4_X_LOC, mod(calldataload(add(data_ptr, 0x100)), r)) mstore(CM_W4_Y_LOC, mod(calldataload(add(data_ptr, 0x120)), r)) mstore(CM_W0_SEL_X_LOC, mod(calldataload(add(data_ptr, 0x140)), r)) mstore(CM_W0_SEL_Y_LOC, mod(calldataload(add(data_ptr, 0x160)), r)) mstore(CM_W1_SEL_X_LOC, mod(calldataload(add(data_ptr, 0x180)), r)) mstore(CM_W1_SEL_Y_LOC, mod(calldataload(add(data_ptr, 0x1a0)), r)) mstore(CM_W2_SEL_X_LOC, mod(calldataload(add(data_ptr, 0x1c0)), r)) mstore(CM_W2_SEL_Y_LOC, mod(calldataload(add(data_ptr, 0x1e0)), r)) mstore(CM_T0_X_LOC, mod(calldataload(add(data_ptr, 0x200)), r)) mstore(CM_T0_Y_LOC, mod(calldataload(add(data_ptr, 0x220)), r)) mstore(CM_T1_X_LOC, mod(calldataload(add(data_ptr, 0x240)), r)) mstore(CM_T1_Y_LOC, mod(calldataload(add(data_ptr, 0x260)), r)) mstore(CM_T2_X_LOC, mod(calldataload(add(data_ptr, 0x280)), r)) mstore(CM_T2_Y_LOC, mod(calldataload(add(data_ptr, 0x2a0)), r)) mstore(CM_T3_X_LOC, mod(calldataload(add(data_ptr, 0x2c0)), r)) mstore(CM_T3_Y_LOC, mod(calldataload(add(data_ptr, 0x2e0)), r)) mstore(CM_T4_X_LOC, mod(calldataload(add(data_ptr, 0x300)), r)) mstore(CM_T4_Y_LOC, mod(calldataload(add(data_ptr, 0x320)), r)) mstore(CM_Z_X_LOC, mod(calldataload(add(data_ptr, 0x340)), r)) mstore(CM_Z_Y_LOC, mod(calldataload(add(data_ptr, 0x360)), r)) mstore(PRK_3_EVAL_ZETA_LOC, mod(calldataload(add(data_ptr, 0x380)), r)) mstore(PRK_4_EVAL_ZETA_LOC, mod(calldataload(add(data_ptr, 0x3a0)), r)) mstore(W_POLY_EVAL_ZETA_0_LOC, mod(calldataload(add(data_ptr, 0x3c0)), r)) mstore(W_POLY_EVAL_ZETA_1_LOC, mod(calldataload(add(data_ptr, 0x3e0)), r)) mstore(W_POLY_EVAL_ZETA_2_LOC, mod(calldataload(add(data_ptr, 0x400)), r)) mstore(W_POLY_EVAL_ZETA_3_LOC, mod(calldataload(add(data_ptr, 0x420)), r)) mstore(W_POLY_EVAL_ZETA_4_LOC, mod(calldataload(add(data_ptr, 0x440)), r)) mstore(W_POLY_EVAL_ZETA_OMEGA_0_LOC, mod(calldataload(add(data_ptr, 0x460)), r)) mstore(W_POLY_EVAL_ZETA_OMEGA_1_LOC, mod(calldataload(add(data_ptr, 0x480)), r)) mstore(W_POLY_EVAL_ZETA_OMEGA_2_LOC, mod(calldataload(add(data_ptr, 0x4a0)), r)) mstore(Z_EVAL_ZETA_OMEGA_LOC, mod(calldataload(add(data_ptr, 0x4c0)), r)) mstore(S_POLY_EVAL_ZETA_0_LOC, mod(calldataload(add(data_ptr, 0x4e0)), r)) mstore(S_POLY_EVAL_ZETA_1_LOC, mod(calldataload(add(data_ptr, 0x500)), r)) mstore(S_POLY_EVAL_ZETA_2_LOC, mod(calldataload(add(data_ptr, 0x520)), r)) mstore(S_POLY_EVAL_ZETA_3_LOC, mod(calldataload(add(data_ptr, 0x540)), r)) mstore(Q_ECC_POLY_EVAL_ZETA_LOC, mod(calldataload(add(data_ptr, 0x560)), r)) mstore(W_SEL_POLY_EVAL_ZETA_0_LOC, mod(calldataload(add(data_ptr, 0x580)), r)) mstore(W_SEL_POLY_EVAL_ZETA_1_LOC, mod(calldataload(add(data_ptr, 0x5a0)), r)) mstore(W_SEL_POLY_EVAL_ZETA_2_LOC, mod(calldataload(add(data_ptr, 0x5c0)), r)) mstore(OPENING_ZETA_X_LOC, mod(calldataload(add(data_ptr, 0x5e0)), r)) mstore(OPENING_ZETA_Y_LOC, mod(calldataload(add(data_ptr, 0x600)), r)) mstore(OPENING_ZETA_OMEGA_X_LOC, mod(calldataload(add(data_ptr, 0x620)), r)) mstore(OPENING_ZETA_OMEGA_Y_LOC, mod(calldataload(add(data_ptr, 0x640)), r)) } // Load the public inputs. assembly { let pi_ptr := add(calldataload(0x24), 0x04) let pi_length := calldataload(add(pi_ptr, 0x00)) let store_ptr := add(PI_POLY_RELATED_LOC, 0x20) for { let i := 0 } lt(i, pi_length) { i := add(i, 1) } { mstore(add(store_ptr, mul(i, 0x20)), calldataload(add(add(pi_ptr, 0x20), mul(i, 0x20)))) } } // Load the public key commitment. assembly { let pk_ptr := add(calldataload(0x44), 0x24) mstore(CM_SHUFFLE_PUBLIC_KEY_0_X_LOC, mod(calldataload(add(pk_ptr, 0x00)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_0_Y_LOC, mod(calldataload(add(pk_ptr, 0x20)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_1_X_LOC, mod(calldataload(add(pk_ptr, 0x40)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_1_Y_LOC, mod(calldataload(add(pk_ptr, 0x60)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_2_X_LOC, mod(calldataload(add(pk_ptr, 0x80)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_2_Y_LOC, mod(calldataload(add(pk_ptr, 0xa0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_3_X_LOC, mod(calldataload(add(pk_ptr, 0xc0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_3_Y_LOC, mod(calldataload(add(pk_ptr, 0xe0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_4_X_LOC, mod(calldataload(add(pk_ptr, 0x100)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_4_Y_LOC, mod(calldataload(add(pk_ptr, 0x120)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_5_X_LOC, mod(calldataload(add(pk_ptr, 0x140)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_5_Y_LOC, mod(calldataload(add(pk_ptr, 0x160)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_6_X_LOC, mod(calldataload(add(pk_ptr, 0x180)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_6_Y_LOC, mod(calldataload(add(pk_ptr, 0x1a0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_7_X_LOC, mod(calldataload(add(pk_ptr, 0x1c0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_7_Y_LOC, mod(calldataload(add(pk_ptr, 0x1e0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_8_X_LOC, mod(calldataload(add(pk_ptr, 0x200)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_8_Y_LOC, mod(calldataload(add(pk_ptr, 0x220)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_9_X_LOC, mod(calldataload(add(pk_ptr, 0x240)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_9_Y_LOC, mod(calldataload(add(pk_ptr, 0x260)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_10_X_LOC, mod(calldataload(add(pk_ptr, 0x280)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_10_Y_LOC, mod(calldataload(add(pk_ptr, 0x2a0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_11_X_LOC, mod(calldataload(add(pk_ptr, 0x2c0)), r)) mstore(CM_SHUFFLE_PUBLIC_KEY_11_Y_LOC, mod(calldataload(add(pk_ptr, 0x2e0)), r)) } return verifyShuffleProof(_extraVk1, _extraVk2); } }
// SPDX-License-Identifier: UNLICENSED // Generated file from uzkge/gen-params, DONOT edit! pragma solidity ^0.8.20; library VerifierKey_20 { function load(uint256 vk, uint256 pi) internal pure { assembly { // verifier key mstore(add(vk, 0x0), 0x13b5e61805d5bbf40a999d4e8d1ae70cb96a36a7d7d88a1c39a79f4bd9148eea) mstore(add(vk, 0x20), 0x2ac2ba68e291bb40dbabb15636366b390a498265d75f3191ec16b5068e4bc1b5) mstore(add(vk, 0x40), 0x254d5975d680bdbf0535012170f11dffae10a648091f2d222f0d042801c9eb77) mstore(add(vk, 0x60), 0x15ef63c63d6d12958ee3cc64ff0bdf8060dc12e15a3aed51250f7c844aee154d) mstore(add(vk, 0x80), 0x21c3ecb6cd2413b23f683dc0072f7b7a7cf2b66692031c2cf2d9b9d03ca72dbf) mstore(add(vk, 0xa0), 0x2a120c052934a46a3e529b92e04155a70b3b3767a03fbe20e2c483c581486fa5) mstore(add(vk, 0xc0), 0x2338558704b09ad96399dd11a1cdc9b292378eaadb7d96ac1d1d13e0f942bdda) mstore(add(vk, 0xe0), 0x289f97e0c47111b4e2f0db2cc4c9c9e58f0f4a94faa026aeee3793768efb306e) mstore(add(vk, 0x100), 0x05b1bdd9c45d47b93a670c228d950918d094ad8f628e6f8c4c3f509e542b6d7f) mstore(add(vk, 0x120), 0x010867defb0f42fa33be74892f4013796195b8dc768e1aa2074189c47d5942b1) mstore(add(vk, 0x140), 0x05b1bdd9c45d47b93a670c228d950918d094ad8f628e6f8c4c3f509e542b6d7f) mstore(add(vk, 0x160), 0x010867defb0f42fa33be74892f4013796195b8dc768e1aa2074189c47d5942b1) mstore(add(vk, 0x180), 0x2211f2fcf72c9682271dc6726e7f854811cfe6a87282932f637b0b2a513395c6) mstore(add(vk, 0x1a0), 0x1fe594ee7ce38aac5890fb70d2a6d913ad4707ca534b5d7a7fd9167194c246fc) mstore(add(vk, 0x1c0), 0x2fba14bc6d29ee1fd4c83ac1c40f2f0affdfe297376eb307d1bbeb1559284ffc) mstore(add(vk, 0x1e0), 0x0e42f7b0fe5e1992c371f9cdc886f2912080bc0fce3db3799f9b9c13e1e035b8) mstore(add(vk, 0x200), 0x080e633e67df3593c1bf695dac59a2a95dfaee394396052aa6f6061dad99b347) mstore(add(vk, 0x220), 0x0bb7c4f7e3c81a2b87f98c863052dcf988313a9ca1495fc54f6b9f87fb469e86) mstore(add(vk, 0x240), 0x03d7eb3b93d77009247d1f93bbd2798dc5af834c9cbebcec2853d0d011d6f54e) mstore(add(vk, 0x260), 0x206c5f4c848a9042a65ec945ac56249a8cf9550a0e57b0a744276acdd1d461af) mstore(add(vk, 0x280), 0x232460896fa3155d6c7a409f90e11a9e8a6637a8991120f2512d0687d34740c4) mstore(add(vk, 0x2a0), 0x00c31fe6ba11ef5c18a1befc64534dc5104886b1fcb848410e2e5c1146c8914f) mstore(add(vk, 0x2c0), 0x04f04f66cc07bdf391e1c60a329d9fc037481d91510e375233dd0a73b1f447db) mstore(add(vk, 0x2e0), 0x12116a1f867bdb640293128da9910c966a5c79ba8d23e93d4dc934e299993f39) mstore(add(vk, 0x300), 0x182e5904f68263a3bbe83512e33b62ab81d92c1efaf03e25d39d9fff81b60a35) mstore(add(vk, 0x320), 0x22a2ab3bd7473030e9c81ba661b276c10712cb5af18b0ec224e207a7daebc3b9) mstore(add(vk, 0x340), 0x2a3552215e1642082588f682e9faa317c08851ec45d28f05d4868e4ef746bb9d) mstore(add(vk, 0x360), 0x013aa92a8efb15f879e4d1a0ef686226f89f32d50b5df9105ee9573693352bb7) mstore(add(vk, 0x380), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3a0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3c0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3e0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x400), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x420), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x440), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x460), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x480), 0x1135c7377f75d0dcc677da46a7d1daf5c07cd1200c0de4ef072bc6dbc4d4459d) mstore(add(vk, 0x4a0), 0x21a00c09aa939ab2e531ff9468899515e4f66d5fadf55bd11f3bb7ad6df4af31) mstore(add(vk, 0x4c0), 0x25bde92c518fcab5575072fb3ef0d9f35aef52a529cb4bb4d9d7cde56f8ed6d7) mstore(add(vk, 0x4e0), 0x0399c72ed68520ffc282da59e8911e92fa907f9e8113b0386167269200de1d63) mstore(add(vk, 0x500), 0x15156c29e5651a04c60ffae60f4ca92635f347b415f380046f96fce7b9e985bb) mstore(add(vk, 0x520), 0x2b88848295d6dc228bbb1f703df8f1ebfb4343114b69b407d131d521b02e40c0) mstore(add(vk, 0x540), 0x1ee65f5f9dc91fdd5423722e2e5879822cd37353480a691025710d1cdd10d6b0) mstore(add(vk, 0x560), 0x01085d0ce87a0493720f8ad1168af18776d2962d896bdaa20085511591bce770) mstore(add(vk, 0x580), 0x2314c3b6d169b89f2d5bb4a5df77d8c8173ffb2c70ec5dc7f640825943819b73) mstore(add(vk, 0x5a0), 0x13f20518ab13a30b22ba1364e4853c39f7cc026c8184ecc03024a56848121b2d) mstore(add(vk, 0x5c0), 0x08629513703963bcb5fd13d212827c345772a0abbb375eea651423bbe0937ffe) mstore(add(vk, 0x5e0), 0x0bae83b1168b35086890e01381742dbce1aa03e8a78ae857d1eeaabc9092f1e0) mstore(add(vk, 0x600), 0x1d842e80c98bb25520b3340090c47fe865b72f36febe14c9ffb8098c15f972a3) mstore(add(vk, 0x620), 0x089c5331b473880f79d8c620f56c4d8f56a90b93ff9d866dc6c1214b46e88e2f) mstore(add(vk, 0x640), 0x1e4817d592d9a84ce38fec9aca102f2547714ca22dd22d03ea1ea5562e933fb1) mstore(add(vk, 0x660), 0x3020447a26a64250bf17b4fe4e288c2bf94091d065c983418d4fe4f0dd21d5a2) mstore(add(vk, 0x680), 0x0d8e555dbf81463279d4125c6c862c0a753d76113221bed3166e8e8eaf0498ef) mstore(add(vk, 0x6a0), 0x18cf7911ddd2ac1b254cb3a6435de42a318a45470a580dbae84cb9fa24ffd4d9) mstore(add(vk, 0x6c0), 0x18b1ce4b8f61476e70afd2259f8f35ec18e0170c353592ad735f0176cbda55a9) mstore(add(vk, 0x6e0), 0x1ef5569839301446d276b66507dcdbda41d58dc0353587b5742591d4ab9de523) mstore(add(vk, 0x700), 0x2b467c2521b21c0c05493cdb8320445b2c7e9ddae43f92adf7833a34a764eaad) mstore(add(vk, 0x720), 0x2425ebd93df694c046af1fc24f53fa8435501cc0e25dd24ccd5966ffa3e25978) mstore(add(vk, 0x740), 0x12c932e4c9fece70d76f0a4459362f9229dfc05b247e105b8fd541720f7e6c90) mstore(add(vk, 0x760), 0x059595fa5350a4482ef005bffafc8cacd7b9fdd66397d3752c0e6fe85295656a) mstore(add(vk, 0x780), 0x1ee88db8d29f8ffcd4095cffc04479b6c6049f4f7b9840f649d93e9f74b47a1c) mstore(add(vk, 0x7a0), 0x147b9aa28a30aaf30168d29011ef532e45ff53d76c228020f9a5982cae7c71d3) mstore(add(vk, 0xac0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0xae0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0xb00), 0x0000000000000000000000000000000000000000000000000000000000000001) mstore(add(vk, 0xb20), 0x2f8dd1f1a7583c42c4e12a44e110404c73ca6c94813f85835da4fb7bb1301d4a) mstore(add(vk, 0xb40), 0x2042a587a90c187b0a087c03e29c968b950b1db26d5c82d666905a6895790c0a) mstore(add(vk, 0xb60), 0x2db4944e13e6e33cf0ef0734796ff332d73b5fa160dca733bf529e9b758e4960) mstore(add(vk, 0xb80), 0x1d9e3a4aaf01052d9925138dc6d7d05aa614e311040142458b045d0053d22f46) mstore(add(vk, 0xba0), 0x0000000000000000000000000000000000000000000000000000000000000001) mstore(add(vk, 0xbc0), 0x0931d596de2fd10f01ddd073fd5a90a976f169c76f039bb91c4775720042d43a) mstore(add(vk, 0xbe0), 4096) /// public inputs length mstore(add(pi, 0x0), 160) } } }
// SPDX-License-Identifier: UNLICENSED // Generated file from uzkge/gen-params, DONOT edit! pragma solidity ^0.8.20; library VerifierKey_52 { function load(uint256 vk, uint256 pi) internal pure { assembly { // verifier key mstore(add(vk, 0x0), 0x28c5a05948fd549d53de629a79f129caa682a1337b067c77611360d585b3e998) mstore(add(vk, 0x20), 0x08c398bbd63af8cf512091bea69e14f507f1a44bff445a9440beb6869b67a75c) mstore(add(vk, 0x40), 0x1e7482ce70f3ef06f5483c6c11a3b694b91aa0afc4b9d3523bd33ec3bda295f4) mstore(add(vk, 0x60), 0x0ec946d77568076e9264f91230746b67a04bb72687c58011facd26785d1ff8e2) mstore(add(vk, 0x80), 0x100660542c99ffa8748a0c519f8307912a13ba222126fbd4d54c0c7af1f3746a) mstore(add(vk, 0xa0), 0x23ff918657c858f91a533b85531e930b9d592dab96c21357fe02aab551d1209c) mstore(add(vk, 0xc0), 0x2cd225b7a20b907480de67ca23716199a198bd9fb2ad2ddd5644eadb22d011f2) mstore(add(vk, 0xe0), 0x18ab4df59571e3da621081bca820830e6078fd6ef947246e69dfc089800497e0) mstore(add(vk, 0x100), 0x03e6e6213ae6f5af9cce6789967df5e2453e078b1514e960b73549c2edd6590d) mstore(add(vk, 0x120), 0x2a17f9a6ef9711cc545fe20677106abfdeef7dbc7c6ee23d912068924e4371bc) mstore(add(vk, 0x140), 0x03e6e6213ae6f5af9cce6789967df5e2453e078b1514e960b73549c2edd6590d) mstore(add(vk, 0x160), 0x2a17f9a6ef9711cc545fe20677106abfdeef7dbc7c6ee23d912068924e4371bc) mstore(add(vk, 0x180), 0x0d92087ed138ef7084c5d84d66a84c4a20422fb4c469a008c984a1adece0b15b) mstore(add(vk, 0x1a0), 0x20aa07e07641553ec6d561e877890ca3115f7c7c22d5a5053ec1256dfeb6d322) mstore(add(vk, 0x1c0), 0x2ce385450737cbf0e4878019312dac30c7aa4b7940d94087caedce7e50eacf87) mstore(add(vk, 0x1e0), 0x21a0c7069a8164f9806a79626fdd80b528e411abf1fc07f611ebc04dbb2c024a) mstore(add(vk, 0x200), 0x26c24e20a03ec770dcf9e4a83d1266860760184046d74d40a09a619c9bbc91c7) mstore(add(vk, 0x220), 0x2b1f43a5c3d41b5a701bc0e95731d99cc2d1869fde91c95e6758d23bafb90a5e) mstore(add(vk, 0x240), 0x2165f5038c92cd92c671191340c0eab66752b25a84a63edaf45d8266e1a07f8c) mstore(add(vk, 0x260), 0x2e3860091a2b9f3bc5206f7411c47d6b6867d42da9b22ee335c55c25b39c182e) mstore(add(vk, 0x280), 0x05a13b380d6d1495430364e98a87af419d35fc55a1f5fa2ff599c79333523206) mstore(add(vk, 0x2a0), 0x15636e4cb2a9472bc7d996d43c5d4787146f957dfab27aeeb9b2167e1b763189) mstore(add(vk, 0x2c0), 0x27f35458e4dde8ca7495db9d2ac901152231de62856f59584e71c5af59cc88bb) mstore(add(vk, 0x2e0), 0x0ba6cbd948cc51dd9bfb97b882337d91fac49772ad023b698ecee67f8c9fbe2b) mstore(add(vk, 0x300), 0x190316470995a13d31c089fcfac23021683b0cadec2671abe00835b4c3cdb318) mstore(add(vk, 0x320), 0x2e20293c31270cbff5d91c7340d88f48955a62106feecbb52e50efad5949d3e3) mstore(add(vk, 0x340), 0x2206e855757723f5fca2acb5c81dd2add2e838173151b3429003ef7b83f19445) mstore(add(vk, 0x360), 0x0edfcc95d0a9269c22a091acf4093796b7769c75dfa31d5e18f37bfe6479e8ac) mstore(add(vk, 0x380), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3a0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3c0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x3e0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x400), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x420), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x440), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x460), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0x480), 0x0ebb75da484e9bbf7487f94111cd03dc3161ef60523694d76c8b54b0f06b1a20) mstore(add(vk, 0x4a0), 0x0883657d7885454656c13592f4bbdea8341941856d489cc5056fe570b81e2f2d) mstore(add(vk, 0x4c0), 0x2891e655f31af890a9751a28e69513ce8db65529fab7f75a0b48ded0817d0766) mstore(add(vk, 0x4e0), 0x1983831f5c69bb1ffdf5c272f2e93ddbff12960af564c0d3b8b505b9cd3bf618) mstore(add(vk, 0x500), 0x2e7d1f072acd3e91f526464d4790d9068bf12eaa3f2ddc002939198aeeef54dc) mstore(add(vk, 0x520), 0x30631f135e5593558205642237c88124eca93c6ddad82b5356c0a7d74835e1ed) mstore(add(vk, 0x540), 0x0061418ba09d8a781fc335501a988aae74957d8fce5455bf382c62e490d258ff) mstore(add(vk, 0x560), 0x00963d1c2fd8ab1759885db4ae5ad7edd459b4e4b30f5853b7c8a0ec835d315b) mstore(add(vk, 0x580), 0x13554d410926b3bf66a3b957aa8028321daaa06a879ebb94cc85e76d45a723cc) mstore(add(vk, 0x5a0), 0x091d4ce288a7469b978703815885d18f986f5e308ece7e2e72b18014b59f6e59) mstore(add(vk, 0x5c0), 0x25b76fc1306c1fbe1def496f707b6dcfb3539b523f99b8b384602cd3c8e322c3) mstore(add(vk, 0x5e0), 0x1e9aae10d0eb1a9ec1ca749f9fb8673a52f867f6413dbfd350963244a3ea93f5) mstore(add(vk, 0x600), 0x1e15152765faacea8e4ec5aca0db2deb01cbfbf19347512d78504d8c77033ded) mstore(add(vk, 0x620), 0x2f9d0f189ebe2c9d694339422a1b02261d79b53272911ce008ee0496a54bf5f3) mstore(add(vk, 0x640), 0x140e10f50e171670550b66cc352aa0038a3627a858abc81237622b659d9bd59c) mstore(add(vk, 0x660), 0x14d3b70464244c956e5f4afbfcd874656746302d7120fe85040eb3d9a9148174) mstore(add(vk, 0x680), 0x2622fdb97c24280d67028057d02bfb1520065caba5fb90403436c5cb86e7b384) mstore(add(vk, 0x6a0), 0x1e7a757a8e5621989975d493b7cce2ac6afed508f2045a148269f1cf39ff979e) mstore(add(vk, 0x6c0), 0x254e7ca9022f9d6c0e3559d77a87c3a7acfd1a5f9da4dec18d7323557ee222df) mstore(add(vk, 0x6e0), 0x0d56e0b7c7d27a2859bc73af66cabff9a55aa88d053e090b1dfb53f1ee6dc797) mstore(add(vk, 0x700), 0x2652d19ba1a130db21a1ebeaf107ff70b2e93608fd9abd5ad7ee2b34938f204e) mstore(add(vk, 0x720), 0x0d6554958ba2ed1561ed65a3fc5119a6cc4d7c11d80ba6d244d3b04db09b0449) mstore(add(vk, 0x740), 0x2eb6571642d84225dfe57ff0ba2add9042525c71e779673dec006206831d9c3b) mstore(add(vk, 0x760), 0x16dfb65d764184dceed3b8635df3f31558617f6d92176610817319968484bea1) mstore(add(vk, 0x780), 0x0797ac6a2b6d56830b3f45f062eee580772ece68e5493f2ded0b902925a17b38) mstore(add(vk, 0x7a0), 0x05ee97c14a2edb11dbec3ce61e4f9ff53b389b466638bb60683fcd754fcbdf23) mstore(add(vk, 0xac0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0xae0), 0x0000000000000000000000000000000000000000000000000000000000000000) mstore(add(vk, 0xb00), 0x0000000000000000000000000000000000000000000000000000000000000001) mstore(add(vk, 0xb20), 0x2f8dd1f1a7583c42c4e12a44e110404c73ca6c94813f85835da4fb7bb1301d4a) mstore(add(vk, 0xb40), 0x2042a587a90c187b0a087c03e29c968b950b1db26d5c82d666905a6895790c0a) mstore(add(vk, 0xb60), 0x2db4944e13e6e33cf0ef0734796ff332d73b5fa160dca733bf529e9b758e4960) mstore(add(vk, 0xb80), 0x1d9e3a4aaf01052d9925138dc6d7d05aa614e311040142458b045d0053d22f46) mstore(add(vk, 0xba0), 0x0000000000000000000000000000000000000000000000000000000000000001) mstore(add(vk, 0xbc0), 0x2d965651cdd9e4811f4e51b80ddca8a8b4a93ee17420aae6adaa01c2617c6e85) mstore(add(vk, 0xbe0), 16384) /// public inputs length mstore(add(pi, 0x0), 416) } } }
// SPDX-License-Identifier: UNLICENSED // Generated file from uzkge/gen-params, DONOT edit! pragma solidity ^0.8.20; contract VerifierKeyExtra1_52 { uint256[416] public PI_POLY_INDICES_LOC; constructor() { // The public constrain variables indices. PI_POLY_INDICES_LOC[0] = 0x006fab49b869ae62001deac878b2667bd31bf3e28e3a2d764aa49b8d9bbdd310; PI_POLY_INDICES_LOC[1] = 0x2b1f91b84d97e711601151e8e7f35b08d1eb8811beaa402a1a446ba9b63d273c; PI_POLY_INDICES_LOC[2] = 0x0931d596de2fd10f01ddd073fd5a90a976f169c76f039bb91c4775720042d43a; PI_POLY_INDICES_LOC[3] = 0x253edb2f4f98f08a8efbab9f6bbb3bb50ff983567ddb991f4d003a0dac62cac3; PI_POLY_INDICES_LOC[4] = 0x21f45e361a74c6f6c33c43a8f978577e3f42dcb7a1dea925052a02bec35cb714; PI_POLY_INDICES_LOC[5] = 0x0f68ad10e993eeac2b65f0b3eadd0d760f8f8b5cc3cf55ce48799bbacbb68e8d; PI_POLY_INDICES_LOC[6] = 0x13d1dd0be26eee52f593ff7d83bf1a7cff26cee8855d5a4b27b447cf84a989a8; PI_POLY_INDICES_LOC[7] = 0x03fb67efce69e0f87166a23fb5efe4004c301adc6a57a98e66c676438fdea7f9; PI_POLY_INDICES_LOC[8] = 0x26c0fddccc98cea9bab3618a73918eb4dd4ac938316631620200f41d1fd0f854; PI_POLY_INDICES_LOC[9] = 0x1178cd26585012825d8eb2edfcfac6a47d3cea0658b12e5fac495da2893c79d2; PI_POLY_INDICES_LOC[10] = 0x2bb78f0ab329965eb9c9b91074d9a410335a0eef2ac77c3da81b6ae230406dbe; PI_POLY_INDICES_LOC[11] = 0x07e6a574bbd9f8696c97225996fdc645250f43a0a217c93379a24882116f374c; PI_POLY_INDICES_LOC[12] = 0x053937385d086f263fb447b192f5c0f2f7389b554d3c3f91171f006c36222642; PI_POLY_INDICES_LOC[13] = 0x258765845bc8a40218e27e0db5aa11288c21cf04147cea50eaa61341e6f212c3; PI_POLY_INDICES_LOC[14] = 0x251c48216d3a33b1aa5d6d86e04d9663e933c53a8a844a5683beb8ffe402dc10; PI_POLY_INDICES_LOC[15] = 0x2e5bd9ad505ab112ca7819bb4edbc3fbcc7ca90584a8c0a4d60475ba32d7f5cd; PI_POLY_INDICES_LOC[16] = 0x2d8952e9cb5e9ce7e0df64f09af94d2f66e049f78538c6c0f21456dd1ceb483e; PI_POLY_INDICES_LOC[17] = 0x29bfb2f3f552324c7f3ca51d839aa42ea69164afafbe506374b2355416e8767e; PI_POLY_INDICES_LOC[18] = 0x2d479b371e50ad41175ec82300c73645d4d4535b04f61ef90f65e0673077e2f4; PI_POLY_INDICES_LOC[19] = 0x04de4ca1cde24d876edbc9f2a1e5017f4d1499bd7555fcfb010733303a684a3c; PI_POLY_INDICES_LOC[20] = 0x1552f6f2aee2b9cfb808198410f77a8b7f683cf09c9e96a3e2a318a8d98cc351; PI_POLY_INDICES_LOC[21] = 0x26f5ac5221eb65bd37d6095a566be415da961aba2bc0b55ca69ef938b7fcde87; PI_POLY_INDICES_LOC[22] = 0x0adb432932d1f87f0f38c282c21ee4c120801d9c503987944270526e39865b26; PI_POLY_INDICES_LOC[23] = 0x10b40b99e1f351c7a16bb7abe76bf8569707159ffaa66e68b7771af12610e8d1; PI_POLY_INDICES_LOC[24] = 0x0f1bb9f37d50445372c0d3d7bf6b060eeb48bda30cf1391653c895e3600f1af5; PI_POLY_INDICES_LOC[25] = 0x1e1fc2f50b8a78a6b862cba88250fb6626a1628d37056476f004a08ed96aa2fa; PI_POLY_INDICES_LOC[26] = 0x033376d842127360023229d9ff25e8ccab17c432bf1e391e78f254145663778c; PI_POLY_INDICES_LOC[27] = 0x05e04fd193617147fd4710fad7d5c36e5dd9634197944a95a1b99dfc7d4c7470; PI_POLY_INDICES_LOC[28] = 0x16ef944ab10af3f6383a8ea1111084fe850d18d411c01a3bff89cd888d7c5504; PI_POLY_INDICES_LOC[29] = 0x249e8bd938f16e5d0f5e40517c20b4f33b6766d5d2ad9546f73f50b701ada5af; PI_POLY_INDICES_LOC[30] = 0x09df8552182b39aadffb843bdf319aa5ceebcdcdbe72652abf909dc24ceb5dc3; PI_POLY_INDICES_LOC[31] = 0x1b67a416fc9ed852c38e77f1999bde0240cdf04aff5cd56aa605ca152843f2cf; PI_POLY_INDICES_LOC[32] = 0x1e7b6541924a52c92111927da2ddd2368a1b64b1e4b36d47c30a6b6b3b7deb4f; PI_POLY_INDICES_LOC[33] = 0x2cd772a5d5948dd33d356a6cab4be630e20554f00a3e9d03c18d5d0d1f15ffb8; PI_POLY_INDICES_LOC[34] = 0x01aaa3a5b2f6687f2a93c3044661aab1cfa37af60605a19de820e72e051c9f5f; PI_POLY_INDICES_LOC[35] = 0x01ec352dde7665e35966c35fe45e322f593957156ea87d81878fe3c6801dabae; PI_POLY_INDICES_LOC[36] = 0x083717e6d176ac9c7c41a99d81cc12c700644af1f6b3c99e3c40a988a9b820c5; PI_POLY_INDICES_LOC[37] = 0x07638f4122ec0a6e2352121ca9e84b6536e11741a30064a6223404c04ee5755b; PI_POLY_INDICES_LOC[38] = 0x1a8bf690588540e86665087c93c4fc6409569eef1a5d0d431891c731742f0b77; PI_POLY_INDICES_LOC[39] = 0x1881865866a55b5f25c35ea470a251f70c11b393d9a40fccd23585ae7c3c5af7; PI_POLY_INDICES_LOC[40] = 0x0fa1c0dafe4b6fc6066d8d973436aa540fac3ed86ae0440aa6a355cc4a61598d; PI_POLY_INDICES_LOC[41] = 0x28f6babe91483eb1560f7cda3a3ef96ce80d420743e991ee60436fb7fdd866cb; PI_POLY_INDICES_LOC[42] = 0x1a893cfa28f567989258ae6c26f1ff8acc415af3b51384fdae8d788fcdf9a4ca; PI_POLY_INDICES_LOC[43] = 0x04ad87ef1e76ef80fe1d4c579b265c6b89b05b33afc5338e7ce2319cde523fbc; PI_POLY_INDICES_LOC[44] = 0x0e7df16f78fc5c909d49dd52670cf041767787742bbf82f9719f186ddc5ea6d2; PI_POLY_INDICES_LOC[45] = 0x23441ee7501ed5fe6011cbcc39d7320ece826867efca3cdbbaa6037a3f45626f; PI_POLY_INDICES_LOC[46] = 0x0b31e4398d648b4983bd949be1afc7e60747c492c9ba3d48d9528ea437bbee41; PI_POLY_INDICES_LOC[47] = 0x08bc3d3f91f541e2522ece961d868c5dfab8fbda32db874534a03e61ec691b2a; PI_POLY_INDICES_LOC[48] = 0x29e514ad2eaeffea784403ef980fea9c8a2a39a4b97b1b65d264836459a0b6bb; PI_POLY_INDICES_LOC[49] = 0x21717842d0a77dcaa0c6272a986ba4418e38e5b1ddd589bff569f87cb46e517d; PI_POLY_INDICES_LOC[50] = 0x0ca56f0731ffa45779e3ed40dbfde29e0a46186ba2cb6627878b8d87792903c2; PI_POLY_INDICES_LOC[51] = 0x25552756f326955b99e9b158e828e18c7b0bfd93b63b28024106c1ee68d23fbb; PI_POLY_INDICES_LOC[52] = 0x09b6917833784ff7369b43ae4e8ef269ebdf0fe6f4ab8b72470f9b5d15b5c763; PI_POLY_INDICES_LOC[53] = 0x1a221e7c244a8a515812b72854a523faca4a3783d9e37426345515272c762307; PI_POLY_INDICES_LOC[54] = 0x2855c59e81a3a030efd8cb6e82a2e6004bef01f63c6d463476eefddd007d1fec; PI_POLY_INDICES_LOC[55] = 0x18aaf393d8ed74433b8383c12c7fea7bdfddf47f88c32d8d50a1db2dcdbd4c0e; PI_POLY_INDICES_LOC[56] = 0x2b3572a8485731d823e873810177eba13a00e7c501d31f2a961614c1bd7b5a52; PI_POLY_INDICES_LOC[57] = 0x124d1f4df8f62e53760f5208d17c10e06b503c40d597aabe59951fb847d476f7; PI_POLY_INDICES_LOC[58] = 0x2c0751d2dbf1bde12eca968400ee777d4366f7d35e078f3d3664983efc14df27; PI_POLY_INDICES_LOC[59] = 0x02a74ef8b37a219d4758e6e4c83a739d293e822921098d1cca1e63f35f73c0c3; PI_POLY_INDICES_LOC[60] = 0x244bb2cde74781a64251b30e1dcdd8629c5fbd715a352fcbd7fc5e4340d83834; PI_POLY_INDICES_LOC[61] = 0x0b3aa2a939f69c9e8781404583bbf4d70fdd2b4fc46fad383ad7a047e3e08630; PI_POLY_INDICES_LOC[62] = 0x1095c35858f1f1a8ce012ba03ececd4c2270021e0aeba844e8ec0da2696ff8e2; PI_POLY_INDICES_LOC[63] = 0x11c2f468ad2412ca6fd4d0f50c4d172c133ac9c9207b3089c378820ca3807625; PI_POLY_INDICES_LOC[64] = 0x269b591508f6efd3aba47cbf90973caafcd3dfa0e3130c75f7a4f671d07aa70f; PI_POLY_INDICES_LOC[65] = 0x25638beb491d997833b874a0e8bbfad6d7475c63d8f308ec9f8536e2eca52a74; PI_POLY_INDICES_LOC[66] = 0x2564c22601f163ba493f0591d584919ae9cb1e1abad42c4fa8c37562b2b98f14; PI_POLY_INDICES_LOC[67] = 0x0d32c5102a6440c0f0c17cb1034e1051859b2f7ed7142366b58b4b380758d258; PI_POLY_INDICES_LOC[68] = 0x0b01ce5fde244b82adc324a30be8f41a0ede55184ec01e4ae61b9ff73eb12216; PI_POLY_INDICES_LOC[69] = 0x2d0b4381e2662f7d670d5da2f49113fba1454cd49647a7088d45e9d257a06237; PI_POLY_INDICES_LOC[70] = 0x06aea15dd40f361048366630d252236273f9ed9bf5b152adfc7e91e0c9fdac00; PI_POLY_INDICES_LOC[71] = 0x212e132a3efd862ef664c613b00eb0b52b95367f00b709988d9806fcb36e569c; PI_POLY_INDICES_LOC[72] = 0x065abf664404d1b14c788fd01e425f55a99f7882af3b34402cd639365e8986cb; PI_POLY_INDICES_LOC[73] = 0x0140b570becf26dc8b13bf9493f1148cb0751c54ba4006ca1dee282eba6b81b6; PI_POLY_INDICES_LOC[74] = 0x094306e03a6de38d8629d399877b972ff6bf31b0a8c3a650236f6e49541f7308; PI_POLY_INDICES_LOC[75] = 0x2fb285f33a78dc3fd5976b50ab99268a61a38462176a4a2ee723d4ec5ca8f062; PI_POLY_INDICES_LOC[76] = 0x1c9e22734dc5f66d1ec784a75db9e2d7a848dd57da367dd99ba1d32b14e69c6e; PI_POLY_INDICES_LOC[77] = 0x0122511f8d4f830c692675193a91931b5731ee5a12624ae3da17759c3a3730d4; PI_POLY_INDICES_LOC[78] = 0x1c42f89adb4ce816f8c3a4b99c994e6666671b7e091418d0bc754685373665d5; PI_POLY_INDICES_LOC[79] = 0x0b234e7bf1ca9d14ed3d2e7f4a0e61660c3a090f5799dc9ad3de666b53734c58; PI_POLY_INDICES_LOC[80] = 0x24a5719ac6ce20863e4347c494569f0789f5258d6a499b7c337a870064086efc; PI_POLY_INDICES_LOC[81] = 0x2ad4bfd5cfc8f71ac74c5ac2d07af52c1e96e6977ab7711b4fae580018f640ee; PI_POLY_INDICES_LOC[82] = 0x1d42f66ac2c6f6b63fad7fe5858876fe247b2f7314a9943240d028d4efc9a30c; PI_POLY_INDICES_LOC[83] = 0x2e20647f3659d1094ad7f13359c699e0cf0d3c931baca1ea094b15b239f4542f; PI_POLY_INDICES_LOC[84] = 0x1d9f48e032863be5fcf3d0335e29f213a340b93f1df7265c0a07ed32ea98e792; PI_POLY_INDICES_LOC[85] = 0x16ca65bd31432418b55911a76ef641eba29c898d8bd077a45884a5c6cfa91769; PI_POLY_INDICES_LOC[86] = 0x04bc4d0d6ade3ba7bbf4fcc1b9b7c0ef2c5efd88996d93ab4a5e344133e02ed0; PI_POLY_INDICES_LOC[87] = 0x228ed165a58cc73a83351b27e7d2a9479cfebe752f599e9d60ba53e93decbba3; PI_POLY_INDICES_LOC[88] = 0x0bb7079f747a0d438a3d84b7ee6714304132a1c5e823e4a75162ef7c50890cf4; PI_POLY_INDICES_LOC[89] = 0x08c6bdcffbece9052cfeb08adb94207b024c611fe1a40a713a38a08e2d0d6caa; PI_POLY_INDICES_LOC[90] = 0x0d26cb632ca43fc5b0eb3b8446149f8a2e32f52c1d0f4cf28452d6168602f692; PI_POLY_INDICES_LOC[91] = 0x0f1197bb409d3c54ab747284393c429e59484b098ed8ad4350bc33bd87ba175c; PI_POLY_INDICES_LOC[92] = 0x1787e85026eae6d03f09d40cc7f39462e0f7fd83c9e2dbe0bb693a24832d9f64; PI_POLY_INDICES_LOC[93] = 0x07669ab6203dcd43368747e398301bbf1d87473963223873ebba2504a3d2156d; PI_POLY_INDICES_LOC[94] = 0x1efc52d2788e9d19cbbff7d2d2d3474dde41dfc8c14ff4179c3d38561ef78c42; PI_POLY_INDICES_LOC[95] = 0x03e493bd07426576896b833bab602f6c004f85a950cc993a0f626efa01f24244; PI_POLY_INDICES_LOC[96] = 0x2a72ed47a7f722f6e30e59f8ecf79d50d53192fdbe9de223474b6adfdda83d0b; PI_POLY_INDICES_LOC[97] = 0x0063a34acac07bb8e9a620b2ea1f6c46781b72823124ccd56c05252aba5466ff; PI_POLY_INDICES_LOC[98] = 0x2b73d3e88eab85153d02e0f3d85b1d327a5e2a5ea8f487be9bf6a907d922cd76; PI_POLY_INDICES_LOC[99] = 0x1c862cd2327ba5143a20dc476be260e7cd0291cf142718bcf1d59ba5dad29ea5; PI_POLY_INDICES_LOC[100] = 0x17107826a6f42fa4407b0b6ab865ee8511cb5227e11af82e7feca6fb18f55372; PI_POLY_INDICES_LOC[101] = 0x13983122d1d526e5278252d3ec6ff5a18880a444fee470290f43330add9a5fe3; PI_POLY_INDICES_LOC[102] = 0x0d846a75ef9a3183bb664ed5f171949f2141889be9c6bd35c37523de5334caf4; PI_POLY_INDICES_LOC[103] = 0x25715ba4f077961086ec240af90861b1be32fdf904349b22e411fa53c08cdac0; PI_POLY_INDICES_LOC[104] = 0x0335c9510a609bbac1ccdff374ca5b13ec264dd6e08315946d13b1c1be1db39c; PI_POLY_INDICES_LOC[105] = 0x0f681ea9246c8e65c21ec71424dd27b6c6b990e8415f787e1b239204fc325e21; PI_POLY_INDICES_LOC[106] = 0x0f989872b530ae3d41bf06655772b7b4efd098f63deced67fc9eb75258246448; PI_POLY_INDICES_LOC[107] = 0x10d5ebdf1c18a764bacfb868c2b889bd5c059b4cebe40985997402370082f3cc; PI_POLY_INDICES_LOC[108] = 0x2ff67e1be71805a126afca5bbab020eacb09f4218814e178b5fe2131b0af0b2a; PI_POLY_INDICES_LOC[109] = 0x14e5699b43ae7cfa02b576ab21c89ed552534dbdef56e4cb6278623743e81b69; PI_POLY_INDICES_LOC[110] = 0x296b35ba398f61ecd1d98d475b3a7bb9e2cb0e39982b41de3e7679225da74683; PI_POLY_INDICES_LOC[111] = 0x2edbb77e8064e9a168f35b3276461da24284fefc9f043fca8602362532b550cb; PI_POLY_INDICES_LOC[112] = 0x0d21821ebd75b8fc8c201052e93136db79b57a7db6394d8cf07e2414fdc9d1e9; PI_POLY_INDICES_LOC[113] = 0x2de0b816cdf8d807b5ba79c52560889627d21665e0b4fb54f1f2db5a6f4232d3; PI_POLY_INDICES_LOC[114] = 0x24d5b700ee56ee5825066ebb6b0891f270e0eca1e662c392e62da34d13d7b62c; PI_POLY_INDICES_LOC[115] = 0x0803d0008f30af3c446870f8935e85c36da740d0910b988d8dfaa9bec7c3f7b8; PI_POLY_INDICES_LOC[116] = 0x246c53673ffdc2780839e29f161be843be08eb03c1c1e7d7869619d78c6ec8f1; PI_POLY_INDICES_LOC[117] = 0x07d58ac8f873235debbe2a0fdf3aca2e597edcf4e05bd1f3bf7668b102627a37; PI_POLY_INDICES_LOC[118] = 0x1648ab2de31f43a2406839504f11c79e2a3c30cc0aee0d77213ffe8a9dfabc89; PI_POLY_INDICES_LOC[119] = 0x03eaeffc29a1e692443f59653265f613c062878b9a987be772dec5a0868ca51f; PI_POLY_INDICES_LOC[120] = 0x06ebeca56dc15c2302f97aaabab50cd75c5f2b79197ac4c3aaf771c95f92f264; PI_POLY_INDICES_LOC[121] = 0x14105fc3253fab4fe0e6e97947f55c3f3d192f600c5110224981d4decd8a9f03; PI_POLY_INDICES_LOC[122] = 0x0d51ce04d3f75c0e7f3d10367daacc2b59b62d90cc3e085f8129c76902eb0bcd; PI_POLY_INDICES_LOC[123] = 0x013bde70af2127c43d060ba277875f8d433fc963960b370673c5866ba139fa58; PI_POLY_INDICES_LOC[124] = 0x2cced2e16697f376c551401bc0b1da49063932a1539dba1bcd8efeb4db27e798; PI_POLY_INDICES_LOC[125] = 0x195e4701eace5a585f027ebbe76611d84a39aa5aa173d564ee34cb144b0aa29f; PI_POLY_INDICES_LOC[126] = 0x0e4b808ba10470ecf58c91043803564c55b3844e83f9ca6afcabbcdc70838d1a; PI_POLY_INDICES_LOC[127] = 0x2a96619a81989d2d45f76d841deb595df4bf0adf2231794a9f15950fcacc834b; PI_POLY_INDICES_LOC[128] = 0x2026a64ab81745b9ac264dc0727ba0209da63da4222eb7a86103eec8ac3700f9; PI_POLY_INDICES_LOC[129] = 0x024f7fcc7818c70b2e41697ca9b22b16a05236c6400ef10cd59160bf9b4c35e7; PI_POLY_INDICES_LOC[130] = 0x2b4e902e0f6e4ecf298a89c9185d38ef3b07c8719871121b48ca2f1e7b7b9064; PI_POLY_INDICES_LOC[131] = 0x18c9d06803cc66281f1d202c44ce3e7d8f08f25e84aa85d15cc582f3edbecf40; PI_POLY_INDICES_LOC[132] = 0x2d3d339f2ac9e198cb52b80fb48f9aeac23e0a0f703e8183f13a4217ee636432; PI_POLY_INDICES_LOC[133] = 0x2fa1b84c8fe76a928dc3595f0cccf80602bcdcc78df8ea6b4bba07f393b4fc3b; PI_POLY_INDICES_LOC[134] = 0x10a29f8e3c05abc39a2972f841cc83e95f243db42b13ea218c574321754b02ba; PI_POLY_INDICES_LOC[135] = 0x2ef28d0a396300db83b273dc538316e588a929d6db5b14f6ca3b318a8474a782; PI_POLY_INDICES_LOC[136] = 0x0451580c4218dc2ff4b43fa281ba450106f4e12844e12d7183185274b80636ed; PI_POLY_INDICES_LOC[137] = 0x1fcfce8ab81e7d9bc9a9ab6bc4582fd5b5a8b619f691cd7e9b56cfa2df6e083b; PI_POLY_INDICES_LOC[138] = 0x2176dfccbf2aaade47a5f4e95c7a42c94d35edec924bd6964eea54278a509e29; PI_POLY_INDICES_LOC[139] = 0x2af4c0ea1fdf30b87ee001f8276cf93989460692545f79e1218763f122159499; PI_POLY_INDICES_LOC[140] = 0x1a81fac24243e7609796de7c389b0587759c4dcd56d6b4be74e625cb984db3ad; PI_POLY_INDICES_LOC[141] = 0x02610a90fe53bbddda83540d4d98a86973ee48b413ae19ffaff703372491b7d5; PI_POLY_INDICES_LOC[142] = 0x16f2e386061c0bc4301a3f61a63ebcc0919a6748bca553283a1067c95a1c2014; PI_POLY_INDICES_LOC[143] = 0x26f98866727d318e11acf949ef088a52fc76dec12dc5723fe7fcd01081c6f808; PI_POLY_INDICES_LOC[144] = 0x2ef7a9b4e8a15810aa9b7305b2d666603da29bfee1367dd81ff7300deb283aa0; PI_POLY_INDICES_LOC[145] = 0x23c3550fbc6880da8d5dbe0f807f7fb11eea517ce08577a55446ffc3bac3b059; PI_POLY_INDICES_LOC[146] = 0x301ce4a5479ee88a8f335c4fe8b9eeeafd5b5a96112f975757b5d87ec982cef5; PI_POLY_INDICES_LOC[147] = 0x2088864a3182d65876406577a82bc06241939964dc752ce5cdb463b18c89a477; PI_POLY_INDICES_LOC[148] = 0x008009eebc91c086003b340a1b7dc93deeec44073a9d22fd29a818d21ed01d79; PI_POLY_INDICES_LOC[149] = 0x1e4ec64a8f5632a60fe90534724d46b959f568d6f844b07bc9152073d883872d; PI_POLY_INDICES_LOC[150] = 0x012d597b1fb2c7f50a2566a6246e249a8c2498620e2e613d39653c010bdea26e; PI_POLY_INDICES_LOC[151] = 0x1c1cff5759de0b2185e3e9237239de950549e677da119a3e4ec289cade06d9b5; PI_POLY_INDICES_LOC[152] = 0x017422c9df947ccba8d15cc5f69970a8819981682a0dd4a067a36e097f485e4d; PI_POLY_INDICES_LOC[153] = 0x1800250fb6e7ea4c25c38533db0c5d66b665deb9eae48fab26219d76abfb2923; PI_POLY_INDICES_LOC[154] = 0x25c0df8a702c6948856f74b17d425c0351b7c8ef05b9622360e482fd9eb92956; PI_POLY_INDICES_LOC[155] = 0x08e4c742594e1c47b396b4dd4455d5f92743ef2b756d0f50bf1ce197cb0c2b20; PI_POLY_INDICES_LOC[156] = 0x2c49f2b7e83343275a3eac53cef47e718292325cc8bef4b1880b83a94364cba7; PI_POLY_INDICES_LOC[157] = 0x2b288029e3a01e9b1811345a680ddd82986408c8ea9fec2093e932612d9a0c1b; PI_POLY_INDICES_LOC[158] = 0x17128c72a676041163fd62e5b7ede5c740a1eec188130a8cf2dbe7d853cd1375; PI_POLY_INDICES_LOC[159] = 0x24675f48bab537555f5f404139586c81be0eeed8bd76dd6b26e807a002a7d233; PI_POLY_INDICES_LOC[160] = 0x0308afb1b4f264cf1e9df722384175f9958a420b6849262e9144f609095b0b09; PI_POLY_INDICES_LOC[161] = 0x1a18883e30169e62ba0f7f67dc30ecff35b090ed05a439381dd054f7d9acf605; PI_POLY_INDICES_LOC[162] = 0x2562120a1fb795ecf4ffb5842ee0eb532295489b63e39c9795319ec9e0622e27; PI_POLY_INDICES_LOC[163] = 0x0c39b2f6b4ba9648a09b4459bf551e4f14672bd6a149938bbde8a80da95f502d; PI_POLY_INDICES_LOC[164] = 0x1fba05b00bf1054707ccf343c445ab1e96d25a44a901696c5348c36c7e8e44cf; PI_POLY_INDICES_LOC[165] = 0x2f2245ffe437794f4c589d40bc745cc410d939db884e0a3305695ad0aa88bfc5; PI_POLY_INDICES_LOC[166] = 0x27e306885d9e8bd902b6b20419ea86f6cc709462034190fa97b8cab9d132c3f0; PI_POLY_INDICES_LOC[167] = 0x017e783a7a728c488308f923ebb46c4e002efb1434df9f6d02c2fe3302d20495; PI_POLY_INDICES_LOC[168] = 0x1b41160961cc4dec07e3a907a7c7e005c9ea095a4385f268e6659439ef4a22a3; PI_POLY_INDICES_LOC[169] = 0x25085211785ef9026c7065bce5eac4ed1b869820482564a99be2d313a9fce5c0; PI_POLY_INDICES_LOC[170] = 0x2372d2183efd194e96ee446aab3ee27bc0a0db96753847270fec15d69685d8d4; PI_POLY_INDICES_LOC[171] = 0x2d7bede76714ac29ac4f23f8617da768f235a9493bbd9297d024dbea38b61d17; PI_POLY_INDICES_LOC[172] = 0x07626fccb43bc0139bf33da4677ae7b2c10d3e4ba96561bd11990925440b3de5; PI_POLY_INDICES_LOC[173] = 0x1b7cd4827a8691209314074ff6054ccf6be217ac9ce6ce147f2b490ae0519cc8; PI_POLY_INDICES_LOC[174] = 0x19082335974c3e6640c32a0185fe73c909a90536eab0e25c1e9bc6080fe7e022; PI_POLY_INDICES_LOC[175] = 0x299849eb5a6e31c623be005f5f4206369279af683dddd3dcc00f3539b39a667e; PI_POLY_INDICES_LOC[176] = 0x21d456f1eaebc20fc80434025236e8573e9506bb3246274c15d34821324656cc; PI_POLY_INDICES_LOC[177] = 0x248930a720d8eda148b5b8ac948271b0cd809a460bd44a8bcbb94ac7d4dbdb22; PI_POLY_INDICES_LOC[178] = 0x044f56dacf2ec124e72719c2085a624676f3e3b740da1a1a624b6718bea56145; PI_POLY_INDICES_LOC[179] = 0x00243f3ebb98cc541564348a333e0ad7bfb91741341b19f3741ed9359f1d27d4; PI_POLY_INDICES_LOC[180] = 0x3022d9cee94d62e32fe9027636b106dd7821a421ece856aa10fa982759cd1c79; PI_POLY_INDICES_LOC[181] = 0x166348c4af1b23d15bd4ea1889277e1f5ae95d27d22b77b866c7d1d78735ff7a; PI_POLY_INDICES_LOC[182] = 0x272c4839bdc1831faf653bb5742200949c9ab48b84ac6bd8f86a1068ef85a638; PI_POLY_INDICES_LOC[183] = 0x1ed363847993f2444dd0294994e1d580d1f5073b367be3bf3ae7623d3677069f; PI_POLY_INDICES_LOC[184] = 0x30644e72e131a029048b6e193fd841045cea24f6fd736bec231204708f703636; PI_POLY_INDICES_LOC[185] = 0x2858415fe5a91fd73841460f065d945a968635322f52ae74fe427e20fc17a152; PI_POLY_INDICES_LOC[186] = 0x1df2772ea647a0167925187042503c041aabc3f0272438dcc0426c62749a388f; PI_POLY_INDICES_LOC[187] = 0x052c12b507ce01c74597e2bae675b14211e80ca2b0b8c3b2f9505254cf6f2480; PI_POLY_INDICES_LOC[188] = 0x2779179bad302d00f149173b7fce0442f00910bd842f557f13340c145852470b; PI_POLY_INDICES_LOC[189] = 0x10ff4eedbe955ec4408c887a8470d0ae667ad41a50d9dd5e03e625776be33f30; PI_POLY_INDICES_LOC[190] = 0x1429c4b553ce40057d3067702120f0f74b7c5410ff753b2e3d9f3cd971f11e5f; PI_POLY_INDICES_LOC[191] = 0x228952528fbbfdad115a6f04ba4d0c15ed9a8168146a330c36da18fa77186e13; PI_POLY_INDICES_LOC[192] = 0x122b87cc03bb317d6b07c860e0fa063c2cde10919c1b4812e322da8c22e3b092; PI_POLY_INDICES_LOC[193] = 0x09bdaefe32336a7e89ff193048cb2de36a372ed92ba0ebb17389087f4420f4e1; PI_POLY_INDICES_LOC[194] = 0x18fdd8fb582e1f5afdd1006c31379b035ac25c09987d1d0fae92b81fd2291733; PI_POLY_INDICES_LOC[195] = 0x2b114c300a26cf8019d9d6b05320f5c3c2fa4417596a6bfdfdce8b283ab5b688; PI_POLY_INDICES_LOC[196] = 0x156324064c5b831eea01dbc1872798ab2d3ae4c6684f09b3bc7f51ed22fc8482; PI_POLY_INDICES_LOC[197] = 0x03ad6cdc74a9700e7edbec285b7c84532ed1a68bb209555e7bf98306a09f03ae; PI_POLY_INDICES_LOC[198] = 0x09ee24d3d373587b3f0925224b4f52245ed69bfa06f6810133a6481b0b6afd56; PI_POLY_INDICES_LOC[199] = 0x0d589c7feb6c2bd730f0774146a82486813dc14923709a03c849479c6b0b7961; PI_POLY_INDICES_LOC[200] = 0x2f101a660bc9a64c0bb58b8247eee78c7bb988c7eb26c967c46e194824deff62; PI_POLY_INDICES_LOC[201] = 0x286c90238bc78f93fd11416351b1dacc9e162fb904df0f19665dce337b0197e0; PI_POLY_INDICES_LOC[202] = 0x279e2f47f73292a8fe874c556b44c37ebc96fb3f9d509da492d3e2d0977d9d14; PI_POLY_INDICES_LOC[203] = 0x2c0fad7689cbc35e4800bdbff71f5abc2d1bde4897689b6e6b69d6d6b0415de6; PI_POLY_INDICES_LOC[204] = 0x1b76f4a26403c24f5562ab296467aca768ac5684b712a17da9bafaa713d1074f; PI_POLY_INDICES_LOC[205] = 0x1389b81ab7ee77f71157110ce45255479f477d3cfafa0867ec6a1d1b8dcf4a5d; PI_POLY_INDICES_LOC[206] = 0x0ad93ad9e54e36fe0a53439a3539e29d61865dea840e8a44a9ba9ab651107658; PI_POLY_INDICES_LOC[207] = 0x1effbe567ff1187d826d6e0e75a9dbbc7e353f98575cdcd2187cf6e8364d142b; PI_POLY_INDICES_LOC[208] = 0x24b99d5cf1007845291b86e528dabef2f4a912cace1c2a890fae8be084aeeae3; PI_POLY_INDICES_LOC[209] = 0x03fc8f9b68a268a76189682718081452c47fa5f0d6e554374e4b3008ce7b51e4; PI_POLY_INDICES_LOC[210] = 0x2de4f152d3d31ab2f4ef2517cc0356cffaf0ec705f829b7e34f0af8143f71eac; PI_POLY_INDICES_LOC[211] = 0x2f66f64a81e51e59d65ed6bcf201fd433cbf61ba054800557a62d105b931239d; PI_POLY_INDICES_LOC[212] = 0x02b23bcad4496a8905f41823459a634c2485161aa3a0fecacde93c4fbfc6989a; PI_POLY_INDICES_LOC[213] = 0x076e04ab3ed513f9a34fbf2e368a7f3eb5b47a956d88cc6e013852122a0958b5; PI_POLY_INDICES_LOC[214] = 0x0007f95dee04e94deb611b74e1e363fd4f73d4450746e68c33c07575760b894a; PI_POLY_INDICES_LOC[215] = 0x247c3831279e4f3fa1368299a16b5100dbc542fa3a202e3808dc9be0b03d9fea; PI_POLY_INDICES_LOC[216] = 0x0dba8508f7a603e514046b743c58d14529f887089a9b36be906d127aaff1dba4; PI_POLY_INDICES_LOC[217] = 0x09b57a92c0992adc22791e8fb115289f8ed192185dacabf80a411e08da370fb6; PI_POLY_INDICES_LOC[218] = 0x19d28eff271f07c5afdf55ac07f162aa5685acebc81b22e5f27dc4804cdb10c8; PI_POLY_INDICES_LOC[219] = 0x04bb91a4676cc7d09088337d8f2ba5e1f9c84092539a9d443a1888406c5dfffb; PI_POLY_INDICES_LOC[220] = 0x11ad78eff008d7c8c0c68b0b0b260b29b92f8bfc393f0bfff3f89fbf0bdc7400; PI_POLY_INDICES_LOC[221] = 0x07a645e9f31bca6cd4893591038b4b47e9a6161501a56e6d2632b7e6cdde0c4f; PI_POLY_INDICES_LOC[222] = 0x079eb958ca85174515532aa463b1f0fcc8ba82e1b1da1be8d2be133adcbc4c4b; PI_POLY_INDICES_LOC[223] = 0x106803b2004389cf500d589e161f070b0a8538bc8482bac8a6e457d9385fe8d7; PI_POLY_INDICES_LOC[224] = 0x2acd16ea8181eeed7ec8ae53aea6b7500859cd4a2eeea0fac674996a445f620c; PI_POLY_INDICES_LOC[225] = 0x1e466b6d8f48ff8ece603595b442d89dea41082a202857cbb59564de7b5d251e; PI_POLY_INDICES_LOC[226] = 0x2b919c14d17ea295f98057e6e17b77b28dc8a21b673e45d1091c6881cfe2ea9e; PI_POLY_INDICES_LOC[227] = 0x01dbcbaac3b3f8a446c38f00df7b1a27c3746736398f9153fe1390ffb84a1a4a; PI_POLY_INDICES_LOC[228] = 0x24b4ac90edc8a7ebb024bbd697d0db4d4b31e3cc1249803f6327ed5d6ca82e3f; PI_POLY_INDICES_LOC[229] = 0x044f69007a8ea582a64ab849262b2595614b59688bfe034b7b0a04eafc47d652; PI_POLY_INDICES_LOC[230] = 0x129dc533431a291b238932861e75dd5bb0c7450eb98a62c50f82399ae12402f9; PI_POLY_INDICES_LOC[231] = 0x144c13bb75632bcefc8849ac7b6a603ea01193a9d2af4c1d10e3418bceafaf5b; PI_POLY_INDICES_LOC[232] = 0x1475bac4d47de152e9f7c76b8fab244714564fe173283ad088fac0debcca5167; PI_POLY_INDICES_LOC[233] = 0x1e9fa5334ea28f9ce077e20b33f29eabd967538ac1f99f5dfb5857ad97ce91e9; PI_POLY_INDICES_LOC[234] = 0x18f597a31d47e64233b9375a8cdccc59b90476d0af95fab3d20104330f1ee053; PI_POLY_INDICES_LOC[235] = 0x0b394e36cb5856ca0bb2edfa2c9e889d626431b40b11404c58111108b345f21a; PI_POLY_INDICES_LOC[236] = 0x264ffc6db389d8fa8a6cc2ae6ee9ea0f07264c9225d9e80a6f7409807099fbc5; PI_POLY_INDICES_LOC[237] = 0x03e681059c21e1db9a8b669bb31fd130d86820b46f45a6a9f20d1e8494a2be27; PI_POLY_INDICES_LOC[238] = 0x06e49727e058e3cdf87389959f4b8e04e478e36ba7bea8920bce50af29f27203; PI_POLY_INDICES_LOC[239] = 0x2292fca7819e51b4c389929c556b4ff8f5ee276cff628b15ec2c955e06ca6385; PI_POLY_INDICES_LOC[240] = 0x02147ad0b8db5caf5ae18634f1b86bdd6e9fbba5a4fe44123b63fe1302d54ed0; PI_POLY_INDICES_LOC[241] = 0x0196bab119194ebc0e439cc29d233d82cce16227022ce5a25e5f527d7c7e45fc; PI_POLY_INDICES_LOC[242] = 0x228abb94830d21a54805b829c7eba09f2dfd9c4584d9f9224c46b8855f338f44; PI_POLY_INDICES_LOC[243] = 0x03f0c1f26a319bdc271b7367d023d6529cc8ef4f2c8ee2f32297c727ae026035; PI_POLY_INDICES_LOC[244] = 0x1d2019bfbe9b404e25ff27db0d3b3a849dfac0861cc1ce225aadbf9dc0fd357e; PI_POLY_INDICES_LOC[245] = 0x24d5c0cd5fe52d26991f7c8839a29b0dd4148099e4c5f911dfcfb4b61f16cc8f; PI_POLY_INDICES_LOC[246] = 0x2215531aa18e8fcb9560eb065cafece55cbb0ace5be5f70d308b9f53189844e9; PI_POLY_INDICES_LOC[247] = 0x2d3800b9f872729152a0100ad1f9e4a299243798ec4eeb88f1cd498cfb30d5ae; PI_POLY_INDICES_LOC[248] = 0x17f6247924b568195bf57330265356e4e599d1a3a34aeaa9bc60520de6f487a3; PI_POLY_INDICES_LOC[249] = 0x063de53ca71f9f0e5d23f6672c59380d52392cc27c0ef47067a4b8c8d891a5c0; PI_POLY_INDICES_LOC[250] = 0x182e948d6c1f3f3171727e3291cc55cdfd0e217a2331b35ed0c5035bd1613614; PI_POLY_INDICES_LOC[251] = 0x28f42faa7051bb05896b1b843cc5e6567efbf91d1ada3181155f895e7b8f1281; PI_POLY_INDICES_LOC[252] = 0x22b3871e220d8904d284f52d52f5f3a01706e37c246b8f85c2d020f164729e07; PI_POLY_INDICES_LOC[253] = 0x1604e6647e75f45e17b8b15665622cd9f3ec7945f3c80164b7f10b2d48da4899; PI_POLY_INDICES_LOC[254] = 0x1981bb0be2ace527d2109f3b9f7c03f640d9ae52819d74af746856067360fe6e; PI_POLY_INDICES_LOC[255] = 0x0bb04efb6e1860c60a1c61906f57f46a65bfb7f6854f0282b8ac2692489ae23e; PI_POLY_INDICES_LOC[256] = 0x0cbdd77c1712dd1b651be409320b953c22e5b4c11989569b5338f04116dae493; PI_POLY_INDICES_LOC[257] = 0x0e9d482a08cd27c5eee4a81ff2d3367f1959372fd52af1ce46bf735f17ca529a; PI_POLY_INDICES_LOC[258] = 0x2d8ecc9e0f393f373cefeeee38ed5b89a4f4a3a8cfa0c82a8fa439b3b9f4d78e; PI_POLY_INDICES_LOC[259] = 0x0a2bf2f7721fd7e547cdd811d0531b0654bc5a697003c953a3e9a7ffdcf85cef; PI_POLY_INDICES_LOC[260] = 0x040fc62e4f6e9ce797ac7db25b25483ab4094a6e1c704a823c6473d798f91a77; PI_POLY_INDICES_LOC[261] = 0x117fc1b549e2c8493f0abd3f0d8d3f89170902aa4020e03886592864c8cdc8f0; PI_POLY_INDICES_LOC[262] = 0x199a871559cb2e872a2f8b8fb220da02dfe65e03080eef752a31b5243583fdf9; PI_POLY_INDICES_LOC[263] = 0x033f9ebe328e1ae74c4248b9cd7baec53b6cf66ed542bdda879e77b50310e6e3; PI_POLY_INDICES_LOC[264] = 0x11db911ee63d3fa26f5d5343dfac2619f93cb83329247ef4f22e845a0f6afa4e; PI_POLY_INDICES_LOC[265] = 0x18a1f38752c99b4004a35730432105c8d989db4b409472a656f77d30e120633e; PI_POLY_INDICES_LOC[266] = 0x28c9a6895f131a495566b462267063335db11660b401111f5562a3339f1a352e; PI_POLY_INDICES_LOC[267] = 0x2241a41e152996176f1451eac5a66b4149af4e37bf22eb277094ab3dcf45637b; PI_POLY_INDICES_LOC[268] = 0x0143278ff951928e81734887b4d9cab576136148fc28938f3265b361d6062b4d; PI_POLY_INDICES_LOC[269] = 0x0e1da283c5fbb7cd88c5f8c033f070dd1b0b31a3b8aa6163111ebb85d9b2c454; PI_POLY_INDICES_LOC[270] = 0x04170ed2bd84d87e223b2ed53c1445f729c64b6ec98544e56433f777e544b422; PI_POLY_INDICES_LOC[271] = 0x191b828704ad66cc5fc15d4190afcf98708bc624a826a8f394a38d7c935e629c; PI_POLY_INDICES_LOC[272] = 0x07cc01ec2c9dc631c18aeea575a48ce11193e20940d15670210def437c523b12; PI_POLY_INDICES_LOC[273] = 0x1a929dde8a6b85b6b71dd6de8b1048d16e92e75c9e1461fc2abb099013e1b983; PI_POLY_INDICES_LOC[274] = 0x0bedf358f33c82a5708ea58c66623875530ba297f861f8562d3968bdb6cbb818; PI_POLY_INDICES_LOC[275] = 0x04882aef65d5c52e8b8c0280cadf2d5a35c8802010a07e2b32930948ca4820fd; PI_POLY_INDICES_LOC[276] = 0x17a59f5502ff8122e4c613b303854bad1687d1a67849d0d8a820942c37b4da8c; PI_POLY_INDICES_LOC[277] = 0x2ac560ed7ebbb8600caad524834417733b42d98ff7ce9e5e600977a58a1dc1e2; PI_POLY_INDICES_LOC[278] = 0x2b8681b258cbfe97b3b70990e213daba65abae53999504c0f8095186725cdd54; PI_POLY_INDICES_LOC[279] = 0x1329dae8e84df0917fdf285d1ef6e79e828749f9023c9e6fee556d6a4cc18461; PI_POLY_INDICES_LOC[280] = 0x02fe8a6de0927d326fe06d53a2510f6e8a562bfa26516879a482fd50c080cb8c; PI_POLY_INDICES_LOC[281] = 0x2b7f37fa06d4e1522884d615318b3730de15e4155d7ded46fc40aab395a85b31; PI_POLY_INDICES_LOC[282] = 0x0f1bb2874c68e9664a6bf542ae62768f2c0c59c816575d16ea290a51666a589f; PI_POLY_INDICES_LOC[283] = 0x0bae888aaeb2bb6e1885a5ac69fa521e8ea53ddf60522fcea03754ab734e2677; PI_POLY_INDICES_LOC[284] = 0x1c4e1efdbbe431c673f6a2466d19fecead2bb588fa9e3b60d159e45f3a42aa03; PI_POLY_INDICES_LOC[285] = 0x05e1449f23a1f69ee7ab062d2b6de504f837ceea9818539f24f093f9e19d10bb; PI_POLY_INDICES_LOC[286] = 0x13b7c16f0a3dc759020f73d9e4562aeba9ad619887a1fb10404591b0b123abd8; PI_POLY_INDICES_LOC[287] = 0x112f034ef8bec10620e5ba685d029285415d24770089b29c066f4b93c417b065; PI_POLY_INDICES_LOC[288] = 0x2b1dbbae872ec6f35679540b86d31bd942a3f4d076812da0cbf595d98a47fc52; PI_POLY_INDICES_LOC[289] = 0x145b8bd898f4ad28f5e563bf56a0078447c2fd1d9c9c22a9848d24c4be014297; PI_POLY_INDICES_LOC[290] = 0x1d2298fbb9a9036a5bf7ae66f8977401bb63f96fd4c650162e7c990e2f42ee67; PI_POLY_INDICES_LOC[291] = 0x0dae2aca364d3fc13827b25722a2871a6a46fec64b9c0ba842e68fb7e10a3fdc; PI_POLY_INDICES_LOC[292] = 0x1cfd779eeba4d1bc23ea99172a68383a3f8e23171beaea30f6dc5c5ad2e42ac9; PI_POLY_INDICES_LOC[293] = 0x094939b8ce02bf0973df2d3845d207b616984d6adffe5bb16f4f9ee1fa0fa706; PI_POLY_INDICES_LOC[294] = 0x2c20525fce70e297d4c1e8fbff8010085d491941d285fd320e18280aeb36699c; PI_POLY_INDICES_LOC[295] = 0x13971a4e0029b2cc55b37e5e5fa66063aa9bb45622cd4a9520824efab2d5a95d; PI_POLY_INDICES_LOC[296] = 0x2be4c403354f4d04a3f853544804447031f33039bb7d2979309cc41d1982443b; PI_POLY_INDICES_LOC[297] = 0x0dd4804d2fb81b33a98c65de364b43bc6b0a7245b695c39df5e47f023a2147f6; PI_POLY_INDICES_LOC[298] = 0x211ef940a8f2f24baefde247ba32f1b23c46199e1bb6906346f8133948c3e531; PI_POLY_INDICES_LOC[299] = 0x1183c8ee411d879d80850bb5d57ea8646cbe98f4fe5f32994adaf7927d591f20; PI_POLY_INDICES_LOC[300] = 0x29569eafe5e71c1874aac22f421785fdf8c019cc3c7de2fc8a4c0be9b39935bf; PI_POLY_INDICES_LOC[301] = 0x0d2520947af225a9ea866a37f85f369e7a0c21cc8d3629a5c5ee5ab9cd775a05; PI_POLY_INDICES_LOC[302] = 0x0f85f73c1f140db03a13dbde2c2a29ada0414c787c206c8c600ac90682938c66; PI_POLY_INDICES_LOC[303] = 0x02106ed4f3139ace6572920d44465680bff3ae9c36f5da5f6bb44726402085c9; PI_POLY_INDICES_LOC[304] = 0x22ca01efb9bf0c3aaf6269d8092fecb2b4591ce5cb7283fe52b332b2250ac4e1; PI_POLY_INDICES_LOC[305] = 0x30391b560e12b944b3634dc4c6f218fa7ae9bae1d1f17af7c5bdaa8cd50cab4a; PI_POLY_INDICES_LOC[306] = 0x0973cc9ed5261efeccd0703d1b7382f6c32be4fe9d22a15251b9e88c18155256; PI_POLY_INDICES_LOC[307] = 0x09ebdafa1ed3698298a50f0a1616b8dfbcf80894050427ee63054f04f1079f8e; PI_POLY_INDICES_LOC[308] = 0x0b172925b6777a3c103fee01b5b97d3454071d7fdc2b37b49d11cae8052af1d8; PI_POLY_INDICES_LOC[309] = 0x2647f332f55c8fc69d097e796a1f1be963897601fedc9ce9bd11137bd288a29a; PI_POLY_INDICES_LOC[310] = 0x144e5bec8706fdc7011f132399f87e98cea37f92d055551e324c975490efee11; PI_POLY_INDICES_LOC[311] = 0x29fcc51d31d52b532b761a793f79fb3830e9e686ced6cd6ec681eadba7729f07; PI_POLY_INDICES_LOC[312] = 0x1aa321e871a614f1765b8242d1edee0b130c231b07ed8dde2f76a49c7ec6edbe; PI_POLY_INDICES_LOC[313] = 0x2bb092a9d8c886201c43ac87fb58edd33c9609ac9bdb64198a439e3b38e018dc; PI_POLY_INDICES_LOC[314] = 0x01fd855524b2452e60119f734af7ce9546aa3a1d277029ae296e7d1274713f3a; PI_POLY_INDICES_LOC[315] = 0x143f5fc1ff54df979b8226d29c8090a4779e3d6d385670e53e3f034a9ad9a3f3; PI_POLY_INDICES_LOC[316] = 0x1cc447d0913b13e74b04a25274e51316c7f1c33e171c2f90a77a833d03b48f2f; PI_POLY_INDICES_LOC[317] = 0x1cbe0d66c0eeae24d5292e06a77c5aa171cd6acc88f31dab101962e61dbfea17; PI_POLY_INDICES_LOC[318] = 0x009119b820827737b4492ef3c046e46f825c15d4b7ed9dca14c17a2b83cc3fc0; PI_POLY_INDICES_LOC[319] = 0x0e486541fd995226b207b01696962813511a6bdaff5e38e3ddcf74d184b9c306; PI_POLY_INDICES_LOC[320] = 0x1faba7dcb039f151bce64642ad21b7911c27ef727d32a8c7db0beaddb0db530f; PI_POLY_INDICES_LOC[321] = 0x1e1592a68e36cc25f1420599bf539fa81ebdf1f052e97db250fb8deb8c9305c8; PI_POLY_INDICES_LOC[322] = 0x1e8ac4166533eeae2521b693b3720ae8967bf9858f7be2e944c8d800b2103c4c; PI_POLY_INDICES_LOC[323] = 0x1c05f3c1bc9205c3e1da3ae117b833bb7654840c435910a355f016f134180e03; PI_POLY_INDICES_LOC[324] = 0x1222bb314c20284706d62b620389f3bff1424811d6ffd00b114e10c289f94282; PI_POLY_INDICES_LOC[325] = 0x03ef60913f978807cab09615faac9eae6005aa3c91e34f3a1c646c2a32e6d2c8; PI_POLY_INDICES_LOC[326] = 0x272397ab87b2ba27326f0b55aabb936e2bd735bad86d3bab3264bb77160fc921; PI_POLY_INDICES_LOC[327] = 0x1f8dd1c88b1475c35477ead80b785dfce3d9357e6eafa647e0eceeb39ebde863; PI_POLY_INDICES_LOC[328] = 0x0002bc3f8ebb4f63950903288a24c643f6e945587f709bafd0498a4a642ba4d6; PI_POLY_INDICES_LOC[329] = 0x16d0fbaed7a91d8031a174446e0c1c88a1315c4b9e2a05ae22fe66c8d9b62015; PI_POLY_INDICES_LOC[330] = 0x2888a5a5702b9fc495cd03ee2eb57177f8a430a8f7450ce625059ad2a07c2cf6; PI_POLY_INDICES_LOC[331] = 0x1f87d8a3e74c89854f9b630034ff307daf906ca592c6e2f11e1b25a601ed1936; PI_POLY_INDICES_LOC[332] = 0x042fd86608773ea8df256bdc07f1a9a62c3b890915e590c6ef2e3dfb0b0a0c83; PI_POLY_INDICES_LOC[333] = 0x2f0465f822601d0d0a3a57861ab0e7767ac1db5fd1b2d348e51aab8b2b62f20f; PI_POLY_INDICES_LOC[334] = 0x1c201c0df1db9616e4f280e19bf095a192a1e96ab6ec144717aa99d93a76c891; PI_POLY_INDICES_LOC[335] = 0x24ce45862da2e02229910fe183187e87e578535e98fe47f182dadba4dbd4101f; PI_POLY_INDICES_LOC[336] = 0x20936e815c1797e2cb7f22eb5c4ef9a48143639e5169faecb56f8dd01145b905; PI_POLY_INDICES_LOC[337] = 0x02f2e1b6f1322745cc847b8c1f2e1893741cd809f34da26980e4d4e5f68b791c; PI_POLY_INDICES_LOC[338] = 0x0e9d3fb69514e6b7d24fb2b11f1a052a382cf9155440516e9232f5c4405e2d68; PI_POLY_INDICES_LOC[339] = 0x1079e297f6a1f877ff243d66fff347d2d5a0573061dfb0629795069c371a1b38; PI_POLY_INDICES_LOC[340] = 0x0ea5dbbcf6ec89e4de2e48300e75d4f530f3d29932570152576b5d08464433d6; PI_POLY_INDICES_LOC[341] = 0x2d444b534f233da693c1331b01ae9e912450b80e592ddb1236ead81aedc77706; PI_POLY_INDICES_LOC[342] = 0x25476823deb86ec032a580127781a191e10c9de814f98457f21bad1870064b9d; PI_POLY_INDICES_LOC[343] = 0x11c0e3592e8eaadfa3deb4a71bac951807ef860617076dc58ce65c79725202c7; PI_POLY_INDICES_LOC[344] = 0x2f440d9ef9fcc36bb31b7a8098da94f17776aadfdf255dd2798a03d72332c387; PI_POLY_INDICES_LOC[345] = 0x0dcc43d50924b1e5df900c09905b3e53c415b9ef9653978406371822838c40ea; PI_POLY_INDICES_LOC[346] = 0x241111608ec85a75e42a19dad4a2c5b4978de809fc4ab2d6e4ee4af9d0ae3e26; PI_POLY_INDICES_LOC[347] = 0x2cb4e14e9e4b08239ff0cd2777d3e271673a71a3b7a1199bac02494c4fdb53be; PI_POLY_INDICES_LOC[348] = 0x033af352e838631d0a5385aa0ea84a49cad813a2e2c7d814e4e8d8b9544f09f2; PI_POLY_INDICES_LOC[349] = 0x06e42eb51202d1c91c2d997ba6af6bd4501feb642a4e2b8de04113da16401d28; PI_POLY_INDICES_LOC[350] = 0x2909b1b7c61aa7eadc0a6d381d3a3c99db264b54f2c2b201492b1d03386b6fb2; PI_POLY_INDICES_LOC[351] = 0x0c4a46a9bb0eb1fb72d731c94bdc8f19eab5a48eb017c59b467204a6eff60466; PI_POLY_INDICES_LOC[352] = 0x0e4e9f2871e6baab5074f3013150ef811cb9f150f4b500fa407d789eb4e0d390; PI_POLY_INDICES_LOC[353] = 0x1bbfe59d865a2e1d68f2dc7d6c09bf9079d3d8e8ffa5aa27dfdc3a04ba1cc3be; PI_POLY_INDICES_LOC[354] = 0x01e7289b0b7546f9b714a2bb7be7ae5ff5223f90086040a7720d8f131e3684b8; PI_POLY_INDICES_LOC[355] = 0x27cc8b0b9b431e69cc4adcdaf8e585d589263646de48631c2dffb18f11f58f8b; PI_POLY_INDICES_LOC[356] = 0x09b54c1498bf4d0db66a2635aae202ae5d96cace1276942a91b97041ef2a305a; PI_POLY_INDICES_LOC[357] = 0x25ecd8145910f384c2d750d80b5edbce88b7bafebe099ac6bc001e6cc3cfa56c; PI_POLY_INDICES_LOC[358] = 0x0fec2824e557fc16709b06c704c741d3158aefcec4a8877ff989b1c31a31596f; PI_POLY_INDICES_LOC[359] = 0x145a1f41ff4332ffb4c80dfb1700d49d9df1e593a49df643256b609d79ce5bc9; PI_POLY_INDICES_LOC[360] = 0x00208e211fb871a210d227a88404d7951b4922818504f72f4db0ae8792760b1e; PI_POLY_INDICES_LOC[361] = 0x0ab613d2908817c2cec77b692aef59330a83913d26671556707bdaf0ab2961ec; PI_POLY_INDICES_LOC[362] = 0x151e57526a4e3dcaab77302cbdc75ee2f9602e8598581eb3ffcf7958fce24b58; PI_POLY_INDICES_LOC[363] = 0x227e34df79f35123c592adc0444f3ad88bd020c5b8029ea999e7d361ed8e3eff; PI_POLY_INDICES_LOC[364] = 0x19989471f1b1b2b2d026bcbdbde5be002b6e4bd4fb2e9176047f110fed8fe942; PI_POLY_INDICES_LOC[365] = 0x07c53096f27fd1cd5e435fb4353631e32b8b8bd8e0c2c3936e077329dc1c547e; PI_POLY_INDICES_LOC[366] = 0x041e7e72055fb5e3a3bc887bd077eb7284f7cadb9d811ecc4e602afc8e8ca3ff; PI_POLY_INDICES_LOC[367] = 0x2701183c99fcfb2bd542b18bb92c3db5750caf221c654ceafb0433544e8b4723; PI_POLY_INDICES_LOC[368] = 0x17601b89959960507d1831ea4bdb2b44c7470d78baf2b988987fa08a8ce5902c; PI_POLY_INDICES_LOC[369] = 0x02f65dc5eaa416920d1835dc18cabd4a62fd0fdca0089d7f35c75d49503e1dbd; PI_POLY_INDICES_LOC[370] = 0x14e4926de7eded675ed7c995898c335007fb3c65c9fb972dad087a8fcfa7c790; PI_POLY_INDICES_LOC[371] = 0x17feb73ab07bfcfc9d4ce0a42e27a631eeb0846b8ffde0305a0cdd0c98e73b2d; PI_POLY_INDICES_LOC[372] = 0x277d68a421a708992827d42e2b17df2a675716bbd3953b7bc43ecdb739c94f4f; PI_POLY_INDICES_LOC[373] = 0x2a3cc19b43337755b3f0b5c8d1f9fc39447db96bab6e5620404d80c139305d7d; PI_POLY_INDICES_LOC[374] = 0x3047a480a22d7cde55875b7bfc3532abdb18067330b7a7df8949229507682689; PI_POLY_INDICES_LOC[375] = 0x0659938d7196326fa9210d7cf779500fd1e1c5f8621aee251d6b20943cb0d99e; PI_POLY_INDICES_LOC[376] = 0x1c635646b2710684420eb7de84f8da2d95092a5983f101f751b964e5fe8f2601; PI_POLY_INDICES_LOC[377] = 0x2ff00d4cf99e561192f4c345bcc23bf053ffeaff07666e4c0b87c2a95d3a1212; PI_POLY_INDICES_LOC[378] = 0x0d60405958cc8db8a78f172d58c7fb3c291d369e42741fd750b118fe9a47893e; PI_POLY_INDICES_LOC[379] = 0x1efd8fced30c571d56970ceb025b65cf795a849e730b33617ada64559993e200; PI_POLY_INDICES_LOC[380] = 0x025699da7447ebf559b74bb4676f62fac0851ad6d0b5493975d7f63d551ca44a; PI_POLY_INDICES_LOC[381] = 0x2d293536c0d8220d651178e7ce3c3f85016dda60a9c199759b4577c4927ea6b6; PI_POLY_INDICES_LOC[382] = 0x147d3484ad6f04a2f22b02acba90e8338973f43bf0ea5516b1d69e57ce3de724; PI_POLY_INDICES_LOC[383] = 0x17e6c22093850557a5a4338a657c78a9fb1b3f29a2eadcf5cd2b53593d8ba987; PI_POLY_INDICES_LOC[384] = 0x0acd6feebe6036743ffbb1ed356965cd7886d886d4acae340a011f08fb850a90; PI_POLY_INDICES_LOC[385] = 0x15b3c7bda77e375243ee4f16307a19e399a73dc8c541e1cf38dfec42b44ab3eb; PI_POLY_INDICES_LOC[386] = 0x073654d37e527ed17bd86b4a11e1867d57dfa5da5fb56fb985154eb1ccfddeac; PI_POLY_INDICES_LOC[387] = 0x155f72cf278c8cc13d112a6bb1a2e58d8e398b128b6174e5ebc092fc9bf58e39; PI_POLY_INDICES_LOC[388] = 0x25afb9472d4001cc3583b76f6af5829ea9ab3284b773ca69459221004e16ec97; PI_POLY_INDICES_LOC[389] = 0x0f02c767c968bbac0a0435b5512c871d26b1ca7bd3c80296c11d22971dd82659; PI_POLY_INDICES_LOC[390] = 0x2964a6970156489c16ed58ef8e60f4df65397d0c8c31f136f6b51e55d04befa6; PI_POLY_INDICES_LOC[391] = 0x03e7e75c9bda03efc257d1ace8a805e34036daffbe1f1c3c76bad67d44f76515; PI_POLY_INDICES_LOC[392] = 0x0e5d6161e7f54ace6c9efb918ad17e6960e68de512d22bb8570e31fe9c40d090; PI_POLY_INDICES_LOC[393] = 0x21494debe103af982dc523b44b394f3b05275c8fe9bae7a4125df2f23f75ee56; PI_POLY_INDICES_LOC[394] = 0x1a015806c8e846e8acd371d153d5f76fe4d4497b81ce606811b4af82f6edd3e2; PI_POLY_INDICES_LOC[395] = 0x28c1418420a929346bcb9ee27f7d6121f6e4bdd07d915e0f283591ba36bbc1a7; PI_POLY_INDICES_LOC[396] = 0x04fbb7eebe1abaa4d22745df26648b885b7309140f94e009bfa41b0caec5d4cd; PI_POLY_INDICES_LOC[397] = 0x1b14f78d2e120d4decd0096152356a2e513d05c99ad443d8e9a584195399e628; PI_POLY_INDICES_LOC[398] = 0x28d12c081eae177aea2e2e28597c4aeebcdc1f1bea60aaddd5c7d1185ff60140; PI_POLY_INDICES_LOC[399] = 0x274acf85b1c7cb921d14be98cdbd805180034abd1418ce1d0a5cd7ffa1c74984; PI_POLY_INDICES_LOC[400] = 0x2f07fa81d1cfdf7ba0a55b1087b915761eccd1c50679b829de52be088fcf96f9; PI_POLY_INDICES_LOC[401] = 0x0ae2a5c59deed0031696b5346c3cf5e70702fe8d91ad514e6358526ac89c9080; PI_POLY_INDICES_LOC[402] = 0x2d093d7e6d21bbb9119b4051e972627ccc740773f737707472d4a520d33bda27; PI_POLY_INDICES_LOC[403] = 0x27abc1b98137c4d86f190b10cc43a67d5f6e404e33c4b23ccd421d2b78586120; PI_POLY_INDICES_LOC[404] = 0x0bb99f23eb933257360d349d4529e3c218c110ee1ef7d68becd78d8fd716211d; PI_POLY_INDICES_LOC[405] = 0x2af26878f7751edf6f64c1ffca5a7831a25fb5aef5bcd122b3d612dc8c46e5cd; PI_POLY_INDICES_LOC[406] = 0x0ac9b88201ba18062589b0e6f7f3fd960d5b2438345441735e11a979ecd69067; PI_POLY_INDICES_LOC[407] = 0x1ecefa8f766af3d7e3d21d07b076c95908e45c83feef22b727ca83dbb65225c2; PI_POLY_INDICES_LOC[408] = 0x0520e3554390eccd3726fcb5e7145df5e0ea20f91c5b4904bb1ad746aa2b53b2; PI_POLY_INDICES_LOC[409] = 0x0a4834e6fb18b7b9a3f43db66f39688f2afdd278a8ca0eba7f46d146d7a0d7da; PI_POLY_INDICES_LOC[410] = 0x14c60185e75885d674db4b3f7d4a5694fa6c01aa0f53557b060bc04a4172705f; PI_POLY_INDICES_LOC[411] = 0x096b821ce1d748932f663d77de0e79fcf4b5dbe154f904827c076cfe0f0dd4c0; PI_POLY_INDICES_LOC[412] = 0x1dfc56cc4e856696a08d639de83d8557ccf4e508ca2fe74660f44c6554cdec33; PI_POLY_INDICES_LOC[413] = 0x104f84d3cb463438fc7df1ac7f84a4b62aa2b9d0e0926183e41e92fbe86c8bc8; PI_POLY_INDICES_LOC[414] = 0x2aba1d7068aa01777a52a5dd33fdddc7ba9f13cd6863eb7ba0b5a13a7da90639; PI_POLY_INDICES_LOC[415] = 0x28f1eddfe71e5a6c6eff794bbfdc23c754e609f60b75cd68cb1687113b615645; } }
// SPDX-License-Identifier: UNLICENSED // Generated file from uzkge/gen-params, DONOT edit! pragma solidity ^0.8.20; contract VerifierKeyExtra2_52 { uint256[416] public PI_POLY_LAGRANGE_LOC; constructor() { // The public constrain variables indices. PI_POLY_LAGRANGE_LOC[0] = 0x21fa6fd3d6c579dc04b25d6a9090749502e9bec8b3022db2b54312c10dfa6ef8; PI_POLY_LAGRANGE_LOC[1] = 0x12ba7d199b257a69c128103f3720bd0ef881ddc0abe14cc836fd09293db5d8f5; PI_POLY_LAGRANGE_LOC[2] = 0x21193fcf391181e2cd242ea58d7384f239dd1c6cf91ee96449ea452cfcb6810c; PI_POLY_LAGRANGE_LOC[3] = 0x2841c58d54b8fa52f690622c43b03b624ce98dbb773b8d65fb2906bd7bf7718c; PI_POLY_LAGRANGE_LOC[4] = 0x06bf83811c9d04d6ecbcbda8efd19de2da83b97d0d56915be4baa4941a800d73; PI_POLY_LAGRANGE_LOC[5] = 0x2563fdef9f1a4a1b76c55334c1e767865004395b0cdfc2a2d4381bf0f87e6edb; PI_POLY_LAGRANGE_LOC[6] = 0x29177b6440270d1b262cff81d62d436483f70ff7c5fdeb6ac2309cb79d2812a7; PI_POLY_LAGRANGE_LOC[7] = 0x122af85148c27724ad9008869985830829450d89010483dd6f91c3e82f3c7f7b; PI_POLY_LAGRANGE_LOC[8] = 0x05cda12b5cd1d5463aef0a28d6cfff8de5952e1354f830472f5b2e23fc497f44; PI_POLY_LAGRANGE_LOC[9] = 0x04ac75565c47e3ef514d76760309292b594bb809679a429b4044aa93d75ea4f2; PI_POLY_LAGRANGE_LOC[10] = 0x0dcecc5f71f8fcdf40578d8a1ce3c1a3e3a0dc4428b65a02e1dc2e8487984102; PI_POLY_LAGRANGE_LOC[11] = 0x0694c38595127eff8e061cd76ae2c2cb441c234369900ffde5d910be501b45bd; PI_POLY_LAGRANGE_LOC[12] = 0x1376ed52a1e562058473885b5f2d4a59bc0f7db8540b036fec0a273adaa15889; PI_POLY_LAGRANGE_LOC[13] = 0x22353ce121e6f70c8d648110bd393811fdb1015396bab9d917733ea262c85bc9; PI_POLY_LAGRANGE_LOC[14] = 0x1b2ce77e227952983c05bc9af153e294a8e2ca7dc7440b06bb3830a0b603900c; PI_POLY_LAGRANGE_LOC[15] = 0x07b6f59fdd7075fcea5694bc7898a4500873579b10dc0bff68f0be80a64c0b60; PI_POLY_LAGRANGE_LOC[16] = 0x2a29999dd168718bcc7b32b9bc4623e91dac14778c2a6bbd29afbc4ce623f3ae; PI_POLY_LAGRANGE_LOC[17] = 0x07310dc64cd43c9bfbdba9cdd9634d93279b905f9714137a562b7c4c778fdba2; PI_POLY_LAGRANGE_LOC[18] = 0x15f73b7930712f23a45b4c1ee572e767a0c6624db22aed9f69e35b3c9619c1e0; PI_POLY_LAGRANGE_LOC[19] = 0x28a757a094d5f8264284aaffc9f640dfc8934fa5c9b82e78fd03077b648fe9a2; PI_POLY_LAGRANGE_LOC[20] = 0x2de2b11e11090563f61e1cfa1e83a462de9895540c0d23125768fea29427a634; PI_POLY_LAGRANGE_LOC[21] = 0x194fd1ee3e97e015e8debb0e0d3ce3caa9323040f2b26fa68f17745078549ff4; PI_POLY_LAGRANGE_LOC[22] = 0x1bdd6d38e29fc668e7c53587288ceac4f6f2a57871c82fdf434f5d9100a2661a; PI_POLY_LAGRANGE_LOC[23] = 0x1187d8ab13b2bdcde3feb9afa741346e403689b4f777f33c98b5ec0deea8d844; PI_POLY_LAGRANGE_LOC[24] = 0x1c028b06cdbd5a60b707e11ccd9c06fd237c9858c96054b8388f9bf213bac03d; PI_POLY_LAGRANGE_LOC[25] = 0x15f2757274a3c763ce0888a86a6cc96e6c8be4a428284c79f23c808890d9e5ab; PI_POLY_LAGRANGE_LOC[26] = 0x06644c6a67bf6641502822fdd262e2137112077d235ecaa714412c08ea74598e; PI_POLY_LAGRANGE_LOC[27] = 0x08be36ad807584b54eac75b47cd0fd8de23cd81ca5041ee768da1984720df532; PI_POLY_LAGRANGE_LOC[28] = 0x2080ba2e994a08add5134abc7e1f138b252a71069091430af9779107422335f2; PI_POLY_LAGRANGE_LOC[29] = 0x13e6914c24460fa561221f6360de641c8208e5ad0884af23d08992bc2b97c6b7; PI_POLY_LAGRANGE_LOC[30] = 0x19e390c5e269610fb859d17977afa30020bd208f1cf582560b2fbc171f89f3ae; PI_POLY_LAGRANGE_LOC[31] = 0x09f9da59f60e71027aac79d851cfd36a0b8656245162da4b06ac76f93a586110; PI_POLY_LAGRANGE_LOC[32] = 0x0fa5a7da711c9875481f58101f2d20ccc70d9092a1422ad66c1565d315d0adf8; PI_POLY_LAGRANGE_LOC[33] = 0x003724360bd4ae26663c4f2417045eb30190c27aa5491999177b6469baa27c58; PI_POLY_LAGRANGE_LOC[34] = 0x18abea39582e1cc567187719abef8f17893a55467f0706de55d75fbb5cdfd473; PI_POLY_LAGRANGE_LOC[35] = 0x0f5d60b93e47837bd69aa23d67cdeacf1ca91ffd9f3ba367955bb4806fa58077; PI_POLY_LAGRANGE_LOC[36] = 0x179d53545696e92e8e2ebccb5170113ae07635ee698de4494944f844b2c3e6e1; PI_POLY_LAGRANGE_LOC[37] = 0x080c8c6a7060e0a79a1447208734bee78c089da28ae557ae7bb6d9bc51e7fb96; PI_POLY_LAGRANGE_LOC[38] = 0x27b980a51f23c271c2b15e0da5d89fc0c9a4613299c7a5df33294981007390bd; PI_POLY_LAGRANGE_LOC[39] = 0x1c012d7b8bb9f62811e8eaa4cb1abfcf9033d9dd5edfb9b80edf76962647b0f2; PI_POLY_LAGRANGE_LOC[40] = 0x1d12c1582f8e15724f7ef357d73251bcc0934de165e27f8d957ebe6273846986; PI_POLY_LAGRANGE_LOC[41] = 0x130fe590c21424c9e95155f2f922ae9d768d31edb3ae4d303e89fc1ae722b762; PI_POLY_LAGRANGE_LOC[42] = 0x14938fdf9bd795465b57aa868a507231d9bb02cffc4fc442572b54778051b7e7; PI_POLY_LAGRANGE_LOC[43] = 0x00337d4979cbbe95ea57cdbf4348060754a8dde839d0141c6892139db3a27949; PI_POLY_LAGRANGE_LOC[44] = 0x130a30b50847222cdc3e4a14db0d37afa7af05e961749c3fb2d2d4d2adcbf17b; PI_POLY_LAGRANGE_LOC[45] = 0x165ba3de45edf17d1e0375bbd35cec733181d4e4bcfb8e4dcf4f19cf79d4bd16; PI_POLY_LAGRANGE_LOC[46] = 0x0d6b3cf8338f74373e9d710ad980603b9449e1bb8aebae3b7cb200de6bd11ef0; PI_POLY_LAGRANGE_LOC[47] = 0x1bda5e77e3cb2fdc0ab6bc5afd72404e0f938b1d66381ed038fee831573231a5; PI_POLY_LAGRANGE_LOC[48] = 0x0702eec10e3a7ec28a8fe168e2b830200888cd4985d435ae37c03fb79ed02683; PI_POLY_LAGRANGE_LOC[49] = 0x232bab79060bdf4fc90979827b506df26499d217229de7d0f92130ace14211ba; PI_POLY_LAGRANGE_LOC[50] = 0x2d8d1d4d6e857638d693b6ae573a281c7a67c5255a02505ad4fbb74ece6e64a5; PI_POLY_LAGRANGE_LOC[51] = 0x0034c1793136961b02691e31ee274016caa14426647214d9fca633b7cb386349; PI_POLY_LAGRANGE_LOC[52] = 0x2acea18f3cbca7c2a77b3c57c3c018da115bba117be8b0156d89596e4e5d16d8; PI_POLY_LAGRANGE_LOC[53] = 0x15e8911bf36a6c4f8c399719ef59c4791bf248bc4d4a1e475377c7e4812e71d9; PI_POLY_LAGRANGE_LOC[54] = 0x1841e7e90af9362569f57b5437832f25c937b418db5bb3f0e8280d22adaf01f5; PI_POLY_LAGRANGE_LOC[55] = 0x27474c77fc2672fcadadd523185175800638e0d7e50a2df21d9600a1e75ab6f6; PI_POLY_LAGRANGE_LOC[56] = 0x1c7e3ae57d2610e0575c122cd912e49dc708376d0a7e2c8a82d988a583fb75ee; PI_POLY_LAGRANGE_LOC[57] = 0x06d53257ad0a89591d170d54c003ac8dca42a137cc528846ecf2b8a3d56edf52; PI_POLY_LAGRANGE_LOC[58] = 0x18d6eb70b567cc1ee121ce31f99fca780deb51bfb1e6e9288b6ffe810295b054; PI_POLY_LAGRANGE_LOC[59] = 0x2fd0e771170e4ade3fa7ce85b501e32dbad20f1ac58b13b47dba4995410e3dd0; PI_POLY_LAGRANGE_LOC[60] = 0x05e5c97d6a06d8d11bbd50c4f81f692b3ae0445b4a19b03b71a4770c6eda0361; PI_POLY_LAGRANGE_LOC[61] = 0x2bb6c8c7d090fbc82238a0fe1d922601f9ed23082533d4aded72c87463ab8f83; PI_POLY_LAGRANGE_LOC[62] = 0x0561e9f063dc608f6a5a65455237d586d1410f7cd7c182eb48982c77822225c0; PI_POLY_LAGRANGE_LOC[63] = 0x0773f9506a6844e637d7bbcf7a8d883bd51d2b3430431c4e60c71d9f2c2bce02; PI_POLY_LAGRANGE_LOC[64] = 0x12dc718fe15ebeca8186d6fce6ce6e90a08acde15d1374ce8e50398c14db01eb; PI_POLY_LAGRANGE_LOC[65] = 0x104b5ab77cde0992719e555a343d5edfc85456e1580a82620bbd20f299e8b295; PI_POLY_LAGRANGE_LOC[66] = 0x24fe424a791ba6e372fd01460865e54dfc16d4cb5ef6db8cbbd26c765b0fcae7; PI_POLY_LAGRANGE_LOC[67] = 0x2285c341c826b072c62006c144e6f2e1b6141e0171d1463e2ea7e7fdd5f61d64; PI_POLY_LAGRANGE_LOC[68] = 0x169e8e521b915295ae18fc2228844c991b3abe8374865005df0e2ddf6d827ac5; PI_POLY_LAGRANGE_LOC[69] = 0x168622bf7cdd4606a880d7e71a6928880ab84d5b8e18aa85f71dca05f4a71e82; PI_POLY_LAGRANGE_LOC[70] = 0x0f1f733e6bd6d249e1da36a2a13bb4e5aa1a087e5c79c9f2afee8eb8828327f7; PI_POLY_LAGRANGE_LOC[71] = 0x1f4c63b4786ca41b13ff43a8f06ff6f08224c03e393500b918d908c298d9cdba; PI_POLY_LAGRANGE_LOC[72] = 0x2b41825a454bbfd11179527285baead9a24a2c5aca78b2bf69c22930051c3a27; PI_POLY_LAGRANGE_LOC[73] = 0x2f1924fcd4bf6fc6363d0ca866cd5aecbcdb86df3b0b4c76fce1dae3e44869af; PI_POLY_LAGRANGE_LOC[74] = 0x09ce7871a2e2d80c026f5cc7a9e433b63d455fae766d16be08e1f7611367507e; PI_POLY_LAGRANGE_LOC[75] = 0x0bcfb8ceb0307df09f312ce08e2cb66c9590f12480fc55d91b4427f44529f2a4; PI_POLY_LAGRANGE_LOC[76] = 0x1ae5b232530613e409acd85ce9c7a24c11deba94fd46817233e8dc4c6d67d39b; PI_POLY_LAGRANGE_LOC[77] = 0x0b78cbe22040a8e5f0132c20883843e8e1e52ae867c36f689b5709455865e8dd; PI_POLY_LAGRANGE_LOC[78] = 0x13c9b44f4316e39c2f44554f8e2201327085b2d9f01d42a30870596a32fa1cda; PI_POLY_LAGRANGE_LOC[79] = 0x270f225eb2f2751020b77f3928442e2bb62b1643a37caae2b1d5905021434dce; PI_POLY_LAGRANGE_LOC[80] = 0x0cde3db1316a5cdd99a9d095f4e0c4e8c09e74c65b1286a40d0d1144c1009022; PI_POLY_LAGRANGE_LOC[81] = 0x2fb104c225536ec1f995f864addb01486276e19c4692b1d46c1ac40411dbe3da; PI_POLY_LAGRANGE_LOC[82] = 0x15e4d5c9322b4e60ba8acf3fa00c69eb80b88d72075d86e3084eac29a056bf27; PI_POLY_LAGRANGE_LOC[83] = 0x212224c6f07197125439005a0bcf38dd8ebd65c830c287e7bba5a411b324a7d2; PI_POLY_LAGRANGE_LOC[84] = 0x1279404f0d667373dc6ad7eb830c901a977f1d554f3338cc8c91909545102a64; PI_POLY_LAGRANGE_LOC[85] = 0x1eb138da7abf1a3c8603de5ad228203fbc99d6177d4947223fbac4ae76257ea5; PI_POLY_LAGRANGE_LOC[86] = 0x0cff03028e2fbf3c22de7e8cb64e635a0848a21d6cd2f2b151a8182c4bb8cf81; PI_POLY_LAGRANGE_LOC[87] = 0x034d20e47298ec52750ee5d521ebe4c4df001ded0ac135e721ca469b699db7b3; PI_POLY_LAGRANGE_LOC[88] = 0x2699302e5f7b96d77bc0af90944b14471e41eb9fd5ae39086ff20f9bacee4225; PI_POLY_LAGRANGE_LOC[89] = 0x0e9ef12e7c7945ef3edc348a9ddbda5ae70977e72a06252a8d1f356c6c433436; PI_POLY_LAGRANGE_LOC[90] = 0x07217c0a2aaaba6224b6d77269f5df0f77ed1ead425fbecb1b0284323c5e980c; PI_POLY_LAGRANGE_LOC[91] = 0x1ebaee57320d15b96f6d27167ead979db250db51b1f20cedf3b86f72900d1ee9; PI_POLY_LAGRANGE_LOC[92] = 0x18a879d849de54b6dd1a62ac7dcf774448b7768a639493d673895f35792b0cb7; PI_POLY_LAGRANGE_LOC[93] = 0x20311779fe7e500e75d4e03d03bcb7d48756ddc6333ed456c403e311b95dcf49; PI_POLY_LAGRANGE_LOC[94] = 0x2720143dbbc9f92f2f2254dc444ed5b5add0303ad74c2979c1b80777d3c8fbdf; PI_POLY_LAGRANGE_LOC[95] = 0x2eadd0fe3f0ceb77d41413ecc87a61ad19a7931d7f8f93378453035c1f3907ca; PI_POLY_LAGRANGE_LOC[96] = 0x023d0c3b9bee3ed6f953a1b1fa9781c7a322dabdc536bfdefec409da655236a1; PI_POLY_LAGRANGE_LOC[97] = 0x12e7f1c4a6ee1258bb89e314e43c35077642c7f9bab71b71b41f038a34baa952; PI_POLY_LAGRANGE_LOC[98] = 0x26376362374692d0064917986a83ad5bc51126de24d9fb9e553d56efbe9ce48c; PI_POLY_LAGRANGE_LOC[99] = 0x1938f92b7abe9313d2ac5e98ab64850330cf219ded0d02535880cf3fe4b0ab4b; PI_POLY_LAGRANGE_LOC[100] = 0x21b0b0beea506008c9d923f453a32553d4692a0a7d1d154181b3f5e13128e3d6; PI_POLY_LAGRANGE_LOC[101] = 0x1848630dc13221e60aa4454422c30c8a74d64dac0ec7dbe16467fa3a0b34366a; PI_POLY_LAGRANGE_LOC[102] = 0x281c59d781df10595a83f66170cf2b34093f0b1db4d40b185c4ae7911df64cd4; PI_POLY_LAGRANGE_LOC[103] = 0x1c2af76e4ba5a416a088d443c98c2c8fbf2d2efe26bcff56f90e143703ff0234; PI_POLY_LAGRANGE_LOC[104] = 0x095e784742fd551482aa11b2a5406dd4f5683d41bf6c78e77606236a3b2df877; PI_POLY_LAGRANGE_LOC[105] = 0x199c93950f0ad131cdfea4201f0283b48c2df388feecc5ad032176823f4c30ca; PI_POLY_LAGRANGE_LOC[106] = 0x14f5afdc63133300caa8cb2d84ec42f0379d3a7cc79128549fe66fb74fdb6092; PI_POLY_LAGRANGE_LOC[107] = 0x093a638cf70cb6bc9207b989be34848b6a2fd5d0bee95b56d8d7eb734e0f020c; PI_POLY_LAGRANGE_LOC[108] = 0x27f40efd9f88ec7187c61fcc8ce90b0babd3c67365c3cfd9f2c56b0dde7142bd; PI_POLY_LAGRANGE_LOC[109] = 0x1baaec5f5c2449e74e040f70fe1ed6035dbd566e066f3e32e018cd2428e74fa1; PI_POLY_LAGRANGE_LOC[110] = 0x2b787f745fd8edcf8156c244e8e9903d7ca84b6e72dd471e43a6cde54b3a369e; PI_POLY_LAGRANGE_LOC[111] = 0x23b2781c327cf04aec6d39792f08151a0d3473a5915b784ce5503f80db578ad6; PI_POLY_LAGRANGE_LOC[112] = 0x22d9b0f4cb9f8eca6f6a1f747bf726c391cda8717b7fe07213328faf25fe3728; PI_POLY_LAGRANGE_LOC[113] = 0x09f71df95edfa35076e4bd83fdb5ea6730036ef66546c4149541688e262e7d09; PI_POLY_LAGRANGE_LOC[114] = 0x076efaa2e038a844217e67ce51b0d90416063c1f53b8e3a45d083bbcd4ff4f5f; PI_POLY_LAGRANGE_LOC[115] = 0x06431ab5dd65c89c22ea74a701642a0924e16e0b640262df2e1ed4d16b691f10; PI_POLY_LAGRANGE_LOC[116] = 0x29a21c9e6a106d3c6e0c4fa0b88ddab06570ffec65a6eb3ad7c03259184a71bc; PI_POLY_LAGRANGE_LOC[117] = 0x045ff07d8587022ad2e4d085db8c520bf46fb726a0f448a02955d6b07621c98a; PI_POLY_LAGRANGE_LOC[118] = 0x029f0751ece09844d0bf7a2712ac18ebc991d8580fa731cc532554a7887cb7eb; PI_POLY_LAGRANGE_LOC[119] = 0x1452f02e374c820f9fd5a7849fd0a03858256e642e6db00cb1e43da28c19da33; PI_POLY_LAGRANGE_LOC[120] = 0x0a4a701e4058b4844fad9db8e9d4dc0e8299fb319746c4caf6ee08866c7e7e4c; PI_POLY_LAGRANGE_LOC[121] = 0x18f1c4010dc79d40ae5443ca7c1dbf555559d5bb38de1a9de0ba7a10184bf62b; PI_POLY_LAGRANGE_LOC[122] = 0x277844f31297158af73a1590178241894b939cf0b2eadc33dc67b43f02874bad; PI_POLY_LAGRANGE_LOC[123] = 0x0446e25e60e9bf4c4efb0c416fbbec8cb9e2a3668d505bbfb2b9a76a4cc484e8; PI_POLY_LAGRANGE_LOC[124] = 0x1274f3a5daa62713b6c4b1dab991f619ef98e4596df0a6044df2418285396ca0; PI_POLY_LAGRANGE_LOC[125] = 0x1637310c102f77031021354a563a81ac6ac99cd38e6b09dfc480fe926948ec2b; PI_POLY_LAGRANGE_LOC[126] = 0x267c7ef1aef69389f1a0ed23611f55ebaf625ed174c8624530c06e951298420f; PI_POLY_LAGRANGE_LOC[127] = 0x2de78f93166d6ce2877d9c3df79ffc52a29e2f8d0a92a2c06fa24d9b8ba1eb33; PI_POLY_LAGRANGE_LOC[128] = 0x2fa888cc43685b73ace5de007e73470fde45f4edb65063d22d575e843790f0dd; PI_POLY_LAGRANGE_LOC[129] = 0x07a29cae974198cc314543456579731dbf0651daea6d86426f8d28e88e482d31; PI_POLY_LAGRANGE_LOC[130] = 0x24004b55d61d984e4448dd061b1b09a0b055093a8bd34471585c8a47f952edef; PI_POLY_LAGRANGE_LOC[131] = 0x24dccae8c328dc316005a18e85569987ef95c612fe325368bdfa9125bb9fb6fc; PI_POLY_LAGRANGE_LOC[132] = 0x1506c8e9c7427274a66e4d1442523bda247a560a64dfc959a24597d1e5cc398e; PI_POLY_LAGRANGE_LOC[133] = 0x02da66f5bd5dbfe09f5951688954e57c3cba399dd7e997f8f800b9f2fa6d0ed4; PI_POLY_LAGRANGE_LOC[134] = 0x2e54cb05ca828b05a05c82e3feedf4e37fdaeebc1a1a8e6d3c1bce92a714552d; PI_POLY_LAGRANGE_LOC[135] = 0x12859eafbac6db4efaaf06f77f50c5d54210bff123b09cb86b4d89dfbb6a91d3; PI_POLY_LAGRANGE_LOC[136] = 0x06dc8a14d1f6dda4db0dd4735aeea9bc695357e6ab434a668e71f9feff7e2019; PI_POLY_LAGRANGE_LOC[137] = 0x2a2ba76b6d4eb2ded13f79a61ac0db74cca332082019e5d28b758fee4c2a3db9; PI_POLY_LAGRANGE_LOC[138] = 0x1996cf46453d15f63aa9b0341f8731fdecd306fd69eed2306959c95e95586943; PI_POLY_LAGRANGE_LOC[139] = 0x20d1f1f673d842f68ddc8b86d89bf13cb1d5b8b2a0b5cf90aae996c42f1ac857; PI_POLY_LAGRANGE_LOC[140] = 0x0951fad3323e6373262c73881ae916bc2677b5500c05fcf40c183aaed009a137; PI_POLY_LAGRANGE_LOC[141] = 0x062d16b73b997aabc28948b2f7046455a5434fa242b9456232149a5f8a41d247; PI_POLY_LAGRANGE_LOC[142] = 0x182363ac7aca8902fe2f4a2e753eccbde9ffaa554359a0eac12cac6ed8ea6871; PI_POLY_LAGRANGE_LOC[143] = 0x0607192aaf63d7c5f80b4561fe87b702c2ad6867812cadf9df5362670bc4071c; PI_POLY_LAGRANGE_LOC[144] = 0x041128754cbd4d78e13d68489ff728456c61528c863497ce2a93f9fcacdfaca1; PI_POLY_LAGRANGE_LOC[145] = 0x0bd6572cf4ca30a9b779f743a6d2403667458d8c5f989859a58b684779552b0f; PI_POLY_LAGRANGE_LOC[146] = 0x2515ddc102bdd1a31a735ff927c4ecca3e769c30d3ff2accee4e09b2db28660c; PI_POLY_LAGRANGE_LOC[147] = 0x14d269f27e13c3d7cc72423fcf2e6ad775e8fb6a34123e46f32fda1da8b3f227; PI_POLY_LAGRANGE_LOC[148] = 0x1a1b5f42a9b0540b04036f48d1ee51bf06d41c9589a8316b2a6fe1b8fed6bb41; PI_POLY_LAGRANGE_LOC[149] = 0x2af7c89240f41919556a25499bd5ecf5f1335e36dccf72f0fc40a82b978aa20f; PI_POLY_LAGRANGE_LOC[150] = 0x165bdd146a08b4936684ff4b559e9cd45d256c3d1e05eec4231a2454323faf7b; PI_POLY_LAGRANGE_LOC[151] = 0x1cf4b49421b2c4b8a2d9bf05b35258f2575e03e6d714286c9382f1a5c708b81c; PI_POLY_LAGRANGE_LOC[152] = 0x197b16cf3092ebb36ae787ba8850c1b8efe93b590f18b8e90fcbfd28d9a93d22; PI_POLY_LAGRANGE_LOC[153] = 0x1149f556f6598a0b109ca4358b8b15369d1b84ae7f03be9ce3a0ad3553336fed; PI_POLY_LAGRANGE_LOC[154] = 0x11239c6b5cb8fb916b4f42edbc126afc2d51e8990e172a2a79bf8031376bfae5; PI_POLY_LAGRANGE_LOC[155] = 0x0fc8db29957d14f60cbcfd17dab2c1a9ba818b536061d1eb9ee7300d47272c31; PI_POLY_LAGRANGE_LOC[156] = 0x27957c6239991bf1ac62f13fec546b7c8bfc1f32b123145263f01defc35ecd94; PI_POLY_LAGRANGE_LOC[157] = 0x273dc20e3f28dfb2ce93d70bb1a41571df6798650776fbba3a6143d9621b7669; PI_POLY_LAGRANGE_LOC[158] = 0x21ae6c138e1dcfbc99990e3a6d0111638d1402f60c1dfc70845e9306b1ae8f35; PI_POLY_LAGRANGE_LOC[159] = 0x22a21a118b73226738904fa0a0aaa9d23cb03dd2b91f3efe2ab4ec12c11ccaa0; PI_POLY_LAGRANGE_LOC[160] = 0x280c4efed91c41719a0108e9321dc8029017ab3862ca14491083d8abd216656d; PI_POLY_LAGRANGE_LOC[161] = 0x078c4ccdf32ee9807b150cdd0f9988775afdceff710f8daacc2277f941d0a6b4; PI_POLY_LAGRANGE_LOC[162] = 0x0d7f4e78c97d39ac7a1e16afaf46318c07d6a407f87f8a36b4f0842670814189; PI_POLY_LAGRANGE_LOC[163] = 0x24296535cbf9b42506091e44ee34f0a835e2fb53b7b003301af4b4f0e831e57e; PI_POLY_LAGRANGE_LOC[164] = 0x2cc204060e4e59692af73ced6c2d759434dcfd2a10c6c9c5bf7d94877435ba3a; PI_POLY_LAGRANGE_LOC[165] = 0x002d590169e72a9d8bb31b62b942550ee8f1533f0a3e582beeb6a9f3cfa3ea23; PI_POLY_LAGRANGE_LOC[166] = 0x2d6ac22b69f84909569d60474f1a0ad788d5e88055c454ea97df2d9b40e344cc; PI_POLY_LAGRANGE_LOC[167] = 0x2ced65fef09428686ccc329cb11370874e0711a715b3494c9b25d736ed614b49; PI_POLY_LAGRANGE_LOC[168] = 0x16343252651f3fe0dbd453caa4016b1e1dad185685e1f6912f7ca13634a07d29; PI_POLY_LAGRANGE_LOC[169] = 0x13d9b84e66a33c2d00a29e597211a4e94931b8601a6e2fc1277e1d44f9bea7f4; PI_POLY_LAGRANGE_LOC[170] = 0x1d9ef28f38960babee39fd64360e87c10e7a47bf4a5a84f705d89caf534f5a18; PI_POLY_LAGRANGE_LOC[171] = 0x1a662cca597bd213f2745a83511db7cdce25b936cdaa99e1474a6dac15bea2d9; PI_POLY_LAGRANGE_LOC[172] = 0x0197aa4e6eb35edfdfaab3d8139c4b3fcf59995d3b8fcb558e5bf9645e7e502d; PI_POLY_LAGRANGE_LOC[173] = 0x1aa1a09ec9b6191d39cf78acebc3e59576bd3ffb40ae5f6d288cf4b0ecdd8147; PI_POLY_LAGRANGE_LOC[174] = 0x1818d61050678ae8bf973b42dfd1f77171c0bf34eb37b8885e35652e9988bfa0; PI_POLY_LAGRANGE_LOC[175] = 0x134a20c560fe391667d64d40e6cb1247f9c83a12e064a81cb509272573264e6a; PI_POLY_LAGRANGE_LOC[176] = 0x1f281b12b1626e9be4384df25f495e8f1acee54f43ca7be122b440376e77c91a; PI_POLY_LAGRANGE_LOC[177] = 0x1be0da357fc5919ebee9a07f5c9c4c68b083dcb8e8f6b9e15841c0d43b47d370; PI_POLY_LAGRANGE_LOC[178] = 0x173c7b186ca47cce8cdfc7d5a4ff28c36423a85c3baf9a0168adcc8481243a96; PI_POLY_LAGRANGE_LOC[179] = 0x1246e2f200685c90f31d26e530325707da7e19af3c7e0a20452137ebb48b7c75; PI_POLY_LAGRANGE_LOC[180] = 0x1addaf07b4b5cd7a34596f16e5a4c3ed71f3110c2bf9e05a3e3306d94beba735; PI_POLY_LAGRANGE_LOC[181] = 0x0065ab91639a3c53e69f57659e814b6efb899853cc5e24f18f07bc39751c9cd8; PI_POLY_LAGRANGE_LOC[182] = 0x137f04cb27de14aadade13aa13c10b4089245b5d0436e62a33dc47b579b1be17; PI_POLY_LAGRANGE_LOC[183] = 0x2b632932c4bf682bb0740f00d919ce443b027160b72e7f3f8b9d0ccd7eec99dd; PI_POLY_LAGRANGE_LOC[184] = 0x07679930fc0d43ede23d19576aa3f00d03bfa427e9ba3aed67ba93fffa6fbdc1; PI_POLY_LAGRANGE_LOC[185] = 0x173336dc276318a37f2f9bf02d20d28a3987fc1a52e29a38dc96727afb38705f; PI_POLY_LAGRANGE_LOC[186] = 0x05a0e178f031a241da2c19ef6e27d74b24f113bd1d07d04b875b92db78fd9269; PI_POLY_LAGRANGE_LOC[187] = 0x14cb2e65a7977209f44f9453f6912dcecc4e956f56d8714179f6fcc6da733dbd; PI_POLY_LAGRANGE_LOC[188] = 0x2b11a285334032de54ff956eece6efafd8d71218e2ea4d1f5d79e0b1bca4214a; PI_POLY_LAGRANGE_LOC[189] = 0x009d89fc3112db9e02a80714b30ef622717c429e3bf4de154d94adf6b6a9af8d; PI_POLY_LAGRANGE_LOC[190] = 0x196dc56fa7f166a56c1302a317a4ff7616f1144b0559d25f01283d8b034d87c5; PI_POLY_LAGRANGE_LOC[191] = 0x0d8e626e4e855940262821305e50d7a827fe6055725856443c284165177e9c62; PI_POLY_LAGRANGE_LOC[192] = 0x0baaf777e16abdc1d4dd466db98c6aedce79f7207b5f1d88a5e12e782cb50b8f; PI_POLY_LAGRANGE_LOC[193] = 0x0868d5087a52645e69dd3ad9876a190387960dedb36b83af2ccd85cc82e55084; PI_POLY_LAGRANGE_LOC[194] = 0x1eda164a78a5b7c7964083f55f386e67af92a27ac4602e4bcff9638df45c08a5; PI_POLY_LAGRANGE_LOC[195] = 0x072983606fd1602d6a2547b7bb2a4f769f61b9e6c95fb5312de3056f6fc2ead7; PI_POLY_LAGRANGE_LOC[196] = 0x2cfc1358e9de4ac7d4888654edb850ba3b23b53fb2003a17af60e53d24350bf3; PI_POLY_LAGRANGE_LOC[197] = 0x2d9c18c5e9c0e062127963a41be09e829e58e78c29289745bf3cbfa362a6027d; PI_POLY_LAGRANGE_LOC[198] = 0x0203d49c8b7f06a01e81138b755d3792e945e47db4393bf190002e7a10e1adac; PI_POLY_LAGRANGE_LOC[199] = 0x0501d5f01c83cbfe804a31b82a92f840d54ec3b2e49c5903af50f5891879ec2e; PI_POLY_LAGRANGE_LOC[200] = 0x007833e2153421aa002f35024898d70dc42d2f0b960c2e690c3ea78eaa59137c; PI_POLY_LAGRANGE_LOC[201] = 0x1e5784e146bdcc08665e47f9f1bedeadd2e7037a2f34d68f4f74c3ee78c5ec07; PI_POLY_LAGRANGE_LOC[202] = 0x1a685a070c60a0df0e664727371ff0fa62dac52af8e9d4deba4ca6ffb4475df7; PI_POLY_LAGRANGE_LOC[203] = 0x19c9a2ab9c28006e4856a5a83df12fface249cec573e54c554cd4be9b6f44106; PI_POLY_LAGRANGE_LOC[204] = 0x2ade07e94d4bc9727de5508b2ab4e8a8976e3d7f2d05c3a4f31c1ab889c00f45; PI_POLY_LAGRANGE_LOC[205] = 0x288e9e95cf7d82c056c02b88f44483e387abddad9257816b1fcfb4846bf5773e; PI_POLY_LAGRANGE_LOC[206] = 0x074d4dbb00a1b203276745d1b7b2f8dc98a65b056707aad613f09e97dcef4442; PI_POLY_LAGRANGE_LOC[207] = 0x2124ee893efcd08974a563b45aa3c0801bfea5a6c15f123fb05a1ef8913b9935; PI_POLY_LAGRANGE_LOC[208] = 0x0ff76a17b366170c24767fad94c5c3059733126153f33967563d25b2014ad2bc; PI_POLY_LAGRANGE_LOC[209] = 0x22dd5437228bd35db157db5f4d8a0039eef1f7a84ef5e59ef935548a855c39ee; PI_POLY_LAGRANGE_LOC[210] = 0x1933f3adf83077042497210a2eafdb615e3f73a9efa4df7913a26ef557f00fdd; PI_POLY_LAGRANGE_LOC[211] = 0x15777b177564166a7a93942709ecb2c566bdd8e88c458139afbdc683ddee24c5; PI_POLY_LAGRANGE_LOC[212] = 0x1dca4a73f77c75d658f2c23ab2564e672628465ab6198ea7e80d196a7b457f1b; PI_POLY_LAGRANGE_LOC[213] = 0x1db5f31202871f156d1b75cbe5836f964ea5953249715c0ba151435337e5e826; PI_POLY_LAGRANGE_LOC[214] = 0x295e3f8fea29fc564f5f8c9caa18f1ef72cb5d6905e2bb6e489080c90508582f; PI_POLY_LAGRANGE_LOC[215] = 0x18435ba548dad79d277e034d41e3b6523823351121af78880cc073e8d25d40f7; PI_POLY_LAGRANGE_LOC[216] = 0x1b7e333b77f38005c33a6aac8d03dd06b19ba528c8c9b45061faf0a88593bfc8; PI_POLY_LAGRANGE_LOC[217] = 0x248355a6c8049be525e9dafdf6658428ac5ba58137794989cac01e775f30e8dd; PI_POLY_LAGRANGE_LOC[218] = 0x23b468ab3de21986e6f2f8ec5d7c6dd745b2a6172c7dd159b88d200697b3336d; PI_POLY_LAGRANGE_LOC[219] = 0x0003dac4678b3593a284a86640385ac97ecf0b2f27f2d0e7406a360950907178; PI_POLY_LAGRANGE_LOC[220] = 0x0913156b6df90e2b31b2102c64746d29a430a04bc6c3aa176cba2dee3bfc2f72; PI_POLY_LAGRANGE_LOC[221] = 0x2715e28598d2254f5bf507b312354a4fcacc334081c47124cd8c6567effef779; PI_POLY_LAGRANGE_LOC[222] = 0x2718e8ac4dbb960e91f18fdf41eae2ffe77232d0b97ecd8e8c8f55b4b68e32f2; PI_POLY_LAGRANGE_LOC[223] = 0x11834e13994e1a67c0342cafa1edcb1a324c92cfbd1eb14b3c974c93dc6aa180; PI_POLY_LAGRANGE_LOC[224] = 0x16a69d2b7faf0fcd42490cc333cb13c5f6a0ec8da0a0d5b980804a91b26c117e; PI_POLY_LAGRANGE_LOC[225] = 0x14541b2d5edd9d72846eb149276cadb143c2b6add209ad31e3ba5804df616d75; PI_POLY_LAGRANGE_LOC[226] = 0x102bb19c422062857ab477cc019044fbbea0ced5ff58d9dd1ffa3b06374ebf8c; PI_POLY_LAGRANGE_LOC[227] = 0x1c83a208af8c248777c3a7a1fde28cd58cc763b8115242aa5da7a4da27716129; PI_POLY_LAGRANGE_LOC[228] = 0x0d6d2625c883ff54b273e529a41f44caa4d033034a149e440d164743935572a1; PI_POLY_LAGRANGE_LOC[229] = 0x1f83e4348499f3c0c18b2011544b8cf0815c131b58a7ec3f279b3bce83a07120; PI_POLY_LAGRANGE_LOC[230] = 0x2e2530352800fa7deca9395e5d7dec35e9f0a22f902cf5bc4fab08d0c359c491; PI_POLY_LAGRANGE_LOC[231] = 0x0c9627674766d18808df3282819825389b33202b47ef78f7b7efc37f2395fabf; PI_POLY_LAGRANGE_LOC[232] = 0x233c1a05079157b86581f9e0f310cf66c4b5bc64a44614da6f52d49c6da4b32a; PI_POLY_LAGRANGE_LOC[233] = 0x22d9f6ed57f1d37dc9eb70d3c2d851c9310f2738dfb40f735a76bb17f4609f3b; PI_POLY_LAGRANGE_LOC[234] = 0x17f3c8fa122938d8bf15e9a5b57aebe32cb0b4e4da219a22905c39c38cf0fc7c; PI_POLY_LAGRANGE_LOC[235] = 0x0a82754e7b728c416a86dd6f521861429d688f4a43ff498f0d073a30dc894d18; PI_POLY_LAGRANGE_LOC[236] = 0x03337a9f71b181e9a5e5180eb711346af0a06af7dcb465647a527177c9630268; PI_POLY_LAGRANGE_LOC[237] = 0x0165b4edcd1ec34b3bc49b70d343ec70554081413a755b9a8c417a2f736c128b; PI_POLY_LAGRANGE_LOC[238] = 0x0a93c807d07fce192d94cd4ace1cb67274810a4484e97ae922526e5a1c4d67ca; PI_POLY_LAGRANGE_LOC[239] = 0x15896d64f9ec87eb57a466ec1ddad0ebd483d11abe3f0f2e1139026706c95b2a; PI_POLY_LAGRANGE_LOC[240] = 0x25311f9cb5d5c74583251d1a1cdbef8b481b9f44a223d93cb534d70d6b000b56; PI_POLY_LAGRANGE_LOC[241] = 0x2bddf3b7ee0770a50c947d4033cfc4b6e84cc145bb73b24e45227e2ab4b4f1fa; PI_POLY_LAGRANGE_LOC[242] = 0x24d9eba788acc61a4b5ec02c89e48de7f249bea72146b88f822a110b38a67ccf; PI_POLY_LAGRANGE_LOC[243] = 0x180a23eb813ffbc2a90c1ccf533cada0c03f1c4b9e149cf2f5714e09b61bf80a; PI_POLY_LAGRANGE_LOC[244] = 0x07f26c81b3882840dac385eebe5f7976f5943da62854ad4a92369c10f07683f5; PI_POLY_LAGRANGE_LOC[245] = 0x26e5f2f5117ea6d4bd23c9c67790a154acbba911e35e443666db69e64f4c3c5c; PI_POLY_LAGRANGE_LOC[246] = 0x2cae64b3654d33b6441692a0f9133ab1561fbfb6757c22023afd75c71fb6a262; PI_POLY_LAGRANGE_LOC[247] = 0x200088dfe9e0fa7a60ae1f1956fe179dec47f7820b2158b33ccf09e0e13f6cc4; PI_POLY_LAGRANGE_LOC[248] = 0x2a9e763f15df3b16de4b817acb45f693461f6d143a61b12259234cbb95305bd3; PI_POLY_LAGRANGE_LOC[249] = 0x13d93d24b34ff72f98d26127b4babea315b2932a6cf6ff6766994c4c90936247; PI_POLY_LAGRANGE_LOC[250] = 0x0780eda3c17f12017488b798b3fe04944863804b42477c6a52b15ad66cb44585; PI_POLY_LAGRANGE_LOC[251] = 0x2267320530f7845e147855fb1748e1e4727a4243c9dc5a8a4a01ea8d7bca2e3d; PI_POLY_LAGRANGE_LOC[252] = 0x19b089828f8a43dec96dc655298bd8a3a1ab89d4a6adc5331a43a9003f1751cb; PI_POLY_LAGRANGE_LOC[253] = 0x29e46cec93fb0b596f01fbfbce5d29a2f7e11eda0257124e05b24e76890b636a; PI_POLY_LAGRANGE_LOC[254] = 0x01305c13adc60a699aad00785f4bf26318fd8971c0869b40e33034efe1554d84; PI_POLY_LAGRANGE_LOC[255] = 0x1680525b1632d361e9133b5b8a28e97de242f997d2b3165b15230ae80b78a26c; PI_POLY_LAGRANGE_LOC[256] = 0x14bceee57098d461d53d5a8f499be9c0208ee9fd01cdf1765a783d546a391b6c; PI_POLY_LAGRANGE_LOC[257] = 0x2253e17aee15eee9372dec860e6d23932eb8f77205d7b75d52782bc93602df2a; PI_POLY_LAGRANGE_LOC[258] = 0x1e9599eebbd861645a5f6e4df9c069550d36a1759bcff72e6dd8628acc5267d4; PI_POLY_LAGRANGE_LOC[259] = 0x1a83de3b7588bd44bb75faa9b39463fad6d463c2bf777ee07d0429f8c28b33e2; PI_POLY_LAGRANGE_LOC[260] = 0x1c61a45170d3fc8d6b7b52d4b4556c8c2392e18c4b3c37ca1c3ce33d06cc23e5; PI_POLY_LAGRANGE_LOC[261] = 0x29a2927d5d14199705f80c2539e7be7b23fb04bc6562cb9c7b8940ed28cf2338; PI_POLY_LAGRANGE_LOC[262] = 0x0188d3d647ef959b8c6f53b38240fd6bfb7d848923c73c0897d7252a503f1610; PI_POLY_LAGRANGE_LOC[263] = 0x12fd2916e6fe37454a8410a404306b0f28ff6bf56a1eed0ab7c124caef9ccc44; PI_POLY_LAGRANGE_LOC[264] = 0x044eb4896d95cb7db4f8a22972c5c955a2a3c37693e1ad1e69263c5ca39bbdac; PI_POLY_LAGRANGE_LOC[265] = 0x15bef4e7dcdd9fa62c19e46086a23340b31bf91f3e1f1dae90a1fc3f16330482; PI_POLY_LAGRANGE_LOC[266] = 0x082f1889f648282876d6a7e4149dbffa0cc17d61da57321453bf615777b9fc69; PI_POLY_LAGRANGE_LOC[267] = 0x1590fbcbd9ba05d96fb3e1a1ff98ce0e1033683ba4bd13292831af55bd65fd16; PI_POLY_LAGRANGE_LOC[268] = 0x0fa6b61beded3e1f48829c19250974c76bf28211d5e2567689bd424fe24a9819; PI_POLY_LAGRANGE_LOC[269] = 0x2d1ebe5b46660cf3c53f7b177ce018d51ee051cfd98cf8cdf68702234cec66cc; PI_POLY_LAGRANGE_LOC[270] = 0x08f929c8187ca1be1e5dab59eaa8642b9de907135e0d40ac8323ded124481513; PI_POLY_LAGRANGE_LOC[271] = 0x163974b4aba66cd2c3e5dc0914df38e38628188ae0f8d95c598ac6e4f5d94d7a; PI_POLY_LAGRANGE_LOC[272] = 0x03ba591af0f93d054f71750a615f8518a07505dbdd4543e90a3313da3a327149; PI_POLY_LAGRANGE_LOC[273] = 0x04e8558e74f6a59ed19e5fc8a0133d2a74fd1d741669990f02066f45a9b10f87; PI_POLY_LAGRANGE_LOC[274] = 0x05fa93e8be758e5b31faacd741f1341363ecb5c07e696a0fd35b7edc097cdb2f; PI_POLY_LAGRANGE_LOC[275] = 0x1772ecd3fe342f3ecbf5b3b7b54be459f93fde13fedbc9b99c5d6bd750526921; PI_POLY_LAGRANGE_LOC[276] = 0x1c5211bf17bce6886eb80ce42c758f9b32cb3a7e3055b65745ec4c08f393ded4; PI_POLY_LAGRANGE_LOC[277] = 0x2ef8861993b79d5a5f9c5bd4cf940f4c086a0e667e249333f75437f84c6ea878; PI_POLY_LAGRANGE_LOC[278] = 0x1a380559e328f5a49468cba0758c4ade62a135957cc00c7fc57a59dfdb2ec974; PI_POLY_LAGRANGE_LOC[279] = 0x2d14fe2c38a4d8281fd5e72e124176a906f9c5350c29656c0d38ad1832717307; PI_POLY_LAGRANGE_LOC[280] = 0x27a94185b0e7fe5e262909a459525b80173d3428962be4d7b059332144660204; PI_POLY_LAGRANGE_LOC[281] = 0x1bd59e8b3a2461ed03e5eceb7b78663b10aeb2e39f377911812299fc2c4a96a2; PI_POLY_LAGRANGE_LOC[282] = 0x1dc6b443b174be73d1256dd4b491d36c8bed40699f25d70495e43cc283bd59aa; PI_POLY_LAGRANGE_LOC[283] = 0x134ef416f00c2b96130649271bf5674ed398906e822e823674b4147ccd1b8d39; PI_POLY_LAGRANGE_LOC[284] = 0x10a0a77c4bfd704b9c80c40e011018b7dcaeaa18dc95f4799609c33ae90da90b; PI_POLY_LAGRANGE_LOC[285] = 0x23bded4603b7c9a72ad1486948934a0f4209576ae331caf958f3b3b7b7a64675; PI_POLY_LAGRANGE_LOC[286] = 0x0f3de613f3e86a084110503269f0edcd0277ffbd59b8259bac420b0dfe38c48f; PI_POLY_LAGRANGE_LOC[287] = 0x0bccfa0cf83ce8b4b055b65685fd6a02211e8d9c1dea45a57629768a9cd8505f; PI_POLY_LAGRANGE_LOC[288] = 0x02c8f0d9999caf2881de3767667043190a8cc692be017b7590a255acf0daa920; PI_POLY_LAGRANGE_LOC[289] = 0x2e6f50c4627f25e53cc2bdb9e1d91aede1388d9a1f62e5f7adaccefc7a88b806; PI_POLY_LAGRANGE_LOC[290] = 0x0d4ec92c72626fd2065b6249dc4fd70dcd68d35a73579450f1a7075cc5a27d0c; PI_POLY_LAGRANGE_LOC[291] = 0x001b6f24cbc7851f167c8dc60005634bd0d0464ea3dda6bf80573ab462168429; PI_POLY_LAGRANGE_LOC[292] = 0x100af3e6fb197dc69b454b862fb265c76228930bf295e3f80fe05635074d8b91; PI_POLY_LAGRANGE_LOC[293] = 0x12e2ca626c157df4443be331765b79ac39d0dc3fbe6c868f9faba3fd3f69683f; PI_POLY_LAGRANGE_LOC[294] = 0x10eec8335a68265c22eae86b4d9ece7a57821e18401d3a89c717f5db31d2acda; PI_POLY_LAGRANGE_LOC[295] = 0x111e08cbb3369a190cce5b3642cfca6694a2e67b53c64e31cba311f18b320b57; PI_POLY_LAGRANGE_LOC[296] = 0x2d321ca67143c1a4aa67e73c227affaaf19061b6903490890f9e045f5d13260a; PI_POLY_LAGRANGE_LOC[297] = 0x2a5f8ba2c8335ac5f499afbc2d4e42b460ad5f857eec21cfc09029c1cd266886; PI_POLY_LAGRANGE_LOC[298] = 0x1445c8c84c0f295ec2ff7beb2806530b6c6c0f592255785d5af8767ab0e16310; PI_POLY_LAGRANGE_LOC[299] = 0x18dbcc5b2666023b8ca33de36e5d46de7bb85ccb9e5abacf68c3bd115c11f565; PI_POLY_LAGRANGE_LOC[300] = 0x07c1777c1a9c0f099f8d8f165a54c58a64dcd403a3d18be49216690cb7668e65; PI_POLY_LAGRANGE_LOC[301] = 0x1cb7fb52970dcb00d8d4ed3893828fd94311960d69cecd321b8bf3e211d875de; PI_POLY_LAGRANGE_LOC[302] = 0x27049df82cd1e75ada0461049dd3624f82e89b05e1469c6c51d4e793f3538a4f; PI_POLY_LAGRANGE_LOC[303] = 0x2c04858d42224c19de1cb9f396699455b68096ec07098537cbd8cb8e393b4083; PI_POLY_LAGRANGE_LOC[304] = 0x2cb4740feefdbaac3b0a04afab2a1cdc60fa24abc6e9176280ea7aa41fb0d42c; PI_POLY_LAGRANGE_LOC[305] = 0x0fa9b6a76a681f776550079c7e8bcf38c96477da1fab624b6e2ebe4741e5d433; PI_POLY_LAGRANGE_LOC[306] = 0x2287376859f865074065397f40cb5f82439255e38a142c43aae077c7f7e5e056; PI_POLY_LAGRANGE_LOC[307] = 0x1888819499226bc7cc82d46ba9ffb2eedd88847a20459ea9c46b715ca397441f; PI_POLY_LAGRANGE_LOC[308] = 0x0ab45c36cda673eb2355026b366c13118fd5cb5d7dec153300764f39049614ac; PI_POLY_LAGRANGE_LOC[309] = 0x163b2c88e1ed391c691c93abc772aaab7a552620e2b201ffaded87aaba75ca23; PI_POLY_LAGRANGE_LOC[310] = 0x0d8faca4e8843ff927dda2c51c806260b4f32618ad4713bc48fa4e3ebd8683c0; PI_POLY_LAGRANGE_LOC[311] = 0x18ef156dbc01bc7cabc5e902e4b585524b6b21bf90f1891dccd82ff117005dcb; PI_POLY_LAGRANGE_LOC[312] = 0x0dce880dbd6ff6d13aa27fd141ad35f50b8c5b0c7965ce9b285e4bf16e817b1c; PI_POLY_LAGRANGE_LOC[313] = 0x1d9906fc6c804ca59c4908b11fb397fe30333116f9a3e855677a09cec263e381; PI_POLY_LAGRANGE_LOC[314] = 0x0095be48c8bd445095cbb89e2a6dd4089a897b3f88ad3374e822a8c9b5f851c5; PI_POLY_LAGRANGE_LOC[315] = 0x153607afb0e3717a477afcd69d0556f0f714bea3d9aebc442ec99e52a8372b67; PI_POLY_LAGRANGE_LOC[316] = 0x24e9b577774ee31aa217467f1269c03ebab9577ff4f0f2714b8dc3fef80fced3; PI_POLY_LAGRANGE_LOC[317] = 0x109189e381bb24f380f0afc2670889d5aedd2c671afe23d9f1cd879c24ee3700; PI_POLY_LAGRANGE_LOC[318] = 0x00306692d9c1b3aa0697216a72508273eee63d589fcc9927086c34fb7c9e0f31; PI_POLY_LAGRANGE_LOC[319] = 0x2e1b4a7fb8e62666085e030a2aad7e7121e2f8f0fca55360caa4781fce2792e8; PI_POLY_LAGRANGE_LOC[320] = 0x21fbae5502dcdde3911831cd15534c57a8b383c84263d07a64ce63e6218a836e; PI_POLY_LAGRANGE_LOC[321] = 0x2c05b7330b343d6d2421ca727b7586903c92b2e4b57bdbec1b6970332aa0324d; PI_POLY_LAGRANGE_LOC[322] = 0x02cd47f5160143e424b2b98f79ad19b50f85dad097a148c2f3629628ff55c841; PI_POLY_LAGRANGE_LOC[323] = 0x25cc88ade19329152d199a1c3c2359d971f8845bcbe438a478c6b1046c559061; PI_POLY_LAGRANGE_LOC[324] = 0x2e7f28cadd93d6dbb6eb7bd3e0464d0690b8649f82fbc05f52dd4824bf0aa7e6; PI_POLY_LAGRANGE_LOC[325] = 0x2230eeaaed20ee679a38e203ab182e014c812cd4ddf32cf5dfbeb7f496dacb9c; PI_POLY_LAGRANGE_LOC[326] = 0x297ddc40a4f8a6d82d7ebc4112870c2ccc3c90375a27fad3ba1bf81b6fd49840; PI_POLY_LAGRANGE_LOC[327] = 0x11db407901e06f9dbba24fd845a05aefb6ecd634b382fa1af1df3e4353f73af8; PI_POLY_LAGRANGE_LOC[328] = 0x148a12f6e362f30ff2b1263acb09b6bc632823b4184c1af196b72109bb7f10af; PI_POLY_LAGRANGE_LOC[329] = 0x1822a193a1a24a70c4786f0a31efe5ee07ab47e176434017c8ff409efe98a6d9; PI_POLY_LAGRANGE_LOC[330] = 0x0e65f918f363abfbe84ef87122af5d473c5d93a29219ef78ea72444cb5a801f1; PI_POLY_LAGRANGE_LOC[331] = 0x1d54c94b32dbd8ec6f32a52df0ee60b2f7dc7401df9c973d1690e36b880587b5; PI_POLY_LAGRANGE_LOC[332] = 0x26ee832c256b826b0aff70eb471822d17894936992b1db79e0ec61be801cec29; PI_POLY_LAGRANGE_LOC[333] = 0x0a8b55b856369ce80abe8558f3a65bc748cfd9acd7234ff4b1f1192d7c006d8c; PI_POLY_LAGRANGE_LOC[334] = 0x29ea91e338fcff23fb1c3aebc35a3407a6a4a02ccbf9560c6364499b763929dc; PI_POLY_LAGRANGE_LOC[335] = 0x24345d793f58daa1368f93ab5c4054010b270af325aa82938c52a2276eeb2f51; PI_POLY_LAGRANGE_LOC[336] = 0x0547b30c29ad46026c718f570f9578cb2fb08e6756200b7b03c63ef335f18517; PI_POLY_LAGRANGE_LOC[337] = 0x0535d87dc53aac971aff56936481f9cbe9f1e725adc2d4652d850794111eda2e; PI_POLY_LAGRANGE_LOC[338] = 0x0e0f5ebf9f071f3bb9cb9b7fb0a470742536f54ff2b2911579d30e84b1eb0179; PI_POLY_LAGRANGE_LOC[339] = 0x1bcfe77d500b7fb3dbed1ea178c975b5a9062b6003b63a503dad9a96bfbedc69; PI_POLY_LAGRANGE_LOC[340] = 0x0932cb207490f24b15837a7918cd774ac880e16d50c77029215848025a369911; PI_POLY_LAGRANGE_LOC[341] = 0x06ca46b1fa331a6bd09c514bed8613074b30190f4a8c0f294c364505284d371e; PI_POLY_LAGRANGE_LOC[342] = 0x279cf004513c25c7614b1f661fd349e6e70be138aaa34a36393c617ec839001a; PI_POLY_LAGRANGE_LOC[343] = 0x2e4afb1eea5897151453396adc970e1dd1a9675e0ca984906d2a06e92a678949; PI_POLY_LAGRANGE_LOC[344] = 0x2dba44403acc2fecf95a858cd0787eccb99689c1c6a378b6799213970c0e4ccc; PI_POLY_LAGRANGE_LOC[345] = 0x2fb396e51c7e674ae75dde77ce5e18df0ce7fad6187abbdc0ed1dc466ba48e32; PI_POLY_LAGRANGE_LOC[346] = 0x0166f729485612ab9ed4a32cb71a788188c41ea7f8ed76947f3a553bfb90c2b9; PI_POLY_LAGRANGE_LOC[347] = 0x217790336684d275fa4bc27891dc5972b57ac22324fbe3245ae809e41ac0bf6e; PI_POLY_LAGRANGE_LOC[348] = 0x28df450de46ec2dfc91835af53d9b17b1773c2b8451aa2aa91611445edc1d13d; PI_POLY_LAGRANGE_LOC[349] = 0x1a58b7c6862eac9dfddd24aaa2b066396714831622d5fee1c48ca617ba325901; PI_POLY_LAGRANGE_LOC[350] = 0x0c54b2031b2df4f04098236c4baea0a3edfd65ee641681304a085d74bc5961ae; PI_POLY_LAGRANGE_LOC[351] = 0x2d111ad7c6ae8b4aa23b4cc8c5b00c24bda041e050d69a5bde8cbfe35fd53fd9; PI_POLY_LAGRANGE_LOC[352] = 0x2199deb2c07dfc8fe266fe3b4470545e6cae7d7017c854bce0cb26395a5ed384; PI_POLY_LAGRANGE_LOC[353] = 0x2d905ffc300cdabd0046f7ee6f9480617404069ae07f5f5aee1156b0d9a26874; PI_POLY_LAGRANGE_LOC[354] = 0x2cd2f0c6cb43454fc0c036e537a2de98035ce911200005e5909e74cee3fa78db; PI_POLY_LAGRANGE_LOC[355] = 0x24a45167bf1753e490285833c631a6517fca91b3d8e5149048ea4942acaf07d7; PI_POLY_LAGRANGE_LOC[356] = 0x0bd52d6397121d3e679fba343090e3bb11c5e76ea3bb7938555b4e8964fe3ca9; PI_POLY_LAGRANGE_LOC[357] = 0x14193f8775765017216de1509e08347d9efc31458507cab5be9bb64c794e0f3f; PI_POLY_LAGRANGE_LOC[358] = 0x1d297186928f40e7944f01ae697e48a08a3a3db10bb4f59b676bdbe700b828c6; PI_POLY_LAGRANGE_LOC[359] = 0x1b6253bc866d6dc9e7865f52c99c68dfa922370bf90f7d264c1205ffc498273a; PI_POLY_LAGRANGE_LOC[360] = 0x27fc6274952808413f9c57631454789f17f4912bacda965f64dc84361f85c9d9; PI_POLY_LAGRANGE_LOC[361] = 0x16be4ef6acbfe4b5fa7a74e14361c594acc10f28d4a990539a90e3a9827daca6; PI_POLY_LAGRANGE_LOC[362] = 0x27d0db84a1d11d9f4a6fb9380900027120bf9a7d5b3c939dff49c7eabcb9f38a; PI_POLY_LAGRANGE_LOC[363] = 0x00c2dcc3d8ce33146c1738a2a7e11ca3c1779fb1461facb281fafefd73977639; PI_POLY_LAGRANGE_LOC[364] = 0x11328b22b43d61289e0206e0a54be5f55261dfabb05509f2646f45382df03640; PI_POLY_LAGRANGE_LOC[365] = 0x20e5cf894b028e68a3c9caf1b88acaf2dbc937aeb4635b594efb6c180666f072; PI_POLY_LAGRANGE_LOC[366] = 0x152cb45d7619505798d88eb31171de8dd0d56a4e81d17e29cb2924793b41fa33; PI_POLY_LAGRANGE_LOC[367] = 0x2aff7b07caaf73757e06073b31b744a79bb212b0414f086d04b00b364229fa2e; PI_POLY_LAGRANGE_LOC[368] = 0x242a5360a810bc66aecf7179bb5128c5cb2e67a2df5a50ba752d2ed4a0753397; PI_POLY_LAGRANGE_LOC[369] = 0x19e7fe889efdc79a2fdfcd72c74cad84f40b35b1ebfc72117a1ff221238480f9; PI_POLY_LAGRANGE_LOC[370] = 0x2aacc7c017cd22b47fe644d8d709f5dcf373e602daee6ef2765336711f233ea0; PI_POLY_LAGRANGE_LOC[371] = 0x03a62f94adbc4b8e99032234c05bc493be6b8468683b265fb3eb548256eda39d; PI_POLY_LAGRANGE_LOC[372] = 0x24d1ae34c12c8bfa600292e8fe97d85dbc73bb211eab079d329846155800a726; PI_POLY_LAGRANGE_LOC[373] = 0x1a18fff0a1345b77dca6b91a7d81139a4ceeef9cdab25918ede7fe2f455424c2; PI_POLY_LAGRANGE_LOC[374] = 0x1341ea454f94a38c0d0b669a57df43d97b9a73a0501b87a4ac1ca136f3265da1; PI_POLY_LAGRANGE_LOC[375] = 0x1d05c192a3d4116ecf1088d3524ef86bdec3a8edcf2207365752917c635872c4; PI_POLY_LAGRANGE_LOC[376] = 0x13a86fdacacb6e0e8c4ac34bed3c99c3df96c9b279b77e99492c0321d6c83a3d; PI_POLY_LAGRANGE_LOC[377] = 0x22bb3becb6c03ba24904275a9ed77e2b0a73505a6f172a5a791f7f144d89f4e9; PI_POLY_LAGRANGE_LOC[378] = 0x296787bfbba1e0c2e8dd0c61ab3315c2613e4dca1cde7ae848f9aee99ee9e91f; PI_POLY_LAGRANGE_LOC[379] = 0x16af80bc18ca8f44eadafb09c060aad942163a4c0b88b8f0e557d686e9d66650; PI_POLY_LAGRANGE_LOC[380] = 0x14f3f7b1f51b25d0c03b688c6c7476d821cb3baf8ccfa5aa8aa2358c9ee7d473; PI_POLY_LAGRANGE_LOC[381] = 0x131fd74469a6c75204720c51c93b7d038d7ec8784cdbd5694c512e479bdfc9fb; PI_POLY_LAGRANGE_LOC[382] = 0x12cc482d916b6c62471376c01ea09806501bcf5977b7bb52c128dc2e1fe838f8; PI_POLY_LAGRANGE_LOC[383] = 0x10fe5836d71d1ef53b9aa64b57bae4dcf899c6690f846cf635d1384c7396b62f; PI_POLY_LAGRANGE_LOC[384] = 0x2867ebb62b4228fbaf760623ea56952d5f87394de5bde870033e12d0c1c7ee15; PI_POLY_LAGRANGE_LOC[385] = 0x0923066e66e1d0493d889722548380eadda95332c5bdcafbb3a187b00295912b; PI_POLY_LAGRANGE_LOC[386] = 0x193358f386332101b5113caf4778f2da1cf4e764d54ce044648faf87d4b233f8; PI_POLY_LAGRANGE_LOC[387] = 0x25a39971acdad32025db833d28507c61aaa6f823ead6a44f0f3fc19f27b0afd7; PI_POLY_LAGRANGE_LOC[388] = 0x0eadc299b470e5f72e5b0e736b9c8a46ab4004cb651d9f76f81f89e755f6f85c; PI_POLY_LAGRANGE_LOC[389] = 0x1365b06cb15a25b1278c74c209a5b8b9133dc8f596995efa83ec69ff2222b761; PI_POLY_LAGRANGE_LOC[390] = 0x0c5dc63da4351b2ccb2f9e050cc4ad7f608b17f6b88bb9b2621bcdfacd60c130; PI_POLY_LAGRANGE_LOC[391] = 0x145a7fce56c17ab11bd06c716573b57665f1b5d1c7914320c9eae8612eaa53de; PI_POLY_LAGRANGE_LOC[392] = 0x23de929b2bf2284c17973227f4c3ca850631fd05efcd7e785af217ff2f1e7104; PI_POLY_LAGRANGE_LOC[393] = 0x0d5bb46c1ca6de6b42279ed235ff87f0b30ca831b3183d6536749ee7687e7dd8; PI_POLY_LAGRANGE_LOC[394] = 0x215c0cf920c6d100dde848dbeddaf0b9550e1b57db96938a2463719390645bb8; PI_POLY_LAGRANGE_LOC[395] = 0x2f251a8167f9becfc963c2583acb636ea5060cc831f6e132bc01ecf719229af0; PI_POLY_LAGRANGE_LOC[396] = 0x20aa08929293c39293a8176b43eeb4032f605739efd9d5bacd84e79f8355fb18; PI_POLY_LAGRANGE_LOC[397] = 0x138aed8181e422550e051d66b810e3e446d53ae05b4dad25b82d0520ad6f4e68; PI_POLY_LAGRANGE_LOC[398] = 0x2f72fc2f52ec22c145a25d12a99b37948225d82f8bc87ae11905e2e750b17fd9; PI_POLY_LAGRANGE_LOC[399] = 0x293301b42aacf668b2a14aac0943441fcfafb09c5e149ea7e32e5674011f871e; PI_POLY_LAGRANGE_LOC[400] = 0x1f06495a16dbb347bc921805f72f25a5adca21af1cfc364c4007a7549a107f3f; PI_POLY_LAGRANGE_LOC[401] = 0x23ea9dc3da394c9a36d7ee1848efb088fb72a271c48de841159b41a515cb2273; PI_POLY_LAGRANGE_LOC[402] = 0x1c9ec5995dadf1621ae79ee6e2f5876f010d841999ebcab3699a9770c4dd0cf0; PI_POLY_LAGRANGE_LOC[403] = 0x17590287728975a333cc7605b7bd172f8ada8847f7f1c4e0dd32b70152f5e162; PI_POLY_LAGRANGE_LOC[404] = 0x175ad7729595ad646bbc3599a27d0cd8a44b50021dd7265eb53e63ee97769c59; PI_POLY_LAGRANGE_LOC[405] = 0x13cffb96d0eb7a710f9d39dcba0ae8622357a93961f02c73fbe0b32c16d5711c; PI_POLY_LAGRANGE_LOC[406] = 0x23fd848eca0ad329e730293f730475eb9e9270191787ff4cceedb0ce5fd1735b; PI_POLY_LAGRANGE_LOC[407] = 0x13d81c4695042acfeaaab95e2188c30e97f82c37e9b93d1c9b2a2dd4103f5949; PI_POLY_LAGRANGE_LOC[408] = 0x218004b22429a0db94c4ae5e624e5eb53504329d6fe848d233c900a45e6728ae; PI_POLY_LAGRANGE_LOC[409] = 0x1e5b95b73490a5f40ade2b0c6c2778ec52acfbf680fecf9ddb9784c18af1de84; PI_POLY_LAGRANGE_LOC[410] = 0x0bd191d04bddbfc2c7804db352760f417a1936b55981ea2e8f43d22b7590c5ca; PI_POLY_LAGRANGE_LOC[411] = 0x20b3eeb1aaa2109953dafcb54b63e0f0dc1ee6d069c7a4f63ce9a312ad283c38; PI_POLY_LAGRANGE_LOC[412] = 0x0ef94086be05489702b4b8070980d980c7b3630d206c1c274e8e087fbab21338; PI_POLY_LAGRANGE_LOC[413] = 0x277c18c00ecc8aa6db2670d90f9c670b950604b10994b0020c528db96061a1b3; PI_POLY_LAGRANGE_LOC[414] = 0x2bb078aab3860b9b2fbe80f9e646b0d9309626c31cf9466b1212d425dea836a5; PI_POLY_LAGRANGE_LOC[415] = 0x1f8e4b1e876d64141dabb332816841fa6d100c114996a3c92d9245e66e462d86; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import "../libraries/EdOnBN254.sol"; import "../libraries/Transcript.sol"; struct ChuamPerdensenDLParameters { EdOnBN254.Point g; EdOnBN254.Point h; } struct ChuamPerdensenDLProof { EdOnBN254.Point a; EdOnBN254.Point b; uint256 r; } library ChuamPerdensenDLVerifier { using Transcript for Transcript.TranscriptData; function verify( ChuamPerdensenDLParameters memory parameters, bytes memory externalInputTranscript, EdOnBN254.Point memory c1, EdOnBN254.Point memory c2, ChuamPerdensenDLProof memory proof ) internal view returns (bool) { Transcript.TranscriptData memory transcript; transcript.appendMessage(externalInputTranscript); // init transcript transcript.appendMessage("DL"); transcript.appendUint256(parameters.g.x); transcript.appendUint256(parameters.g.y); transcript.appendUint256(parameters.h.x); transcript.appendUint256(parameters.h.y); transcript.appendUint256(c1.x); transcript.appendUint256(c1.y); transcript.appendUint256(c2.x); transcript.appendUint256(c2.y); transcript.appendUint256(proof.a.x); transcript.appendUint256(proof.a.y); transcript.appendUint256(proof.b.x); transcript.appendUint256(proof.b.y); uint256 c = transcript.getAndAppendChallenge(EdOnBN254.R); EdOnBN254.Point memory r1Left = EdOnBN254.scalarMul(parameters.g, proof.r); EdOnBN254.Point memory r1Right = EdOnBN254.add(proof.a, EdOnBN254.scalarMul(c1, c)); if (!EdOnBN254.eq(r1Left, r1Right)) { return false; } EdOnBN254.Point memory r2Left = EdOnBN254.scalarMul(parameters.h, proof.r); EdOnBN254.Point memory r2Right = EdOnBN254.add(proof.b, EdOnBN254.scalarMul(c2, c)); if (!EdOnBN254.eq(r2Left, r2Right)) { return false; } return true; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.7.0 <0.9.0; abstract contract Groth16Verifier { // Base field size uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; uint256 constant alphax = 16256165923103553519926347729425900872314204430994883104612610343111348135876; uint256 constant alphay = 19138652545956295660675617199594802505676299171380623649352005981478562443597; uint256 constant betax2 = 8204071324534901362341322439059587797414455100368336987686753165020369846845; uint256 constant betax1 = 6665433577658572066897486913299087481647452979210336608994345891701581856834; uint256 constant betay2 = 14834262973843077629865390891613017385609839712110447137888951068189007531011; uint256 constant betay1 = 16331941496885753419055646151848176696559025436200237673776742282742412967965; uint256 constant gammax2 = 19395211150219211391283530851566767038798848986875800621481809004353459821568; uint256 constant gammax1 = 20757124324097756225247531942005322123026046939826820803010761345582846713724; uint256 constant gammay2 = 9870927845400502661127907784295437871374570395824491513643064976625430961023; uint256 constant gammay1 = 7766404489786028606513551971777366421088003918093983243784536876175268136627; uint256 constant deltax2 = 2163309680161400121119682607794655964701512537494085645265412397027931826575; uint256 constant deltax1 = 3113283545088766024192829174616606999308594429959623964524929092618870403528; uint256 constant deltay2 = 1921476643110464450809770330667699614900900065953918273865752354000185267157; uint256 constant deltay1 = 5874921860466770388917190410934466283623612858778487631644429297361457438421; uint256 constant IC0x = 21032310447698900733489244462461327620034172087268937718486459736686330097542; uint256 constant IC0y = 15255358700585757092585473918754076738773749970617893456100369574687238860968; uint256 constant IC1x = 16715217290128382155589461578618236218430957776188273715735875193401306192313; uint256 constant IC1y = 15368024543709579921762320385741813490971153401525665424442005121364732127398; uint256 constant IC2x = 14274951064878040028256546927596989081768612233326778274916949637976011816760; uint256 constant IC2y = 6254462161320240732243528131880818559627315286143223997306859640249410473204; uint256 constant IC3x = 5364975381886818914093677874599753689915933780903550459994816244990917737679; uint256 constant IC3y = 4526703053836949638741254715952140627391613788977370991000243191073409095812; uint256 constant IC4x = 13817104078492523964688304194393832807277054048340506699203968948475441561857; uint256 constant IC4y = 13509663893899442455638082454515888969479420524783664872936091308415086582920; uint256 constant IC5x = 16914819523008621620287202063716635121588678411537131671993818040047759424213; uint256 constant IC5y = 12098080924417899419588547964089902275811924124479739512070960973355920054842; uint256 constant IC6x = 16968890734033980860207835394298675744606073588133402425478057457348548726313; uint256 constant IC6y = 8350946616796852576005794893850785435191413973586632109917286639736684400674; uint256 constant IC7x = 5588818621080811063986938798787918832692618028732440561053848238611142504983; uint256 constant IC7y = 226018260702723203566376453179106937624682067560259651059139245131362609172; // Memory data uint16 constant pVk = 0; uint16 constant pPairing = 128; uint16 constant pLastMem = 896; // _proof = [A, B ,C] function verifyProof(uint256[8] calldata _proof, uint256[7] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { if iszero(lt(v, q)) { mstore(0, 0) return(0, 0x20) } } // G1 function to multiply a G1 value(x,y) to value in an address function g1_mulAccC(pR, x, y, s) { let success let mIn := mload(0x40) mstore(mIn, x) mstore(add(mIn, 32), y) mstore(add(mIn, 64), s) success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64) if iszero(success) { mstore(0, 0) return(0, 0x20) } mstore(add(mIn, 64), mload(pR)) mstore(add(mIn, 96), mload(add(pR, 32))) success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64) if iszero(success) { mstore(0, 0) return(0, 0x20) } } function checkPairing(proof, pubSignals, pMem) -> isOk { let _pPairing := add(pMem, pPairing) let _pVk := add(pMem, pVk) mstore(_pVk, IC0x) mstore(add(_pVk, 32), IC0y) // Compute the linear combination vk_x g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0))) g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32))) g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64))) g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96))) g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128))) g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160))) g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192))) // -A mstore(_pPairing, calldataload(proof)) mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(proof, 32))), q)) // B mstore(add(_pPairing, 64), calldataload(add(proof, 64))) mstore(add(_pPairing, 96), calldataload(add(proof, 96))) mstore(add(_pPairing, 128), calldataload(add(proof, 128))) mstore(add(_pPairing, 160), calldataload(add(proof, 160))) // alpha1 mstore(add(_pPairing, 192), alphax) mstore(add(_pPairing, 224), alphay) // beta2 mstore(add(_pPairing, 256), betax1) mstore(add(_pPairing, 288), betax2) mstore(add(_pPairing, 320), betay1) mstore(add(_pPairing, 352), betay2) // vk_x mstore(add(_pPairing, 384), mload(add(pMem, pVk))) mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32)))) // gamma2 mstore(add(_pPairing, 448), gammax1) mstore(add(_pPairing, 480), gammax2) mstore(add(_pPairing, 512), gammay1) mstore(add(_pPairing, 544), gammay2) // C mstore(add(_pPairing, 576), calldataload(add(proof, 192))) mstore(add(_pPairing, 608), calldataload(add(proof, 224))) // delta2 mstore(add(_pPairing, 640), deltax1) mstore(add(_pPairing, 672), deltax2) mstore(add(_pPairing, 704), deltay1) mstore(add(_pPairing, 736), deltay2) let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20) isOk := and(success, mload(_pPairing)) } let pMem := mload(0x40) mstore(0x40, add(pMem, pLastMem)) // Validate that all evaluations ∈ F checkField(calldataload(add(_pubSignals, 0))) checkField(calldataload(add(_pubSignals, 32))) checkField(calldataload(add(_pubSignals, 64))) checkField(calldataload(add(_pubSignals, 96))) checkField(calldataload(add(_pubSignals, 128))) checkField(calldataload(add(_pubSignals, 160))) checkField(calldataload(add(_pubSignals, 192))) // Validate all evaluations let isValid := checkPairing(_proof, _pubSignals, pMem) mstore(0, isValid) return(0, 0x20) } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; abstract contract PlonkVerifier { // The proof memory locations. uint256 internal constant CM_W0_X_LOC = 0x200 + 0x00; uint256 internal constant CM_W0_Y_LOC = 0x200 + 0x20; uint256 internal constant CM_W1_X_LOC = 0x200 + 0x40; uint256 internal constant CM_W1_Y_LOC = 0x200 + 0x60; uint256 internal constant CM_W2_X_LOC = 0x200 + 0x80; uint256 internal constant CM_W2_Y_LOC = 0x200 + 0xa0; uint256 internal constant CM_W3_X_LOC = 0x200 + 0xc0; uint256 internal constant CM_W3_Y_LOC = 0x200 + 0xe0; uint256 internal constant CM_W4_X_LOC = 0x200 + 0x100; uint256 internal constant CM_W4_Y_LOC = 0x200 + 0x120; uint256 internal constant CM_W0_SEL_X_LOC = 0x200 + 0x140; uint256 internal constant CM_W0_SEL_Y_LOC = 0x200 + 0x160; uint256 internal constant CM_W1_SEL_X_LOC = 0x200 + 0x180; uint256 internal constant CM_W1_SEL_Y_LOC = 0x200 + 0x1a0; uint256 internal constant CM_W2_SEL_X_LOC = 0x200 + 0x1c0; uint256 internal constant CM_W2_SEL_Y_LOC = 0x200 + 0x1e0; uint256 internal constant CM_T0_X_LOC = 0x200 + 0x200; uint256 internal constant CM_T0_Y_LOC = 0x200 + 0x220; uint256 internal constant CM_T1_X_LOC = 0x200 + 0x240; uint256 internal constant CM_T1_Y_LOC = 0x200 + 0x260; uint256 internal constant CM_T2_X_LOC = 0x200 + 0x280; uint256 internal constant CM_T2_Y_LOC = 0x200 + 0x2a0; uint256 internal constant CM_T3_X_LOC = 0x200 + 0x2c0; uint256 internal constant CM_T3_Y_LOC = 0x200 + 0x2e0; uint256 internal constant CM_T4_X_LOC = 0x200 + 0x300; uint256 internal constant CM_T4_Y_LOC = 0x200 + 0x320; uint256 internal constant CM_Z_X_LOC = 0x200 + 0x340; uint256 internal constant CM_Z_Y_LOC = 0x200 + 0x360; uint256 internal constant PRK_3_EVAL_ZETA_LOC = 0x200 + 0x380; uint256 internal constant PRK_4_EVAL_ZETA_LOC = 0x200 + 0x3a0; uint256 internal constant W_POLY_EVAL_ZETA_0_LOC = 0x200 + 0x3c0; uint256 internal constant W_POLY_EVAL_ZETA_1_LOC = 0x200 + 0x3e0; uint256 internal constant W_POLY_EVAL_ZETA_2_LOC = 0x200 + 0x400; uint256 internal constant W_POLY_EVAL_ZETA_3_LOC = 0x200 + 0x420; uint256 internal constant W_POLY_EVAL_ZETA_4_LOC = 0x200 + 0x440; uint256 internal constant W_POLY_EVAL_ZETA_OMEGA_0_LOC = 0x200 + 0x460; uint256 internal constant W_POLY_EVAL_ZETA_OMEGA_1_LOC = 0x200 + 0x480; uint256 internal constant W_POLY_EVAL_ZETA_OMEGA_2_LOC = 0x200 + 0x4a0; uint256 internal constant Z_EVAL_ZETA_OMEGA_LOC = 0x200 + 0x4c0; uint256 internal constant S_POLY_EVAL_ZETA_0_LOC = 0x200 + 0x4e0; uint256 internal constant S_POLY_EVAL_ZETA_1_LOC = 0x200 + 0x500; uint256 internal constant S_POLY_EVAL_ZETA_2_LOC = 0x200 + 0x520; uint256 internal constant S_POLY_EVAL_ZETA_3_LOC = 0x200 + 0x540; uint256 internal constant Q_ECC_POLY_EVAL_ZETA_LOC = 0x200 + 0x560; uint256 internal constant W_SEL_POLY_EVAL_ZETA_0_LOC = 0x200 + 0x580; uint256 internal constant W_SEL_POLY_EVAL_ZETA_1_LOC = 0x200 + 0x5a0; uint256 internal constant W_SEL_POLY_EVAL_ZETA_2_LOC = 0x200 + 0x5c0; uint256 internal constant OPENING_ZETA_X_LOC = 0x200 + 0x5e0; uint256 internal constant OPENING_ZETA_Y_LOC = 0x200 + 0x600; uint256 internal constant OPENING_ZETA_OMEGA_X_LOC = 0x200 + 0x620; uint256 internal constant OPENING_ZETA_OMEGA_Y_LOC = 0x200 + 0x640; // The challenge memory locations. uint256 internal constant ALPHA_LOC = 0x200 + 0x660; uint256 internal constant BETA_LOC = 0x200 + 0x680; uint256 internal constant GAMMA_LOC = 0x200 + 0x6a0; uint256 internal constant ZETA_LOC = 0x200 + 0x6c0; uint256 internal constant U_LOC = 0x200 + 0x6e0; uint256 internal constant ALPHA_POW_2_LOC = 0x200 + 0x700; uint256 internal constant ALPHA_POW_3_LOC = 0x200 + 0x720; uint256 internal constant ALPHA_POW_4_LOC = 0x200 + 0x740; uint256 internal constant ALPHA_POW_5_LOC = 0x200 + 0x760; uint256 internal constant ALPHA_POW_6_LOC = 0x200 + 0x780; uint256 internal constant ALPHA_POW_7_LOC = 0x200 + 0x7a0; uint256 internal constant ALPHA_POW_8_LOC = 0x200 + 0x7c0; uint256 internal constant ALPHA_POW_9_LOC = 0x200 + 0x7e0; uint256 internal constant ALPHA_POW_10_LOC = 0x200 + 0x800; uint256 internal constant ALPHA_POW_11_LOC = 0x200 + 0x820; uint256 internal constant ALPHA_POW_12_LOC = 0x200 + 0x840; uint256 internal constant ALPHA_POW_13_LOC = 0x200 + 0x860; uint256 internal constant ALPHA_POW_14_LOC = 0x200 + 0x880; uint256 internal constant ALPHA_POW_15_LOC = 0x200 + 0x8a0; uint256 internal constant ALPHA_POW_16_LOC = 0x200 + 0x8c0; uint256 internal constant ALPHA_BATCH_12_LOC = 0x200 + 0x8e0; uint256 internal constant ALPHA_BATCH_4_LOC = 0x200 + 0x900; // The verifier key memory locations uint256 internal constant CM_Q0_X_LOC = 0x200 + 0x920; uint256 internal constant CM_Q0_Y_LOC = 0x200 + 0x940; uint256 internal constant CM_Q1_X_LOC = 0x200 + 0x960; uint256 internal constant CM_Q1_Y_LOC = 0x200 + 0x980; uint256 internal constant CM_Q2_X_LOC = 0x200 + 0x9a0; uint256 internal constant CM_Q2_Y_LOC = 0x200 + 0x9c0; uint256 internal constant CM_Q3_X_LOC = 0x200 + 0x9e0; uint256 internal constant CM_Q3_Y_LOC = 0x200 + 0xa00; uint256 internal constant CM_Q4_X_LOC = 0x200 + 0xa20; uint256 internal constant CM_Q4_Y_LOC = 0x200 + 0xa40; uint256 internal constant CM_Q5_X_LOC = 0x200 + 0xa60; uint256 internal constant CM_Q5_Y_LOC = 0x200 + 0xa80; uint256 internal constant CM_Q6_X_LOC = 0x200 + 0xaa0; uint256 internal constant CM_Q6_Y_LOC = 0x200 + 0xac0; uint256 internal constant CM_Q7_X_LOC = 0x200 + 0xae0; uint256 internal constant CM_Q7_Y_LOC = 0x200 + 0xb00; uint256 internal constant CM_S0_X_LOC = 0x200 + 0xb20; uint256 internal constant CM_S0_Y_LOC = 0x200 + 0xb40; uint256 internal constant CM_S1_X_LOC = 0x200 + 0xb60; uint256 internal constant CM_S1_Y_LOC = 0x200 + 0xb80; uint256 internal constant CM_S2_X_LOC = 0x200 + 0xba0; uint256 internal constant CM_S2_Y_LOC = 0x200 + 0xbc0; uint256 internal constant CM_S3_X_LOC = 0x200 + 0xbe0; uint256 internal constant CM_S3_Y_LOC = 0x200 + 0xc00; uint256 internal constant CM_S4_X_LOC = 0x200 + 0xc20; uint256 internal constant CM_S4_Y_LOC = 0x200 + 0xc40; uint256 internal constant CM_QB_X_LOC = 0x200 + 0xc60; uint256 internal constant CM_QB_Y_LOC = 0x200 + 0xc80; uint256 internal constant CM_PRK_0_X_LOC = 0x200 + 0xca0; uint256 internal constant CM_PRK_0_Y_LOC = 0x200 + 0xcc0; uint256 internal constant CM_PRK_1_X_LOC = 0x200 + 0xce0; uint256 internal constant CM_PRK_1_Y_LOC = 0x200 + 0xd00; uint256 internal constant CM_PRK_2_X_LOC = 0x200 + 0xd20; uint256 internal constant CM_PRK_2_Y_LOC = 0x200 + 0xd40; uint256 internal constant CM_PRK_3_X_LOC = 0x200 + 0xd60; uint256 internal constant CM_PRK_3_Y_LOC = 0x200 + 0xd80; uint256 internal constant CM_Q_ECC_X_LOC = 0x200 + 0xda0; uint256 internal constant CM_Q_ECC_Y_LOC = 0x200 + 0xdc0; uint256 internal constant CM_SHUFFLE_GENERATOR_0_X_LOC = 0x200 + 0xde0; uint256 internal constant CM_SHUFFLE_GENERATOR_0_Y_LOC = 0x200 + 0xe00; uint256 internal constant CM_SHUFFLE_GENERATOR_1_X_LOC = 0x200 + 0xe20; uint256 internal constant CM_SHUFFLE_GENERATOR_1_Y_LOC = 0x200 + 0xe40; uint256 internal constant CM_SHUFFLE_GENERATOR_2_X_LOC = 0x200 + 0xe60; uint256 internal constant CM_SHUFFLE_GENERATOR_2_Y_LOC = 0x200 + 0xe80; uint256 internal constant CM_SHUFFLE_GENERATOR_3_X_LOC = 0x200 + 0xea0; uint256 internal constant CM_SHUFFLE_GENERATOR_3_Y_LOC = 0x200 + 0xec0; uint256 internal constant CM_SHUFFLE_GENERATOR_4_X_LOC = 0x200 + 0xee0; uint256 internal constant CM_SHUFFLE_GENERATOR_4_Y_LOC = 0x200 + 0xf00; uint256 internal constant CM_SHUFFLE_GENERATOR_5_X_LOC = 0x200 + 0xf20; uint256 internal constant CM_SHUFFLE_GENERATOR_5_Y_LOC = 0x200 + 0xf40; uint256 internal constant CM_SHUFFLE_GENERATOR_6_X_LOC = 0x200 + 0xf60; uint256 internal constant CM_SHUFFLE_GENERATOR_6_Y_LOC = 0x200 + 0xf80; uint256 internal constant CM_SHUFFLE_GENERATOR_7_X_LOC = 0x200 + 0xfa0; uint256 internal constant CM_SHUFFLE_GENERATOR_7_Y_LOC = 0x200 + 0xfc0; uint256 internal constant CM_SHUFFLE_GENERATOR_8_X_LOC = 0x200 + 0xfe0; uint256 internal constant CM_SHUFFLE_GENERATOR_8_Y_LOC = 0x200 + 0x1000; uint256 internal constant CM_SHUFFLE_GENERATOR_9_X_LOC = 0x200 + 0x1020; uint256 internal constant CM_SHUFFLE_GENERATOR_9_Y_LOC = 0x200 + 0x1040; uint256 internal constant CM_SHUFFLE_GENERATOR_10_X_LOC = 0x200 + 0x1060; uint256 internal constant CM_SHUFFLE_GENERATOR_10_Y_LOC = 0x200 + 0x1080; uint256 internal constant CM_SHUFFLE_GENERATOR_11_X_LOC = 0x200 + 0x10a0; uint256 internal constant CM_SHUFFLE_GENERATOR_11_Y_LOC = 0x200 + 0x10c0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_0_X_LOC = 0x200 + 0x10e0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_0_Y_LOC = 0x200 + 0x1100; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_1_X_LOC = 0x200 + 0x1120; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_1_Y_LOC = 0x200 + 0x1140; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_2_X_LOC = 0x200 + 0x1160; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_2_Y_LOC = 0x200 + 0x1180; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_3_X_LOC = 0x200 + 0x11a0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_3_Y_LOC = 0x200 + 0x11c0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_4_X_LOC = 0x200 + 0x11e0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_4_Y_LOC = 0x200 + 0x1200; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_5_X_LOC = 0x200 + 0x1220; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_5_Y_LOC = 0x200 + 0x1240; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_6_X_LOC = 0x200 + 0x1260; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_6_Y_LOC = 0x200 + 0x1280; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_7_X_LOC = 0x200 + 0x12a0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_7_Y_LOC = 0x200 + 0x12c0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_8_X_LOC = 0x200 + 0x12e0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_8_Y_LOC = 0x200 + 0x1300; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_9_X_LOC = 0x200 + 0x1320; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_9_Y_LOC = 0x200 + 0x1340; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_10_X_LOC = 0x200 + 0x1360; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_10_Y_LOC = 0x200 + 0x1380; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_11_X_LOC = 0x200 + 0x13a0; uint256 internal constant CM_SHUFFLE_PUBLIC_KEY_11_Y_LOC = 0x200 + 0x13c0; uint256 internal constant ANEMOI_GENERATOR_LOC = 0x200 + 0x13e0; uint256 internal constant ANEMOI_GENERATOR_INV_LOC = 0x200 + 0x1400; uint256 internal constant K_0_LOC = 0x200 + 0x1420; uint256 internal constant K_1_LOC = 0x200 + 0x1440; uint256 internal constant K_2_LOC = 0x200 + 0x1460; uint256 internal constant K_3_LOC = 0x200 + 0x1480; uint256 internal constant K_4_LOC = 0x200 + 0x14a0; uint256 internal constant EDWARDS_A_LOC = 0x200 + 0x14c0; uint256 internal constant ROOT_LOC = 0x200 + 0x14e0; uint256 internal constant CS_SIZE_LOC = 0x200 + 0x1500; // The intermediary variable memory locations. uint256 internal constant Z_H_EVAL_ZETA_LOC = 0x200 + 0x1520; uint256 internal constant FIRST_LAGRANGE_EVAL_ZETA_LOC = 0x200 + 0x1540; uint256 internal constant PI_EVAL_ZETA_LOC = 0x200 + 0x1560; uint256 internal constant W3_W0_LOC = 0x200 + 0x1580; uint256 internal constant W2_W1_LOC = 0x200 + 0x15a0; uint256 internal constant W3_2W0_LOC = 0x200 + 0x15c0; uint256 internal constant W2_2W1_LOC = 0x200 + 0x15e0; uint256 internal constant R_EVAL_ZETA_LOC = 0x200 + 0x1600; uint256 internal constant R_COMMITMENT_X_LOC = 0x200 + 0x1620; uint256 internal constant R_COMMITMENT_Y_LOC = 0x200 + 0x1640; uint256 internal constant COMMITMENT_X_LOC = 0x200 + 0x1660; uint256 internal constant COMMITMENT_Y_LOC = 0x200 + 0x1680; uint256 internal constant VALUE_LOC = 0x200 + 0x16a0; uint256 internal constant BATCH_COMMITMENT_X_LOC = 0x200 + 0x16c0; uint256 internal constant BATCH_COMMITMENT_Y_LOC = 0x200 + 0x16e0; uint256 internal constant BATCH_VALUE_LOC = 0x200 + 0x1700; uint256 internal constant SUCCESS_LOC = 0x200 + 0x1720; uint256 internal constant SEL_00_LOC = 0x200 + 0x1740; uint256 internal constant SEL_01_LOC = 0x200 + 0x1760; uint256 internal constant SEL_10_LOC = 0x200 + 0x1780; uint256 internal constant SEL_11_LOC = 0x200 + 0x17a0; // We reserve 5 slots for external input TRANSCRIPT, // so the length of the external input TRANSCRIPT cannot exceed 5. uint256 internal constant EXTERNAL_TRANSCRIPT_LENGTH_LOC = 0x200 + 0x17c0; // The first slot represents the length of pulic inputs, // the next slot for the length of pulic inputs represents the public constrain variables indices(power format), // the following slot for the length of pulic inputs represents the constrain lagrange base by public constrain variables. // and the following slot for the length of pulic inputs represents the constrain lagrange base by public inputs. uint256 internal constant PI_POLY_RELATED_LOC = 0x200 + 0x1860; bytes4 internal constant sig1 = 0x9e01fc03; bytes4 internal constant sig2 = 0x264f76ef; function verifyShuffleProof(address vk1, address vk2) public view returns (bool) { return verifyProof(vk1, vk2, true); } function verifyGenericProof(address vk1, address vk2) public view returns (bool) { return verifyProof(vk1, vk2, false); } function verifyProof(address vk1, address vk2, bool shuffle_specified) private view returns (bool) { assembly { // The scalar field of BN254. let r := 21888242871839275222246405745257275088548364400416034343698204186575808495617 mstore(0x40, add(mul(mload(PI_POLY_RELATED_LOC), 0x20), add(0x20, PI_POLY_RELATED_LOC))) mstore(mload(SUCCESS_LOC), true) // Rerutn the invert of the value. function invert(fr) -> result { mstore(mload(0x40), 0x20) mstore(add(mload(0x40), 0x20), 0x20) mstore(add(mload(0x40), 0x40), 0x20) mstore(add(mload(0x40), 0x60), fr) mstore( add(mload(0x40), 0x80), sub(21888242871839275222246405745257275088548364400416034343698204186575808495617, 2) ) mstore( add(mload(0x40), 0xa0), 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let success_flag := staticcall(gas(), 0x05, mload(0x40), 0xc0, mload(0x40), 0x20) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) result := mload(mload(0x40)) } // Batch invert values in memory[mload(0x40)..end_ptr] in place. function batchInvert(end_ptr) { let prod_ptr := add(end_ptr, 0x20) let tmp := mload(mload(0x40)) mstore(prod_ptr, tmp) for { let i := add(mload(0x40), 0x20) } lt(i, add(end_ptr, 0x01)) { i := add(i, 0x20) } { tmp := mulmod( tmp, mload(i), 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) prod_ptr := add(prod_ptr, 0x20) mstore(prod_ptr, tmp) } mstore(add(prod_ptr, 0x20), 0x20) mstore(add(prod_ptr, 0x40), 0x20) mstore(add(prod_ptr, 0x60), 0x20) mstore(add(prod_ptr, 0x80), tmp) mstore( add(prod_ptr, 0xa0), sub(21888242871839275222246405745257275088548364400416034343698204186575808495617, 2) ) mstore( add(prod_ptr, 0xc0), 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let success_flag := staticcall(gas(), 0x05, add(prod_ptr, 0x20), 0xc0, add(prod_ptr, 0x20), 0x20) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) let all_inv := mload(add(prod_ptr, 0x20)) prod_ptr := sub(prod_ptr, 0x20) for { } lt(mload(0x40), end_ptr) { } { let inv := mulmod( all_inv, mload(prod_ptr), 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) all_inv := mulmod( all_inv, mload(end_ptr), 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) mstore(end_ptr, inv) prod_ptr := sub(prod_ptr, 0x20) end_ptr := sub(end_ptr, 0x20) } mstore(mload(0x40), all_inv) } // Return base^exponent (mod modulus) function powSmall(base, exponent) -> result { result := 1 let input := base for { let count := 1 } lt(count, add(exponent, 0x01)) { count := add(count, count) } { if and(exponent, count) { result := mulmod( result, input, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) } input := mulmod( input, input, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) } } // Scale point by scalar. function scalarMul(x, y, scalar) { mstore(mload(0x40), x) mstore(add(mload(0x40), 0x20), y) mstore(add(mload(0x40), 0x40), scalar) let success_flag := staticcall(gas(), 7, mload(0x40), 0x60, mload(0x40), 0x40) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) } // Add point into point. function pointAdd(x0, y0, x1, y1) { mstore(mload(0x40), x0) mstore(add(mload(0x40), 0x20), y0) mstore(add(mload(0x40), 0x40), x1) mstore(add(mload(0x40), 0x60), y1) let success_flag := staticcall(gas(), 6, mload(0x40), 0x80, mload(0x40), 0x40) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) } // Add point(x,y) into point at (mload(0x40), add(mload(0x40),0x20)). function pointAddInMemory(x, y) { mstore(add(mload(0x40), 0x40), x) mstore(add(mload(0x40), 0x60), y) let success_flag := staticcall(gas(), 6, mload(0x40), 0x80, mload(0x40), 0x40) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) } function loadPiIndice(sig, v, i) -> result { let pi_ptr := add(mul(mload(PI_POLY_RELATED_LOC), 0x40), add(0x20, PI_POLY_RELATED_LOC)) // skip tmp mstore(pi_ptr, sig) mstore(add(pi_ptr, 0x04), i) // PI_POLY_INDICES_LOC let success_flag := staticcall(gas(), v, pi_ptr, 0x24, pi_ptr, 0x20) mstore(mload(SUCCESS_LOC), and(mload(mload(SUCCESS_LOC)), success_flag)) result := mload(pi_ptr) } // 1. compute all challenges. { let external_transcript_length := mload(EXTERNAL_TRANSCRIPT_LENGTH_LOC) for { let i := 0 } lt(i, external_transcript_length) { i := add(i, 1) } { mstore( add(mload(0x40), mul(i, 0x20)), mload(add(add(EXTERNAL_TRANSCRIPT_LENGTH_LOC, 0x20), mul(i, 0x20))) ) } let ptr := add(mload(0x40), mul(external_transcript_length, 0x20)) mstore(ptr, 0x504c4f4e4b) mstore(add(ptr, 0x20), mload(CS_SIZE_LOC)) mstore(add(ptr, 0x40), r) mstore(add(ptr, 0x60), mload(CM_Q0_X_LOC)) mstore(add(ptr, 0x80), mload(CM_Q0_Y_LOC)) mstore(add(ptr, 0xa0), mload(CM_Q1_X_LOC)) mstore(add(ptr, 0xc0), mload(CM_Q1_Y_LOC)) mstore(add(ptr, 0xe0), mload(CM_Q2_X_LOC)) mstore(add(ptr, 0x100), mload(CM_Q2_Y_LOC)) mstore(add(ptr, 0x120), mload(CM_Q3_X_LOC)) mstore(add(ptr, 0x140), mload(CM_Q3_Y_LOC)) mstore(add(ptr, 0x160), mload(CM_Q4_X_LOC)) mstore(add(ptr, 0x180), mload(CM_Q4_Y_LOC)) mstore(add(ptr, 0x1a0), mload(CM_Q5_X_LOC)) mstore(add(ptr, 0x1c0), mload(CM_Q5_Y_LOC)) mstore(add(ptr, 0x1e0), mload(CM_Q6_X_LOC)) mstore(add(ptr, 0x200), mload(CM_Q6_Y_LOC)) mstore(add(ptr, 0x220), mload(CM_Q7_X_LOC)) mstore(add(ptr, 0x240), mload(CM_Q7_Y_LOC)) mstore(add(ptr, 0x260), mload(CM_S0_X_LOC)) mstore(add(ptr, 0x280), mload(CM_S0_Y_LOC)) mstore(add(ptr, 0x2a0), mload(CM_S1_X_LOC)) mstore(add(ptr, 0x2c0), mload(CM_S1_Y_LOC)) mstore(add(ptr, 0x2e0), mload(CM_S2_X_LOC)) mstore(add(ptr, 0x300), mload(CM_S2_Y_LOC)) mstore(add(ptr, 0x320), mload(CM_S3_X_LOC)) mstore(add(ptr, 0x340), mload(CM_S3_Y_LOC)) mstore(add(ptr, 0x360), mload(CM_S4_X_LOC)) mstore(add(ptr, 0x380), mload(CM_S4_Y_LOC)) mstore(add(ptr, 0x3a0), mload(ROOT_LOC)) mstore(add(ptr, 0x3c0), mload(K_0_LOC)) mstore(add(ptr, 0x3e0), mload(K_1_LOC)) mstore(add(ptr, 0x400), mload(K_2_LOC)) mstore(add(ptr, 0x420), mload(K_3_LOC)) mstore(add(ptr, 0x440), mload(K_4_LOC)) let pi_length := mload(PI_POLY_RELATED_LOC) let pi_ptr := add(PI_POLY_RELATED_LOC, 0x20) for { let i := 0 } lt(i, pi_length) { i := add(i, 1) } { mstore(add(add(ptr, 0x460), mul(i, 0x20)), mload(add(pi_ptr, mul(i, 0x20)))) } ptr := add(add(ptr, 0x460), mul(pi_length, 0x20)) mstore(ptr, mload(CM_W0_X_LOC)) mstore(add(ptr, 0x20), mload(CM_W0_Y_LOC)) mstore(add(ptr, 0x40), mload(CM_W1_X_LOC)) mstore(add(ptr, 0x60), mload(CM_W1_Y_LOC)) mstore(add(ptr, 0x80), mload(CM_W2_X_LOC)) mstore(add(ptr, 0xa0), mload(CM_W2_Y_LOC)) mstore(add(ptr, 0xc0), mload(CM_W3_X_LOC)) mstore(add(ptr, 0xe0), mload(CM_W3_Y_LOC)) mstore(add(ptr, 0x100), mload(CM_W4_X_LOC)) mstore(add(ptr, 0x120), mload(CM_W4_Y_LOC)) if shuffle_specified { mstore(add(ptr, 0x140), mload(CM_W0_SEL_X_LOC)) mstore(add(ptr, 0x160), mload(CM_W0_SEL_Y_LOC)) mstore(add(ptr, 0x180), mload(CM_W1_SEL_X_LOC)) mstore(add(ptr, 0x1a0), mload(CM_W1_SEL_Y_LOC)) mstore(add(ptr, 0x1c0), mload(CM_W2_SEL_X_LOC)) mstore(add(ptr, 0x1e0), mload(CM_W2_SEL_Y_LOC)) } // compute beta challenge. let beta := mod( keccak256( mload(0x40), add(add(mul(external_transcript_length, 0x20), mul(pi_length, 0x20)), 0x660) ), r ) mstore(BETA_LOC, beta) mstore(mload(0x40), beta) // compute gamma challenge. { mstore8(add(mload(0x40), 0x20), 0x01) let gamma := mod(keccak256(mload(0x40), 0x21), r) mstore(GAMMA_LOC, gamma) mstore(mload(0x40), gamma) } // compute alpha challenge. { mstore(add(mload(0x40), 0x20), mload(CM_Z_X_LOC)) mstore(add(mload(0x40), 0x40), mload(CM_Z_Y_LOC)) let alpha := mod(keccak256(mload(0x40), 0x60), r) mstore(ALPHA_LOC, alpha) mstore(mload(0x40), alpha) } // compute zeta challenge. { mstore(add(mload(0x40), 0x20), mload(CM_T0_X_LOC)) mstore(add(mload(0x40), 0x40), mload(CM_T0_Y_LOC)) mstore(add(mload(0x40), 0x60), mload(CM_T1_X_LOC)) mstore(add(mload(0x40), 0x80), mload(CM_T1_Y_LOC)) mstore(add(mload(0x40), 0xa0), mload(CM_T2_X_LOC)) mstore(add(mload(0x40), 0xc0), mload(CM_T2_Y_LOC)) mstore(add(mload(0x40), 0xe0), mload(CM_T3_X_LOC)) mstore(add(mload(0x40), 0x100), mload(CM_T3_Y_LOC)) mstore(add(mload(0x40), 0x120), mload(CM_T4_X_LOC)) mstore(add(mload(0x40), 0x140), mload(CM_T4_Y_LOC)) let zeta := mod(keccak256(mload(0x40), 0x160), r) mstore(ZETA_LOC, zeta) mstore(mload(0x40), zeta) } // compute u challenge. { mstore(add(mload(0x40), 0x20), mload(W_POLY_EVAL_ZETA_0_LOC)) mstore(add(mload(0x40), 0x40), mload(W_POLY_EVAL_ZETA_1_LOC)) mstore(add(mload(0x40), 0x60), mload(W_POLY_EVAL_ZETA_2_LOC)) mstore(add(mload(0x40), 0x80), mload(W_POLY_EVAL_ZETA_3_LOC)) mstore(add(mload(0x40), 0xa0), mload(W_POLY_EVAL_ZETA_4_LOC)) mstore(add(mload(0x40), 0xc0), mload(S_POLY_EVAL_ZETA_0_LOC)) mstore(add(mload(0x40), 0xe0), mload(S_POLY_EVAL_ZETA_1_LOC)) mstore(add(mload(0x40), 0x100), mload(S_POLY_EVAL_ZETA_2_LOC)) mstore(add(mload(0x40), 0x120), mload(S_POLY_EVAL_ZETA_3_LOC)) if shuffle_specified { mstore(add(mload(0x40), 0x140), mload(W_SEL_POLY_EVAL_ZETA_0_LOC)) mstore(add(mload(0x40), 0x160), mload(W_SEL_POLY_EVAL_ZETA_1_LOC)) mstore(add(mload(0x40), 0x180), mload(W_SEL_POLY_EVAL_ZETA_2_LOC)) } mstore(add(mload(0x40), 0x1a0), mload(PRK_3_EVAL_ZETA_LOC)) mstore(add(mload(0x40), 0x1c0), mload(PRK_4_EVAL_ZETA_LOC)) mstore(add(mload(0x40), 0x1e0), mload(Z_EVAL_ZETA_OMEGA_LOC)) if shuffle_specified { // todo put it with W_SEL_POLY_EVAL_ZETA mstore(add(mload(0x40), 0x200), mload(Q_ECC_POLY_EVAL_ZETA_LOC)) } mstore(add(mload(0x40), 0x220), mload(W_POLY_EVAL_ZETA_OMEGA_0_LOC)) mstore(add(mload(0x40), 0x240), mload(W_POLY_EVAL_ZETA_OMEGA_1_LOC)) mstore(add(mload(0x40), 0x260), mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC)) let u := mod(keccak256(mload(0x40), 0x280), r) mstore(U_LOC, u) mstore(mload(0x40), u) } { mstore(add(mload(0x40), 0x20), 0x4e6577205043532d42617463682d4576616c2050726f746f636f6c) mstore(add(mload(0x40), 0x40), r) mstore(add(mload(0x40), 0x60), add(mload(CS_SIZE_LOC), 2)) mstore(add(mload(0x40), 0x80), mload(ZETA_LOC)) let alpha_batch_12 := mod(keccak256(mload(0x40), 0xa0), r) mstore(ALPHA_BATCH_12_LOC, alpha_batch_12) mstore(mload(0x40), alpha_batch_12) } { mstore(add(mload(0x40), 0x20), 0x4e6577205043532d42617463682d4576616c2050726f746f636f6c) mstore(add(mload(0x40), 0x40), r) mstore(add(mload(0x40), 0x60), add(mload(CS_SIZE_LOC), 2)) let zeta_omega := mulmod(mload(ZETA_LOC), mload(ROOT_LOC), r) mstore(add(mload(0x40), 0x80), zeta_omega) let alpha_batch_4 := mod(keccak256(mload(0x40), 0xa0), r) mstore(ALPHA_BATCH_4_LOC, alpha_batch_4) } { let alpha := mload(ALPHA_LOC) // r = 21888242871839275222246405745257275088548364400416034343698204186575808495617 let alpha_pow_2 := mulmod( alpha, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_3 := mulmod( alpha_pow_2, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_4 := mulmod( alpha_pow_3, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_5 := mulmod( alpha_pow_4, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_6 := mulmod( alpha_pow_5, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_7 := mulmod( alpha_pow_6, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_8 := mulmod( alpha_pow_7, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_9 := mulmod( alpha_pow_8, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) mstore(ALPHA_POW_2_LOC, alpha_pow_2) mstore(ALPHA_POW_3_LOC, alpha_pow_3) mstore(ALPHA_POW_4_LOC, alpha_pow_4) mstore(ALPHA_POW_5_LOC, alpha_pow_5) mstore(ALPHA_POW_6_LOC, alpha_pow_6) mstore(ALPHA_POW_7_LOC, alpha_pow_7) mstore(ALPHA_POW_8_LOC, alpha_pow_8) mstore(ALPHA_POW_9_LOC, alpha_pow_9) if shuffle_specified { let alpha_pow_10 := mulmod( alpha_pow_9, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_11 := mulmod( alpha_pow_10, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_12 := mulmod( alpha_pow_11, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_13 := mulmod( alpha_pow_12, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_14 := mulmod( alpha_pow_13, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_15 := mulmod( alpha_pow_14, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) let alpha_pow_16 := mulmod( alpha_pow_15, alpha, 21888242871839275222246405745257275088548364400416034343698204186575808495617 ) mstore(ALPHA_POW_10_LOC, alpha_pow_10) mstore(ALPHA_POW_11_LOC, alpha_pow_11) mstore(ALPHA_POW_12_LOC, alpha_pow_12) mstore(ALPHA_POW_13_LOC, alpha_pow_13) mstore(ALPHA_POW_14_LOC, alpha_pow_14) mstore(ALPHA_POW_15_LOC, alpha_pow_15) mstore(ALPHA_POW_16_LOC, alpha_pow_16) } } } // 2. compute Z_h(\zeta) and L_1(\zeta). { let zeta := mload(ZETA_LOC) let zeta_power_n := powSmall(zeta, mload(CS_SIZE_LOC)) let z_h_eval_zeta := addmod(zeta_power_n, sub(r, 1), r) let zeta_minus_one := addmod(zeta, sub(r, 1), r) let zeta_minus_one_inv := invert(zeta_minus_one) let first_lagrange_eval_zeta := mulmod(z_h_eval_zeta, zeta_minus_one_inv, r) mstore(Z_H_EVAL_ZETA_LOC, z_h_eval_zeta) mstore(FIRST_LAGRANGE_EVAL_ZETA_LOC, first_lagrange_eval_zeta) } // 3. compute PI(\zeta). { let pi_length := mload(PI_POLY_RELATED_LOC) let pi_ptr := add(PI_POLY_RELATED_LOC, 0x20) let denominator_prod := 1 let zeta := mload(ZETA_LOC) let end_ptr := mload(0x40) for { let i := 0 } lt(i, sub(pi_length, 1)) { i := add(i, 1) } { let root_pow := loadPiIndice(sig1, vk1, i) let denominator := addmod(zeta, sub(r, root_pow), r) mstore(end_ptr, denominator) end_ptr := add(end_ptr, 0x20) } let root_pow := loadPiIndice(sig1, vk1, sub(pi_length, 1)) let denominator := addmod(zeta, sub(r, root_pow), r) mstore(end_ptr, denominator) batchInvert(end_ptr) let eval := 0 for { let i := 0 } lt(i, pi_length) { i := add(i, 1) } { let lagrange_constant := loadPiIndice(sig2, vk2, i) let public_input := mload(add(pi_ptr, mul(i, 0x20))) let tmp := mulmod( mulmod(lagrange_constant, mload(add(mload(0x40), mul(i, 0x20))), r), public_input, r ) eval := addmod(tmp, eval, r) } eval := mulmod(eval, mload(Z_H_EVAL_ZETA_LOC), r) mstore(PI_EVAL_ZETA_LOC, eval) } // 4. derive the linearization polynomial. { let res := sub(r, mload(PI_EVAL_ZETA_LOC)) { let term1 := mulmod(mload(ALPHA_LOC), mload(Z_EVAL_ZETA_OMEGA_LOC), r) let beta := mload(BETA_LOC) let gamma := mload(GAMMA_LOC) let tmp := addmod( addmod(mload(W_POLY_EVAL_ZETA_0_LOC), gamma, r), mulmod(beta, mload(S_POLY_EVAL_ZETA_0_LOC), r), r ) term1 := mulmod(term1, tmp, r) tmp := addmod( addmod(mload(W_POLY_EVAL_ZETA_1_LOC), gamma, r), mulmod(beta, mload(S_POLY_EVAL_ZETA_1_LOC), r), r ) term1 := mulmod(term1, tmp, r) tmp := addmod( addmod(mload(W_POLY_EVAL_ZETA_2_LOC), gamma, r), mulmod(beta, mload(S_POLY_EVAL_ZETA_2_LOC), r), r ) term1 := mulmod(term1, tmp, r) tmp := addmod( addmod(mload(W_POLY_EVAL_ZETA_3_LOC), gamma, r), mulmod(beta, mload(S_POLY_EVAL_ZETA_3_LOC), r), r ) term1 := mulmod(term1, tmp, r) term1 := mulmod(term1, addmod(gamma, mload(W_POLY_EVAL_ZETA_4_LOC), r), r) res := addmod(res, term1, r) } { let term2 := mulmod(mload(FIRST_LAGRANGE_EVAL_ZETA_LOC), mload(ALPHA_POW_2_LOC), r) res := addmod(res, term2, r) } { let anemoi_generator := mload(ANEMOI_GENERATOR_LOC) let tmp { let w3_w0 := addmod(mload(W_POLY_EVAL_ZETA_3_LOC), mload(W_POLY_EVAL_ZETA_0_LOC), r) let w2_w1 := addmod(mload(W_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_1_LOC), r) let w3_2w0 := addmod(w3_w0, mload(W_POLY_EVAL_ZETA_0_LOC), r) let w2_2w1 := addmod(w2_w1, mload(W_POLY_EVAL_ZETA_1_LOC), r) mstore(W3_W0_LOC, w2_w1) mstore(W2_W1_LOC, w3_w0) mstore(W3_2W0_LOC, w2_2w1) mstore(W2_2W1_LOC, w3_2w0) tmp := addmod( addmod(w3_w0, mload(PRK_3_EVAL_ZETA_LOC), r), mulmod(w2_w1, anemoi_generator, r), r ) } let tmp_sub_w2_polys_eval_zeta_omega_pow_5 { let tmp_sub_w2_polys_eval_zeta_omega := addmod( tmp, sub(r, mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC)), r ) let tmp_sub_w2_polys_eval_zeta_omega_pow_2 := mulmod( tmp_sub_w2_polys_eval_zeta_omega, tmp_sub_w2_polys_eval_zeta_omega, r ) let tmp_sub_w2_polys_eval_zeta_omega_pow_4 := mulmod( tmp_sub_w2_polys_eval_zeta_omega_pow_2, tmp_sub_w2_polys_eval_zeta_omega_pow_2, r ) tmp_sub_w2_polys_eval_zeta_omega_pow_5 := mulmod( tmp_sub_w2_polys_eval_zeta_omega, tmp_sub_w2_polys_eval_zeta_omega_pow_4, r ) } { let term3 := addmod( addmod( tmp_sub_w2_polys_eval_zeta_omega_pow_5, sub(r, addmod(mload(W2_2W1_LOC), mulmod(anemoi_generator, mload(W3_2W0_LOC), r), r)), r ), mulmod(anemoi_generator, mulmod(tmp, tmp, r), r), r ) term3 := mulmod(term3, mulmod(mload(ALPHA_POW_6_LOC), mload(PRK_3_EVAL_ZETA_LOC), r), r) res := addmod(res, term3, r) } { let w2_polys_eval_zeta_omega := mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC) let w2_polys_eval_zeta_omega_square := mulmod( w2_polys_eval_zeta_omega, w2_polys_eval_zeta_omega, r ) let term5 := mulmod(mload(ALPHA_POW_8_LOC), mload(PRK_3_EVAL_ZETA_LOC), r) let term5_tmp := addmod( addmod(tmp_sub_w2_polys_eval_zeta_omega_pow_5, mload(ANEMOI_GENERATOR_INV_LOC), r), mulmod(anemoi_generator, w2_polys_eval_zeta_omega_square, r), r ) term5_tmp := addmod(term5_tmp, sub(r, mload(W_POLY_EVAL_ZETA_OMEGA_0_LOC)), r) term5 := mulmod(term5, term5_tmp, r) res := addmod(res, term5, r) } } { let anemoi_generator := mload(ANEMOI_GENERATOR_LOC) let anemoi_generator_square_plus_one := addmod(1, mulmod(anemoi_generator, anemoi_generator, r), r) let tmp let tmp_sub_w4_polys_eval_zeta_pow_5 { tmp := addmod( addmod( mload(PRK_4_EVAL_ZETA_LOC), mulmod(anemoi_generator_square_plus_one, mload(W3_W0_LOC), r), r ), mulmod(anemoi_generator, mload(W2_W1_LOC), r), r ) let tmp_sub_w4_polys_eval_zeta := addmod(tmp, sub(r, mload(W_POLY_EVAL_ZETA_4_LOC)), r) let tmp_sub_w4_polys_eval_zeta_pow_2 := mulmod( tmp_sub_w4_polys_eval_zeta, tmp_sub_w4_polys_eval_zeta, r ) let tmp_sub_w4_polys_eval_zeta_pow_4 := mulmod( tmp_sub_w4_polys_eval_zeta_pow_2, tmp_sub_w4_polys_eval_zeta_pow_2, r ) tmp_sub_w4_polys_eval_zeta_pow_5 := mulmod( tmp_sub_w4_polys_eval_zeta, tmp_sub_w4_polys_eval_zeta_pow_4, r ) } { let term4 := mulmod(mload(ALPHA_POW_7_LOC), mload(PRK_3_EVAL_ZETA_LOC), r) let term4_tmp := addmod( addmod( tmp_sub_w4_polys_eval_zeta_pow_5, sub( r, addmod( mulmod(anemoi_generator, mload(W2_2W1_LOC), r), mulmod(anemoi_generator_square_plus_one, mload(W3_2W0_LOC), r), r ) ), r ), mulmod(anemoi_generator, mulmod(tmp, tmp, r), r), r ) term4 := mulmod(term4, term4_tmp, r) res := addmod(res, term4, r) } { let term6 := mulmod(mload(ALPHA_POW_9_LOC), mload(PRK_3_EVAL_ZETA_LOC), r) let term6_tmp := addmod( addmod( addmod(tmp_sub_w4_polys_eval_zeta_pow_5, mload(ANEMOI_GENERATOR_INV_LOC), r), sub(r, mload(W_POLY_EVAL_ZETA_OMEGA_1_LOC)), r ), mulmod( anemoi_generator, mulmod(mload(W_POLY_EVAL_ZETA_4_LOC), mload(W_POLY_EVAL_ZETA_4_LOC), r), r ), r ) term6 := mulmod(term6, term6_tmp, r) res := addmod(res, term6, r) } } if shuffle_specified { let sel_00 := addmod( mulmod( addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_0_LOC)), r), addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_1_LOC)), r), r ), addmod(mload(Q_ECC_POLY_EVAL_ZETA_LOC), sub(r, 1), r), r ) let sel_01 := mulmod( mload(W_SEL_POLY_EVAL_ZETA_0_LOC), addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_1_LOC)), r), r ) let sel_10 := mulmod( mload(W_SEL_POLY_EVAL_ZETA_1_LOC), addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_0_LOC)), r), r ) let sel_11 := mulmod(mload(W_SEL_POLY_EVAL_ZETA_0_LOC), mload(W_SEL_POLY_EVAL_ZETA_1_LOC), r) mstore(SEL_00_LOC, sel_00) mstore(SEL_01_LOC, sel_01) mstore(SEL_10_LOC, sel_10) mstore(SEL_11_LOC, sel_11) let sel_sum := addmod(addmod(sel_00, sel_01, r), addmod(sel_10, sel_11, r), r) let term7 := mulmod( mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), sel_sum, r), addmod( addmod( mulmod(mload(ALPHA_POW_10_LOC), mload(W_POLY_EVAL_ZETA_OMEGA_0_LOC), r), mulmod(mload(ALPHA_POW_11_LOC), mload(W_POLY_EVAL_ZETA_OMEGA_1_LOC), r), r ), addmod( mulmod(mload(ALPHA_POW_12_LOC), mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC), r), mulmod(mload(ALPHA_POW_13_LOC), mload(W_POLY_EVAL_ZETA_4_LOC), r), r ), r ), r ) res := addmod(res, sub(r, term7), r) } if shuffle_specified { let term8 := mulmod( mload(ALPHA_POW_14_LOC), addmod( mulmod( mload(Q_ECC_POLY_EVAL_ZETA_LOC), mulmod( mload(W_SEL_POLY_EVAL_ZETA_0_LOC), addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_0_LOC)), r), r ), r ), mulmod( addmod(1, sub(r, mload(Q_ECC_POLY_EVAL_ZETA_LOC)), r), mload(W_SEL_POLY_EVAL_ZETA_0_LOC), r ), r ), r ) res := addmod(res, sub(r, term8), r) } if shuffle_specified { let term9 := mulmod( mload(ALPHA_POW_15_LOC), addmod( mulmod( mload(Q_ECC_POLY_EVAL_ZETA_LOC), mulmod( mload(W_SEL_POLY_EVAL_ZETA_1_LOC), addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_1_LOC)), r), r ), r ), mulmod( addmod(1, sub(r, mload(Q_ECC_POLY_EVAL_ZETA_LOC)), r), mload(W_SEL_POLY_EVAL_ZETA_1_LOC), r ), r ), r ) res := addmod(res, sub(r, term9), r) } if shuffle_specified { let term10 := mulmod( mulmod(mload(ALPHA_POW_16_LOC), mload(Q_ECC_POLY_EVAL_ZETA_LOC), r), mulmod( addmod(1, sub(r, mload(W_SEL_POLY_EVAL_ZETA_2_LOC)), r), addmod(1, mload(W_SEL_POLY_EVAL_ZETA_2_LOC), r), r ), r ) res := addmod(res, sub(r, term10), r) } mstore(R_EVAL_ZETA_LOC, res) } // 5. derive the linearization polynomial commitment. { let w0 := mload(W_POLY_EVAL_ZETA_0_LOC) let w1 := mload(W_POLY_EVAL_ZETA_1_LOC) let w2 := mload(W_POLY_EVAL_ZETA_2_LOC) let w3 := mload(W_POLY_EVAL_ZETA_3_LOC) let wo := mload(W_POLY_EVAL_ZETA_4_LOC) scalarMul(mload(CM_Q0_X_LOC), mload(CM_Q0_Y_LOC), w0) let r_commitment_x := mload(mload(0x40)) let r_commitment_y := mload(add(mload(0x40), 0x20)) { scalarMul(mload(CM_Q1_X_LOC), mload(CM_Q1_Y_LOC), w1) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_Q2_X_LOC), mload(CM_Q2_Y_LOC), w2) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_Q3_X_LOC), mload(CM_Q3_Y_LOC), w3) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) let w0w1 := mulmod(w0, w1, r) scalarMul(mload(CM_Q4_X_LOC), mload(CM_Q4_Y_LOC), w0w1) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) let w2w3 := mulmod(w2, w3, r) scalarMul(mload(CM_Q5_X_LOC), mload(CM_Q5_Y_LOC), w2w3) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) pointAdd(r_commitment_x, r_commitment_y, mload(CM_Q6_X_LOC), mload(CM_Q6_Y_LOC)) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_Q7_X_LOC), mload(CM_Q7_Y_LOC), sub(r, wo)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } { let gamma := mload(GAMMA_LOC) let beta_zeta := mulmod(mload(BETA_LOC), mload(ZETA_LOC), r) let tmp := addmod(w0, addmod(gamma, mulmod(mload(K_0_LOC), beta_zeta, r), r), r) let z_scalar := mulmod(tmp, mload(ALPHA_LOC), r) tmp := addmod(w1, addmod(gamma, mulmod(mload(K_1_LOC), beta_zeta, r), r), r) z_scalar := mulmod(tmp, z_scalar, r) tmp := addmod(w2, addmod(gamma, mulmod(mload(K_2_LOC), beta_zeta, r), r), r) z_scalar := mulmod(tmp, z_scalar, r) tmp := addmod(w3, addmod(gamma, mulmod(mload(K_3_LOC), beta_zeta, r), r), r) z_scalar := mulmod(tmp, z_scalar, r) tmp := addmod(wo, addmod(gamma, mulmod(mload(K_4_LOC), beta_zeta, r), r), r) z_scalar := mulmod(tmp, z_scalar, r) z_scalar := addmod( mulmod(mload(FIRST_LAGRANGE_EVAL_ZETA_LOC), mload(ALPHA_POW_2_LOC), r), z_scalar, r ) scalarMul(mload(CM_Z_X_LOC), mload(CM_Z_Y_LOC), z_scalar) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } { let beta := mload(BETA_LOC) let gamma := mload(GAMMA_LOC) let s_last_poly_scalar := mulmod(mload(ALPHA_LOC), mulmod(mload(Z_EVAL_ZETA_OMEGA_LOC), beta, r), r) let tmp := addmod(w0, addmod(gamma, mulmod(beta, mload(S_POLY_EVAL_ZETA_0_LOC), r), r), r) s_last_poly_scalar := mulmod(s_last_poly_scalar, tmp, r) tmp := addmod(w1, addmod(gamma, mulmod(beta, mload(S_POLY_EVAL_ZETA_1_LOC), r), r), r) s_last_poly_scalar := mulmod(s_last_poly_scalar, tmp, r) tmp := addmod(w2, addmod(gamma, mulmod(beta, mload(S_POLY_EVAL_ZETA_2_LOC), r), r), r) s_last_poly_scalar := mulmod(s_last_poly_scalar, tmp, r) tmp := addmod(w3, addmod(gamma, mulmod(beta, mload(S_POLY_EVAL_ZETA_3_LOC), r), r), r) s_last_poly_scalar := mulmod(s_last_poly_scalar, tmp, r) scalarMul(mload(CM_S4_X_LOC), mload(CM_S4_Y_LOC), sub(r, s_last_poly_scalar)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } { let w1_part := mulmod(w1, mulmod(mload(ALPHA_POW_3_LOC), addmod(w1, sub(r, 1), r), r), r) let w2_part := mulmod(w2, mulmod(mload(ALPHA_POW_4_LOC), addmod(w2, sub(r, 1), r), r), r) let w3_part := mulmod(w3, mulmod(mload(ALPHA_POW_5_LOC), addmod(w3, sub(r, 1), r), r), r) let w_part := addmod(w1_part, addmod(w2_part, w3_part, r), r) scalarMul(mload(CM_QB_X_LOC), mload(CM_QB_Y_LOC), w_part) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } { let q_prk3_0 := mulmod(mload(PRK_3_EVAL_ZETA_LOC), mload(ALPHA_POW_6_LOC), r) let q_prk3_1 := mulmod(mload(PRK_3_EVAL_ZETA_LOC), mload(ALPHA_POW_7_LOC), r) scalarMul(mload(CM_PRK_0_X_LOC), mload(CM_PRK_0_Y_LOC), q_prk3_0) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_PRK_1_X_LOC), mload(CM_PRK_1_Y_LOC), q_prk3_1) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } { let factor := powSmall(mload(ZETA_LOC), add(mload(CS_SIZE_LOC), 2)) let exponent_0 := mulmod(mload(Z_H_EVAL_ZETA_LOC), factor, r) let exponent_1 := mulmod(exponent_0, factor, r) let exponent_2 := mulmod(exponent_1, factor, r) let exponent_3 := mulmod(exponent_2, factor, r) scalarMul(mload(CM_T0_X_LOC), mload(CM_T0_Y_LOC), sub(r, mload(Z_H_EVAL_ZETA_LOC))) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_T1_X_LOC), mload(CM_T1_Y_LOC), sub(r, exponent_0)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_T2_X_LOC), mload(CM_T2_Y_LOC), sub(r, exponent_1)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_T3_X_LOC), mload(CM_T3_Y_LOC), sub(r, exponent_2)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(CM_T4_X_LOC), mload(CM_T4_Y_LOC), sub(r, exponent_3)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { let tmp_scalar_0 := mulmod( mulmod(mload(W_POLY_EVAL_ZETA_0_LOC), mload(W_POLY_EVAL_ZETA_1_LOC), r), mload(W_POLY_EVAL_ZETA_OMEGA_0_LOC), r ) scalarMul(mload(CM_SHUFFLE_PUBLIC_KEY_8_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_8_Y_LOC), tmp_scalar_0) let commitment_x := mload(mload(0x40)) let commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_1 := sub( r, mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_0_LOC), r) ) scalarMul(mload(CM_SHUFFLE_PUBLIC_KEY_4_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_4_Y_LOC), tmp_scalar_1) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_0_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_0_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_1_LOC)) ) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(commitment_x, commitment_y, mload(SEL_00_LOC)) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_9_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_9_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_5_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_5_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_1_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_1_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_1_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_01_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_10_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_10_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_6_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_6_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_2_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_2_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_1_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_10_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_11_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_11_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_7_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_7_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_3_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_3_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_1_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_11_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } scalarMul(commitment_x, commitment_y, mload(ALPHA_POW_10_LOC)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { let tmp_scalar_0 := mulmod( mulmod(sub(r, mload(W_POLY_EVAL_ZETA_0_LOC)), mload(W_POLY_EVAL_ZETA_1_LOC), r), mload(W_POLY_EVAL_ZETA_OMEGA_1_LOC), r ) scalarMul(mload(CM_SHUFFLE_PUBLIC_KEY_8_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_8_Y_LOC), tmp_scalar_0) let commitment_x := mload(mload(0x40)) let commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_1 := mulmod(mload(W_POLY_EVAL_ZETA_0_LOC), mload(EDWARDS_A_LOC), r) scalarMul(mload(CM_SHUFFLE_PUBLIC_KEY_0_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_0_Y_LOC), tmp_scalar_1) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_2 := sub( r, mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_1_LOC), r) ) scalarMul(mload(CM_SHUFFLE_PUBLIC_KEY_4_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_4_Y_LOC), tmp_scalar_2) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(commitment_x, commitment_y, mload(SEL_00_LOC)) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_9_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_9_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_1_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_1_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_5_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_5_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_01_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_10_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_10_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_2_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_2_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_6_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_6_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_10_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_11_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_11_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_3_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_3_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_PUBLIC_KEY_7_X_LOC), mload(CM_SHUFFLE_PUBLIC_KEY_7_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_11_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } scalarMul(commitment_x, commitment_y, mload(ALPHA_POW_11_LOC)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { let tmp_scalar_0 := mulmod( mulmod(mload(W_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_3_LOC), r), mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC), r ) scalarMul(mload(CM_SHUFFLE_GENERATOR_8_X_LOC), mload(CM_SHUFFLE_GENERATOR_8_Y_LOC), tmp_scalar_0) let commitment_x := mload(mload(0x40)) let commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_1 := sub( r, mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_2_LOC), r) ) scalarMul(mload(CM_SHUFFLE_GENERATOR_4_X_LOC), mload(CM_SHUFFLE_GENERATOR_4_Y_LOC), tmp_scalar_1) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_0_X_LOC), mload(CM_SHUFFLE_GENERATOR_0_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_3_LOC)) ) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(commitment_x, commitment_y, mload(SEL_00_LOC)) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) { scalarMul( mload(CM_SHUFFLE_GENERATOR_9_X_LOC), mload(CM_SHUFFLE_GENERATOR_9_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_5_X_LOC), mload(CM_SHUFFLE_GENERATOR_5_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_1_X_LOC), mload(CM_SHUFFLE_GENERATOR_1_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_3_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_01_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_GENERATOR_10_X_LOC), mload(CM_SHUFFLE_GENERATOR_10_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_6_X_LOC), mload(CM_SHUFFLE_GENERATOR_6_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_2_X_LOC), mload(CM_SHUFFLE_GENERATOR_2_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_3_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_10_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_GENERATOR_11_X_LOC), mload(CM_SHUFFLE_GENERATOR_11_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_7_X_LOC), mload(CM_SHUFFLE_GENERATOR_7_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_3_X_LOC), mload(CM_SHUFFLE_GENERATOR_3_Y_LOC), sub(r, mload(W_POLY_EVAL_ZETA_3_LOC)) ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_11_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } scalarMul(commitment_x, commitment_y, mload(ALPHA_POW_12_LOC)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { let tmp_scalar_0 := mulmod( mulmod(sub(r, mload(W_POLY_EVAL_ZETA_2_LOC)), mload(W_POLY_EVAL_ZETA_3_LOC), r), mload(W_POLY_EVAL_ZETA_4_LOC), r ) scalarMul(mload(CM_SHUFFLE_GENERATOR_8_X_LOC), mload(CM_SHUFFLE_GENERATOR_8_Y_LOC), tmp_scalar_0) let commitment_x := mload(mload(0x40)) let commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_1 := mulmod(mload(W_POLY_EVAL_ZETA_2_LOC), mload(EDWARDS_A_LOC), r) scalarMul(mload(CM_SHUFFLE_GENERATOR_0_X_LOC), mload(CM_SHUFFLE_GENERATOR_0_Y_LOC), tmp_scalar_1) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) let tmp_scalar_2 := sub( r, mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), mload(W_POLY_EVAL_ZETA_3_LOC), r) ) scalarMul(mload(CM_SHUFFLE_GENERATOR_4_X_LOC), mload(CM_SHUFFLE_GENERATOR_4_Y_LOC), tmp_scalar_2) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(commitment_x, commitment_y, mload(SEL_00_LOC)) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) { scalarMul( mload(CM_SHUFFLE_GENERATOR_9_X_LOC), mload(CM_SHUFFLE_GENERATOR_9_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_1_X_LOC), mload(CM_SHUFFLE_GENERATOR_1_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_5_X_LOC), mload(CM_SHUFFLE_GENERATOR_5_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_01_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_GENERATOR_10_X_LOC), mload(CM_SHUFFLE_GENERATOR_10_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_2_X_LOC), mload(CM_SHUFFLE_GENERATOR_2_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_6_X_LOC), mload(CM_SHUFFLE_GENERATOR_6_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_10_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { scalarMul( mload(CM_SHUFFLE_GENERATOR_11_X_LOC), mload(CM_SHUFFLE_GENERATOR_11_Y_LOC), tmp_scalar_0 ) let tmp_commitment_x := mload(mload(0x40)) let tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_3_X_LOC), mload(CM_SHUFFLE_GENERATOR_3_Y_LOC), tmp_scalar_1 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul( mload(CM_SHUFFLE_GENERATOR_7_X_LOC), mload(CM_SHUFFLE_GENERATOR_7_Y_LOC), tmp_scalar_2 ) pointAddInMemory(tmp_commitment_x, tmp_commitment_y) tmp_commitment_x := mload(mload(0x40)) tmp_commitment_y := mload(add(mload(0x40), 0x20)) scalarMul(tmp_commitment_x, tmp_commitment_y, mload(SEL_11_LOC)) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } scalarMul(commitment_x, commitment_y, mload(ALPHA_POW_13_LOC)) pointAddInMemory(r_commitment_x, r_commitment_y) r_commitment_x := mload(mload(0x40)) r_commitment_y := mload(add(mload(0x40), 0x20)) } mstore(R_COMMITMENT_X_LOC, r_commitment_x) mstore(R_COMMITMENT_Y_LOC, r_commitment_y) } // 6. Combine multiple commitments(opening in zeta) into one commitment. { let commitment_x := mload(CM_W0_X_LOC) let commitment_y := mload(CM_W0_Y_LOC) let multiplier := 1 let eval_combined := mload(W_POLY_EVAL_ZETA_0_LOC) let alpha := mload(ALPHA_BATCH_12_LOC) { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_1_LOC), multiplier, r), r) scalarMul(mload(CM_W1_X_LOC), mload(CM_W1_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_2_LOC), multiplier, r), r) scalarMul(mload(CM_W2_X_LOC), mload(CM_W2_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_3_LOC), multiplier, r), r) scalarMul(mload(CM_W3_X_LOC), mload(CM_W3_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_4_LOC), multiplier, r), r) scalarMul(mload(CM_W4_X_LOC), mload(CM_W4_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(S_POLY_EVAL_ZETA_0_LOC), multiplier, r), r) scalarMul(mload(CM_S0_X_LOC), mload(CM_S0_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(S_POLY_EVAL_ZETA_1_LOC), multiplier, r), r) scalarMul(mload(CM_S1_X_LOC), mload(CM_S1_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(S_POLY_EVAL_ZETA_2_LOC), multiplier, r), r) scalarMul(mload(CM_S2_X_LOC), mload(CM_S2_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(S_POLY_EVAL_ZETA_3_LOC), multiplier, r), r) scalarMul(mload(CM_S3_X_LOC), mload(CM_S3_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(PRK_3_EVAL_ZETA_LOC), multiplier, r), r) scalarMul(mload(CM_PRK_2_X_LOC), mload(CM_PRK_2_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(PRK_4_EVAL_ZETA_LOC), multiplier, r), r) scalarMul(mload(CM_PRK_3_X_LOC), mload(CM_PRK_3_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(Q_ECC_POLY_EVAL_ZETA_LOC), multiplier, r), r) scalarMul(mload(CM_Q_ECC_X_LOC), mload(CM_Q_ECC_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_SEL_POLY_EVAL_ZETA_0_LOC), multiplier, r), r) scalarMul(mload(CM_W0_SEL_X_LOC), mload(CM_W0_SEL_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_SEL_POLY_EVAL_ZETA_1_LOC), multiplier, r), r) scalarMul(mload(CM_W1_SEL_X_LOC), mload(CM_W1_SEL_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } if shuffle_specified { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_SEL_POLY_EVAL_ZETA_2_LOC), multiplier, r), r) scalarMul(mload(CM_W2_SEL_X_LOC), mload(CM_W2_SEL_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } { multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(R_EVAL_ZETA_LOC), multiplier, r), r) scalarMul(mload(R_COMMITMENT_X_LOC), mload(R_COMMITMENT_Y_LOC), multiplier) pointAddInMemory(commitment_x, commitment_y) commitment_x := mload(mload(0x40)) commitment_y := mload(add(mload(0x40), 0x20)) } mstore(COMMITMENT_X_LOC, commitment_x) mstore(COMMITMENT_Y_LOC, commitment_y) mstore(VALUE_LOC, eval_combined) } // 7. Combine multiple commitments(opening in zeta omega) into one commitment. { let batc_commitment_x := mload(CM_Z_X_LOC) let batc_commitment_y := mload(CM_Z_Y_LOC) let alpha := mload(ALPHA_BATCH_4_LOC) let multiplier := alpha let eval_combined := addmod( mload(Z_EVAL_ZETA_OMEGA_LOC), mulmod(mload(W_POLY_EVAL_ZETA_OMEGA_0_LOC), multiplier, r), r ) scalarMul(mload(CM_W0_X_LOC), mload(CM_W0_Y_LOC), multiplier) pointAddInMemory(batc_commitment_x, batc_commitment_y) batc_commitment_x := mload(mload(0x40)) batc_commitment_y := mload(add(mload(0x40), 0x20)) multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_OMEGA_1_LOC), multiplier, r), r) scalarMul(mload(CM_W1_X_LOC), mload(CM_W1_Y_LOC), multiplier) pointAddInMemory(batc_commitment_x, batc_commitment_y) batc_commitment_x := mload(mload(0x40)) batc_commitment_y := mload(add(mload(0x40), 0x20)) multiplier := mulmod(multiplier, alpha, r) eval_combined := addmod(eval_combined, mulmod(mload(W_POLY_EVAL_ZETA_OMEGA_2_LOC), multiplier, r), r) scalarMul(mload(CM_W2_X_LOC), mload(CM_W2_Y_LOC), multiplier) pointAddInMemory(batc_commitment_x, batc_commitment_y) batc_commitment_x := mload(mload(0x40)) batc_commitment_y := mload(add(mload(0x40), 0x20)) mstore(BATCH_COMMITMENT_X_LOC, batc_commitment_x) mstore(BATCH_COMMITMENT_Y_LOC, batc_commitment_y) mstore(BATCH_VALUE_LOC, eval_combined) } // 8. batch verify proofs with different points. { scalarMul(mload(OPENING_ZETA_X_LOC), mload(OPENING_ZETA_Y_LOC), mload(ZETA_LOC)) let p0_zeta_x := mload(mload(0x40)) let p0_zeta_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(OPENING_ZETA_OMEGA_X_LOC), mload(OPENING_ZETA_OMEGA_Y_LOC), mload(U_LOC)) let p1_u_x := mload(mload(0x40)) let p1_u_y := mload(add(mload(0x40), 0x20)) scalarMul(p1_u_x, p1_u_y, mulmod(mload(ROOT_LOC), mload(ZETA_LOC), r)) let p1_u_zata_omega_x := mload(mload(0x40)) let p1_u_zata_omega_y := mload(add(mload(0x40), 0x20)) pointAdd(mload(OPENING_ZETA_X_LOC), mload(OPENING_ZETA_Y_LOC), p1_u_x, p1_u_y) let left_first_x := mload(mload(0x40)) let left_first_y := mload(add(mload(0x40), 0x20)) pointAdd(p0_zeta_x, p0_zeta_y, p1_u_zata_omega_x, p1_u_zata_omega_y) let right_first_x := mload(mload(0x40)) let right_first_y := mload(add(mload(0x40), 0x20)) scalarMul(mload(BATCH_COMMITMENT_X_LOC), mload(BATCH_COMMITMENT_Y_LOC), mload(U_LOC)) pointAddInMemory(mload(COMMITMENT_X_LOC), mload(COMMITMENT_Y_LOC)) let right_first_comm_x := mload(mload(0x40)) let right_first_comm_y := mload(add(mload(0x40), 0x20)) scalarMul(1, 2, sub(r, addmod(mload(VALUE_LOC), mulmod(mload(BATCH_VALUE_LOC), mload(U_LOC), r), r))) pointAddInMemory(right_first_x, right_first_y) right_first_x := mload(mload(0x40)) right_first_y := mload(add(mload(0x40), 0x20)) pointAdd(right_first_x, right_first_y, right_first_comm_x, right_first_comm_y) right_first_x := mload(mload(0x40)) right_first_y := mload(add(mload(0x40), 0x20)) mstore(mload(0x40), left_first_x) mstore(add(mload(0x40), 0x20), left_first_y) mstore(add(mload(0x40), 0x40), 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1) mstore(add(mload(0x40), 0x60), 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0) mstore(add(mload(0x40), 0x80), 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4) mstore(add(mload(0x40), 0xa0), 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55) mstore(add(mload(0x40), 0xc0), right_first_x) mstore( add(mload(0x40), 0xe0), sub(21888242871839275222246405745257275088696311157297823662689037894645226208583, right_first_y) ) mstore(add(mload(0x40), 0x100), 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2) mstore(add(mload(0x40), 0x120), 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed) mstore(add(mload(0x40), 0x140), 0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b) mstore(add(mload(0x40), 0x160), 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa) let success_flag := staticcall(gas(), 8, mload(0x40), 0x180, mload(0x40), 0x20) let is_success := and(mload(mload(SUCCESS_LOC)), success_flag) if iszero(is_success) { revert(0x00, 0x00) } return(mload(0x40), 0x20) } } } }
{ "metadata": { "bytecodeHash": "none" }, "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040518060400160405280600a8152602001691e9058d948141bda5b9d60b21b81525060405180604001604052806002815260200161041560f41b81525081600390816200006191906200023e565b5060046200007082826200023e565b505050620000ae7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6620000a8620000e260201b60201c565b620000e6565b50620000db7f0af0c3ebe77999ca20698e1ff25f812bf82409a59d21ca15a41f39e0ce9f250033620000e6565b506200030a565b3390565b60008281526005602090815260408083206001600160a01b038516845290915281205460ff166200018f5760008381526005602090815260408083206001600160a01b03861684529091529020805460ff19166001179055620001463390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600162000193565b5060005b92915050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001c457607f821691505b602082108103620001e557634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200023957600081815260208120601f850160051c81016020861015620002145750805b601f850160051c820191505b81811015620002355782815560010162000220565b5050505b505050565b81516001600160401b038111156200025a576200025a62000199565b62000272816200026b8454620001af565b84620001eb565b602080601f831160018114620002aa5760008415620002915750858301515b600019600386901b1c1916600185901b17855562000235565b600085815260208120601f198616915b82811015620002db57888601518255948401946001909101908401620002ba565b5085821015620002fa5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610cf3806200031a6000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806342966c68116100c3578063a217fddf1161007c578063a217fddf146102c6578063a9059cbb146102ce578063d5391393146102e1578063d547741f146102f6578063dd62ed3e14610309578063f80f5dd51461034257600080fd5b806342966c681461024957806370a082311461025c57806379cc67901461028557806391d148541461029857806395d89b41146102ab578063983b2d56146102b357600080fd5b806323b872dd1161011557806323b872dd146101c9578063248a9ca3146101dc5780632f2ff15d146101ff578063313ce5671461021457806336568abe1461022357806340c10f191461023657600080fd5b806301ffc9a71461015257806306fdde031461017a578063095ea7b31461018f57806318160ddd146101a25780631bb7cc99146101b4575b600080fd5b610165610160366004610ac0565b610355565b60405190151581526020015b60405180910390f35b61018261038c565b6040516101719190610af1565b61016561019d366004610b5b565b61041e565b6002545b604051908152602001610171565b6101a6600080516020610cc783398151915281565b6101656101d7366004610b85565b610436565b6101a66101ea366004610bc1565b60009081526005602052604090206001015490565b61021261020d366004610bda565b610464565b005b60405160128152602001610171565b610212610231366004610bda565b61048f565b610212610244366004610b5b565b6104c7565b610212610257366004610bc1565b6104e9565b6101a661026a366004610c06565b6001600160a01b031660009081526020819052604090205490565b610212610293366004610b5b565b6104f6565b6101656102a6366004610bda565b61050f565b61018261053a565b6102126102c1366004610c06565b610549565b6101a6600081565b6101656102dc366004610b5b565b610579565b6101a6600080516020610ca783398151915281565b610212610304366004610bda565b6105a5565b6101a6610317366004610c21565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610212610350366004610c06565b6105ca565b60006001600160e01b03198216637965db0b60e01b148061038657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606003805461039b90610c4b565b80601f01602080910402602001604051908101604052809291908181526020018280546103c790610c4b565b80156104145780601f106103e957610100808354040283529160200191610414565b820191906000526020600020905b8154815290600101906020018083116103f757829003601f168201915b5050505050905090565b60003361042c8185856105fa565b5060019392505050565b6000600080516020610cc783398151915261045081610607565b61045b858585610611565b95945050505050565b60008281526005602052604090206001015461047f81610607565b6104898383610635565b50505050565b6001600160a01b03811633146104b85760405163334bd91960e11b815260040160405180910390fd5b6104c282826106c9565b505050565b600080516020610ca78339815191526104df81610607565b6104c28383610736565b6104f33382610771565b50565b6105018233836107a7565b61050b8282610771565b5050565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606004805461039b90610c4b565b600080516020610ca783398151915261056181610607565b6104c2600080516020610ca783398151915283610635565b6000600080516020610cc783398151915261059381610607565b61059d848461081f565b949350505050565b6000828152600560205260409020600101546105c081610607565b61048983836106c9565b600080516020610ca78339815191526105e281610607565b6104c2600080516020610cc783398151915283610635565b6104c2838383600161082d565b6104f38133610902565b60003361061f8582856107a7565b61062a85858561093b565b506001949350505050565b6000610641838361050f565b6106c15760008381526005602090815260408083206001600160a01b03861684529091529020805460ff191660011790556106793390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610386565b506000610386565b60006106d5838361050f565b156106c15760008381526005602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610386565b6001600160a01b0382166107655760405163ec442f0560e01b8152600060048201526024015b60405180910390fd5b61050b60008383610996565b6001600160a01b03821661079b57604051634b637e8f60e11b81526000600482015260240161075c565b61050b82600083610996565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610489578181101561081057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161075c565b6104898484848403600061082d565b60003361042c81858561093b565b6001600160a01b0384166108575760405163e602df0560e01b81526000600482015260240161075c565b6001600160a01b03831661088157604051634a1406b160e11b81526000600482015260240161075c565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561048957826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108f491815260200190565b60405180910390a350505050565b61090c828261050f565b61050b5760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161075c565b6001600160a01b03831661096557604051634b637e8f60e11b81526000600482015260240161075c565b6001600160a01b03821661098f5760405163ec442f0560e01b81526000600482015260240161075c565b6104c28383835b6001600160a01b0383166109c15780600260008282546109b69190610c85565b90915550610a339050565b6001600160a01b03831660009081526020819052604090205481811015610a145760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161075c565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b038216610a4f57600280548290039055610a6e565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ab391815260200190565b60405180910390a3505050565b600060208284031215610ad257600080fd5b81356001600160e01b031981168114610aea57600080fd5b9392505050565b600060208083528351808285015260005b81811015610b1e57858101830151858201604001528201610b02565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610b5657600080fd5b919050565b60008060408385031215610b6e57600080fd5b610b7783610b3f565b946020939093013593505050565b600080600060608486031215610b9a57600080fd5b610ba384610b3f565b9250610bb160208501610b3f565b9150604084013590509250925092565b600060208284031215610bd357600080fd5b5035919050565b60008060408385031215610bed57600080fd5b82359150610bfd60208401610b3f565b90509250929050565b600060208284031215610c1857600080fd5b610aea82610b3f565b60008060408385031215610c3457600080fd5b610c3d83610b3f565b9150610bfd60208401610b3f565b600181811c90821680610c5f57607f821691505b602082108103610c7f57634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561038657634e487b7160e01b600052601160045260246000fdfe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a60af0c3ebe77999ca20698e1ff25f812bf82409a59d21ca15a41f39e0ce9f2500a164736f6c6343000814000a
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806342966c68116100c3578063a217fddf1161007c578063a217fddf146102c6578063a9059cbb146102ce578063d5391393146102e1578063d547741f146102f6578063dd62ed3e14610309578063f80f5dd51461034257600080fd5b806342966c681461024957806370a082311461025c57806379cc67901461028557806391d148541461029857806395d89b41146102ab578063983b2d56146102b357600080fd5b806323b872dd1161011557806323b872dd146101c9578063248a9ca3146101dc5780632f2ff15d146101ff578063313ce5671461021457806336568abe1461022357806340c10f191461023657600080fd5b806301ffc9a71461015257806306fdde031461017a578063095ea7b31461018f57806318160ddd146101a25780631bb7cc99146101b4575b600080fd5b610165610160366004610ac0565b610355565b60405190151581526020015b60405180910390f35b61018261038c565b6040516101719190610af1565b61016561019d366004610b5b565b61041e565b6002545b604051908152602001610171565b6101a6600080516020610cc783398151915281565b6101656101d7366004610b85565b610436565b6101a66101ea366004610bc1565b60009081526005602052604090206001015490565b61021261020d366004610bda565b610464565b005b60405160128152602001610171565b610212610231366004610bda565b61048f565b610212610244366004610b5b565b6104c7565b610212610257366004610bc1565b6104e9565b6101a661026a366004610c06565b6001600160a01b031660009081526020819052604090205490565b610212610293366004610b5b565b6104f6565b6101656102a6366004610bda565b61050f565b61018261053a565b6102126102c1366004610c06565b610549565b6101a6600081565b6101656102dc366004610b5b565b610579565b6101a6600080516020610ca783398151915281565b610212610304366004610bda565b6105a5565b6101a6610317366004610c21565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610212610350366004610c06565b6105ca565b60006001600160e01b03198216637965db0b60e01b148061038657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606003805461039b90610c4b565b80601f01602080910402602001604051908101604052809291908181526020018280546103c790610c4b565b80156104145780601f106103e957610100808354040283529160200191610414565b820191906000526020600020905b8154815290600101906020018083116103f757829003601f168201915b5050505050905090565b60003361042c8185856105fa565b5060019392505050565b6000600080516020610cc783398151915261045081610607565b61045b858585610611565b95945050505050565b60008281526005602052604090206001015461047f81610607565b6104898383610635565b50505050565b6001600160a01b03811633146104b85760405163334bd91960e11b815260040160405180910390fd5b6104c282826106c9565b505050565b600080516020610ca78339815191526104df81610607565b6104c28383610736565b6104f33382610771565b50565b6105018233836107a7565b61050b8282610771565b5050565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606004805461039b90610c4b565b600080516020610ca783398151915261056181610607565b6104c2600080516020610ca783398151915283610635565b6000600080516020610cc783398151915261059381610607565b61059d848461081f565b949350505050565b6000828152600560205260409020600101546105c081610607565b61048983836106c9565b600080516020610ca78339815191526105e281610607565b6104c2600080516020610cc783398151915283610635565b6104c2838383600161082d565b6104f38133610902565b60003361061f8582856107a7565b61062a85858561093b565b506001949350505050565b6000610641838361050f565b6106c15760008381526005602090815260408083206001600160a01b03861684529091529020805460ff191660011790556106793390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610386565b506000610386565b60006106d5838361050f565b156106c15760008381526005602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610386565b6001600160a01b0382166107655760405163ec442f0560e01b8152600060048201526024015b60405180910390fd5b61050b60008383610996565b6001600160a01b03821661079b57604051634b637e8f60e11b81526000600482015260240161075c565b61050b82600083610996565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610489578181101561081057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161075c565b6104898484848403600061082d565b60003361042c81858561093b565b6001600160a01b0384166108575760405163e602df0560e01b81526000600482015260240161075c565b6001600160a01b03831661088157604051634a1406b160e11b81526000600482015260240161075c565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561048957826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108f491815260200190565b60405180910390a350505050565b61090c828261050f565b61050b5760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161075c565b6001600160a01b03831661096557604051634b637e8f60e11b81526000600482015260240161075c565b6001600160a01b03821661098f5760405163ec442f0560e01b81526000600482015260240161075c565b6104c28383835b6001600160a01b0383166109c15780600260008282546109b69190610c85565b90915550610a339050565b6001600160a01b03831660009081526020819052604090205481811015610a145760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161075c565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b038216610a4f57600280548290039055610a6e565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ab391815260200190565b60405180910390a3505050565b600060208284031215610ad257600080fd5b81356001600160e01b031981168114610aea57600080fd5b9392505050565b600060208083528351808285015260005b81811015610b1e57858101830151858201604001528201610b02565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610b5657600080fd5b919050565b60008060408385031215610b6e57600080fd5b610b7783610b3f565b946020939093013593505050565b600080600060608486031215610b9a57600080fd5b610ba384610b3f565b9250610bb160208501610b3f565b9150604084013590509250925092565b600060208284031215610bd357600080fd5b5035919050565b60008060408385031215610bed57600080fd5b82359150610bfd60208401610b3f565b90509250929050565b600060208284031215610c1857600080fd5b610aea82610b3f565b60008060408385031215610c3457600080fd5b610c3d83610b3f565b9150610bfd60208401610b3f565b600181811c90821680610c5f57607f821691505b602082108103610c7f57634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561038657634e487b7160e01b600052601160045260246000fdfe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a60af0c3ebe77999ca20698e1ff25f812bf82409a59d21ca15a41f39e0ce9f2500a164736f6c6343000814000a
Deployed Bytecode Sourcemap
326:1103:40:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2565:202:9;;;;;;:::i;:::-;;:::i;:::-;;;470:14:98;;463:22;445:41;;433:2;418:18;2565:202:9;;;;;;;;2074:89:16;;;:::i;:::-;;;;;;;:::i;4293:186::-;;;;;;:::i;:::-;;:::i;3144:97::-;3222:12;;3144:97;;;1633:25:98;;;1621:2;1606:18;3144:97:16;1487:177:98;460:58:40;;-1:-1:-1;;;;;;;;;;;460:58:40;;843:203;;;;;;:::i;:::-;;:::i;3810:120:9:-;;;;;;:::i;:::-;3875:7;3901:12;;;:6;:12;;;;;:22;;;;3810:120;4226:136;;;;;;:::i;:::-;;:::i;:::-;;3002:82:16;;;3075:2;2770:36:98;;2758:2;2743:18;3002:82:16;2628:184:98;5328:245:9;;;;;;:::i;:::-;;:::i;1052:134:40:-;;;;;;:::i;:::-;;:::i;618:87:18:-;;;;;;:::i;:::-;;:::i;3299:116:16:-;;;;;;:::i;:::-;-1:-1:-1;;;;;3390:18:16;3364:7;3390:18;;;;;;;;;;;;3299:116;1021:158:18;;;;;;:::i;:::-;;:::i;2854:136:9:-;;;;;;:::i;:::-;;:::i;2276:93:16:-;;;:::i;1192:114:40:-;;;;;;:::i;:::-;;:::i;2187:49:9:-;;2232:4;2187:49;;670:167:40;;;;;;:::i;:::-;;:::i;392:62::-;;-1:-1:-1;;;;;;;;;;;392:62:40;;4642:138:9;;;;;;:::i;:::-;;:::i;3846:140:16:-;;;;;;:::i;:::-;-1:-1:-1;;;;;3952:18:16;;;3926:7;3952:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3846:140;1312:115:40;;;;;;:::i;:::-;;:::i;2565:202:9:-;2650:4;-1:-1:-1;;;;;;2673:47:9;;-1:-1:-1;;;2673:47:9;;:87;;-1:-1:-1;;;;;;;;;;861:40:29;;;2724:36:9;2666:94;2565:202;-1:-1:-1;;2565:202:9:o;2074:89:16:-;2119:13;2151:5;2144:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2074:89;:::o;4293:186::-;4366:4;735:10:23;4420:31:16;735:10:23;4436:7:16;4445:5;4420:8;:31::i;:::-;-1:-1:-1;4468:4:16;;4293:186;-1:-1:-1;;;4293:186:16:o;843:203:40:-;981:4;-1:-1:-1;;;;;;;;;;;2464:16:9;2475:4;2464:10;:16::i;:::-;1004:35:40::1;1023:4;1029:2;1033:5;1004:18;:35::i;:::-;997:42:::0;843:203;-1:-1:-1;;;;;843:203:40:o;4226:136:9:-;3875:7;3901:12;;;:6;:12;;;;;:22;;;2464:16;2475:4;2464:10;:16::i;:::-;4330:25:::1;4341:4;4347:7;4330:10;:25::i;:::-;;4226:136:::0;;;:::o;5328:245::-;-1:-1:-1;;;;;5421:34:9;;735:10:23;5421:34:9;5417:102;;5478:30;;-1:-1:-1;;;5478:30:9;;;;;;;;;;;5417:102;5529:37;5541:4;5547:18;5529:11;:37::i;:::-;;5328:245;;:::o;1052:134:40:-;-1:-1:-1;;;;;;;;;;;2464:16:9;2475:4;2464:10;:16::i;:::-;1163::40::1;1169:2;1173:5;1163;:16::i;618:87:18:-:0;672:26;735:10:23;692:5:18;672;:26::i;:::-;618:87;:::o;1021:158::-;1096:45;1112:7;735:10:23;1135:5:18;1096:15;:45::i;:::-;1151:21;1157:7;1166:5;1151;:21::i;:::-;1021:158;;:::o;2854:136:9:-;2931:4;2954:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;2954:29:9;;;;;;;;;;;;;;;2854:136::o;2276:93:16:-;2323:13;2355:7;2348:14;;;;;:::i;1192:114:40:-;-1:-1:-1;;;;;;;;;;;2464:16:9;2475:4;2464:10;:16::i;:::-;1267:32:40::1;-1:-1:-1::0;;;;;;;;;;;1291:7:40::1;1267:10;:32::i;670:167::-:0;782:4;-1:-1:-1;;;;;;;;;;;2464:16:9;2475:4;2464:10;:16::i;:::-;805:25:40::1;820:2;824:5;805:14;:25::i;:::-;798:32:::0;670:167;-1:-1:-1;;;;670:167:40:o;4642:138:9:-;3875:7;3901:12;;;:6;:12;;;;;:22;;;2464:16;2475:4;2464:10;:16::i;:::-;4747:26:::1;4759:4;4765:7;4747:11;:26::i;1312:115:40:-:0;-1:-1:-1;;;;;;;;;;;2464:16:9;2475:4;2464:10;:16::i;:::-;1390:30:40::1;-1:-1:-1::0;;;;;;;;;;;1412:7:40::1;1390:10;:30::i;8989:128:16:-:0;9073:37;9082:5;9089:7;9098:5;9105:4;9073:8;:37::i;3199:103:9:-;3265:30;3276:4;735:10:23;3265::9;:30::i;5039:244:16:-;5126:4;735:10:23;5182:37:16;5198:4;735:10:23;5213:5:16;5182:15;:37::i;:::-;5229:26;5239:4;5245:2;5249:5;5229:9;:26::i;:::-;-1:-1:-1;5272:4:16;;5039:244;-1:-1:-1;;;;5039:244:16:o;6179:316:9:-;6256:4;6277:22;6285:4;6291:7;6277;:22::i;:::-;6272:217;;6315:12;;;;:6;:12;;;;;;;;-1:-1:-1;;;;;6315:29:9;;;;;;;;;:36;;-1:-1:-1;;6315:36:9;6347:4;6315:36;;;6397:12;735:10:23;;656:96;6397:12:9;-1:-1:-1;;;;;6370:40:9;6388:7;-1:-1:-1;;;;;6370:40:9;6382:4;6370:40;;;;;;;;;;-1:-1:-1;6431:4:9;6424:11;;6272:217;-1:-1:-1;6473:5:9;6466:12;;6730:317;6808:4;6828:22;6836:4;6842:7;6828;:22::i;:::-;6824:217;;;6898:5;6866:12;;;:6;:12;;;;;;;;-1:-1:-1;;;;;6866:29:9;;;;;;;;;;:37;;-1:-1:-1;;6866:37:9;;;6922:40;735:10:23;;6866:12:9;;6922:40;;6898:5;6922:40;-1:-1:-1;6983:4:9;6976:11;;7721:208:16;-1:-1:-1;;;;;7791:21:16;;7787:91;;7835:32;;-1:-1:-1;;;7835:32:16;;7864:1;7835:32;;;3989:51:98;3962:18;;7835:32:16;;;;;;;;7787:91;7887:35;7903:1;7907:7;7916:5;7887:7;:35::i;8247:206::-;-1:-1:-1;;;;;8317:21:16;;8313:89;;8361:30;;-1:-1:-1;;;8361:30:16;;8388:1;8361:30;;;3989:51:98;3962:18;;8361:30:16;3843:203:98;8313:89:16;8411:35;8419:7;8436:1;8440:5;8411:7;:35::i;10663:477::-;-1:-1:-1;;;;;3952:18:16;;;10762:24;3952:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;-1:-1:-1;;10828:37:16;;10824:310;;10904:5;10885:16;:24;10881:130;;;10936:60;;-1:-1:-1;;;10936:60:16;;-1:-1:-1;;;;;4271:32:98;;10936:60:16;;;4253:51:98;4320:18;;;4313:34;;;4363:18;;;4356:34;;;4226:18;;10936:60:16;4051:345:98;10881:130:16;11052:57;11061:5;11068:7;11096:5;11077:16;:24;11103:5;11052:8;:57::i;3610:178::-;3679:4;735:10:23;3733:27:16;735:10:23;3750:2:16;3754:5;3733:9;:27::i;9949:432::-;-1:-1:-1;;;;;10061:19:16;;10057:89;;10103:32;;-1:-1:-1;;;10103:32:16;;10132:1;10103:32;;;3989:51:98;3962:18;;10103:32:16;3843:203:98;10057:89:16;-1:-1:-1;;;;;10159:21:16;;10155:90;;10203:31;;-1:-1:-1;;;10203:31:16;;10231:1;10203:31;;;3989:51:98;3962:18;;10203:31:16;3843:203:98;10155:90:16;-1:-1:-1;;;;;10254:18:16;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;:35;;;10299:76;;;;10349:7;-1:-1:-1;;;;;10333:31:16;10342:5;-1:-1:-1;;;;;10333:31:16;;10358:5;10333:31;;;;1633:25:98;;1621:2;1606:18;;1487:177;10333:31:16;;;;;;;;9949:432;;;;:::o;3432:197:9:-;3520:22;3528:4;3534:7;3520;:22::i;:::-;3515:108;;3565:47;;-1:-1:-1;;;3565:47:9;;-1:-1:-1;;;;;4593:32:98;;3565:47:9;;;4575:51:98;4642:18;;;4635:34;;;4548:18;;3565:47:9;4401:274:98;5656:300:16;-1:-1:-1;;;;;5739:18:16;;5735:86;;5780:30;;-1:-1:-1;;;5780:30:16;;5807:1;5780:30;;;3989:51:98;3962:18;;5780:30:16;3843:203:98;5735:86:16;-1:-1:-1;;;;;5834:16:16;;5830:86;;5873:32;;-1:-1:-1;;;5873:32:16;;5902:1;5873:32;;;3989:51:98;3962:18;;5873:32:16;3843:203:98;5830:86:16;5925:24;5933:4;5939:2;5943:5;6271:1107;-1:-1:-1;;;;;6360:18:16;;6356:540;;6512:5;6496:12;;:21;;;;;;;:::i;:::-;;;;-1:-1:-1;6356:540:16;;-1:-1:-1;6356:540:16;;-1:-1:-1;;;;;6570:15:16;;6548:19;6570:15;;;;;;;;;;;6603:19;;;6599:115;;;6649:50;;-1:-1:-1;;;6649:50:16;;-1:-1:-1;;;;;4271:32:98;;6649:50:16;;;4253:51:98;4320:18;;;4313:34;;;4363:18;;;4356:34;;;4226:18;;6649:50:16;4051:345:98;6599:115:16;-1:-1:-1;;;;;6834:15:16;;:9;:15;;;;;;;;;;6852:19;;;;6834:37;;6356:540;-1:-1:-1;;;;;6910:16:16;;6906:425;;7073:12;:21;;;;;;;6906:425;;;-1:-1:-1;;;;;7284:13:16;;:9;:13;;;;;;;;;;:22;;;;;;6906:425;7361:2;-1:-1:-1;;;;;7346:25:16;7355:4;-1:-1:-1;;;;;7346:25:16;;7365:5;7346:25;;;;1633::98;;1621:2;1606:18;;1487:177;7346:25:16;;;;;;;;6271:1107;;;:::o;14:286:98:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;167:23;;-1:-1:-1;;;;;;219:32:98;;209:43;;199:71;;266:1;263;256:12;199:71;289:5;14:286;-1:-1:-1;;;14:286:98:o;497:548::-;609:4;638:2;667;656:9;649:21;699:6;693:13;742:6;737:2;726:9;722:18;715:34;767:1;777:140;791:6;788:1;785:13;777:140;;;886:14;;;882:23;;876:30;852:17;;;871:2;848:26;841:66;806:10;;777:140;;;781:3;966:1;961:2;952:6;941:9;937:22;933:31;926:42;1036:2;1029;1025:7;1020:2;1012:6;1008:15;1004:29;993:9;989:45;985:54;977:62;;;;497:548;;;;:::o;1050:173::-;1118:20;;-1:-1:-1;;;;;1167:31:98;;1157:42;;1147:70;;1213:1;1210;1203:12;1147:70;1050:173;;;:::o;1228:254::-;1296:6;1304;1357:2;1345:9;1336:7;1332:23;1328:32;1325:52;;;1373:1;1370;1363:12;1325:52;1396:29;1415:9;1396:29;:::i;:::-;1386:39;1472:2;1457:18;;;;1444:32;;-1:-1:-1;;;1228:254:98:o;1851:328::-;1928:6;1936;1944;1997:2;1985:9;1976:7;1972:23;1968:32;1965:52;;;2013:1;2010;2003:12;1965:52;2036:29;2055:9;2036:29;:::i;:::-;2026:39;;2084:38;2118:2;2107:9;2103:18;2084:38;:::i;:::-;2074:48;;2169:2;2158:9;2154:18;2141:32;2131:42;;1851:328;;;;;:::o;2184:180::-;2243:6;2296:2;2284:9;2275:7;2271:23;2267:32;2264:52;;;2312:1;2309;2302:12;2264:52;-1:-1:-1;2335:23:98;;2184:180;-1:-1:-1;2184:180:98:o;2369:254::-;2437:6;2445;2498:2;2486:9;2477:7;2473:23;2469:32;2466:52;;;2514:1;2511;2504:12;2466:52;2550:9;2537:23;2527:33;;2579:38;2613:2;2602:9;2598:18;2579:38;:::i;:::-;2569:48;;2369:254;;;;;:::o;3002:186::-;3061:6;3114:2;3102:9;3093:7;3089:23;3085:32;3082:52;;;3130:1;3127;3120:12;3082:52;3153:29;3172:9;3153:29;:::i;3193:260::-;3261:6;3269;3322:2;3310:9;3301:7;3297:23;3293:32;3290:52;;;3338:1;3335;3328:12;3290:52;3361:29;3380:9;3361:29;:::i;:::-;3351:39;;3409:38;3443:2;3432:9;3428:18;3409:38;:::i;3458:380::-;3537:1;3533:12;;;;3580;;;3601:61;;3655:4;3647:6;3643:17;3633:27;;3601:61;3708:2;3700:6;3697:14;3677:18;3674:38;3671:161;;3754:10;3749:3;3745:20;3742:1;3735:31;3789:4;3786:1;3779:15;3817:4;3814:1;3807:15;3671:161;;3458:380;;;:::o;4680:222::-;4745:9;;;4766:10;;;4763:133;;;4818:10;4813:3;4809:20;4806:1;4799:31;4853:4;4850:1;4843:15;4881:4;4878:1;4871:15
Swarm Source
none
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.