Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Verify Proof And... | 20407242 | 176 days ago | IN | 0 ETH | 0.02271798 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x9069A510...B10e369FF The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
GpsStatementVerifier
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity Standard Json-Input format)
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../cpu/CairoBootloaderProgram.sol"; import "../cpu/CairoVerifierContract.sol"; import "../cpu/MemoryPageFactRegistry.sol"; import "../../interfaces/Identity.sol"; import "../PrimeFieldElement0.sol"; import "./GpsOutputParser.sol"; contract GpsStatementVerifier is GpsOutputParser, Identity, CairoBootloaderProgramSize, PrimeFieldElement0 { CairoBootloaderProgram bootloaderProgramContractAddress; MemoryPageFactRegistry memoryPageFactRegistry; CairoVerifierContract[] cairoVerifierContractAddresses; uint256 internal constant N_BUILTINS = 11; uint256 internal constant N_MAIN_ARGS = N_BUILTINS; uint256 internal constant N_MAIN_RETURN_VALUES = N_BUILTINS; // Cairo verifier program hash. uint256 immutable hashedSupportedCairoVerifiers_; // Simple bootloader program hash. uint256 immutable simpleBootloaderProgramHash_; // Applicative bootloader program hash. uint256 immutable applicativeBootloaderProgramHash_; /* Constructs an instance of GpsStatementVerifier. bootloaderProgramContract is the address of the bootloader program contract and cairoVerifierContracts is a list of cairoVerifiers indexed by their id. */ constructor( address bootloaderProgramContract, address memoryPageFactRegistry_, address[] memory cairoVerifierContracts, uint256 simpleBootloaderProgramHash, uint256 applicativeBootloaderProgramHash, uint256 hashedSupportedCairoVerifiers, address referenceVerifier, uint256 referralDurationSeconds ) public GpsOutputParser(referenceVerifier, referralDurationSeconds) { bootloaderProgramContractAddress = CairoBootloaderProgram(bootloaderProgramContract); memoryPageFactRegistry = MemoryPageFactRegistry(memoryPageFactRegistry_); cairoVerifierContractAddresses = new CairoVerifierContract[](cairoVerifierContracts.length); for (uint256 i = 0; i < cairoVerifierContracts.length; ++i) { cairoVerifierContractAddresses[i] = CairoVerifierContract(cairoVerifierContracts[i]); } hashedSupportedCairoVerifiers_ = hashedSupportedCairoVerifiers; simpleBootloaderProgramHash_ = simpleBootloaderProgramHash; applicativeBootloaderProgramHash_ = applicativeBootloaderProgramHash; } function identify() external pure override returns (string memory) { return "StarkWare_GpsStatementVerifier_2024_10"; } /* Returns the bootloader config. */ function getBootloaderConfig() external view returns ( uint256, uint256, uint256 ) { return ( simpleBootloaderProgramHash_, applicativeBootloaderProgramHash_, hashedSupportedCairoVerifiers_ ); } /* Verifies a proof and registers the corresponding facts. For the structure of cairoAuxInput, see cpu/CpuPublicInputOffsets.sol. taskMetadata is structured as follows: 1. Number of tasks. 2. For each task: 1. Task output size (including program hash and size). 2. Program hash. */ function verifyProofAndRegister( uint256[] calldata proofParams, uint256[] calldata proof, uint256[] calldata taskMetadata, uint256[] calldata cairoAuxInput, uint256 cairoVerifierId ) external { require( cairoVerifierId < cairoVerifierContractAddresses.length, "cairoVerifierId is out of range." ); CairoVerifierContract cairoVerifier = cairoVerifierContractAddresses[cairoVerifierId]; // The values z and alpha are used only for the fact registration of the main page. // They are not part of the public input of CpuVerifier as they are computed there. // Take the relevant slice from 'cairoAuxInput'. uint256[] calldata cairoPublicInput = ( cairoAuxInput[:cairoAuxInput.length - // z and alpha. 2] ); uint256[] memory publicMemoryPages; { (uint256 publicMemoryOffset, uint256 selectedBuiltins) = cairoVerifier.getLayoutInfo(); require(cairoAuxInput.length > publicMemoryOffset, "Invalid cairoAuxInput length."); publicMemoryPages = (uint256[])(cairoPublicInput[publicMemoryOffset:]); uint256 nPages = publicMemoryPages[0]; require(nPages < 10000, "Invalid nPages."); // Validate publicMemoryPages.length. // Each page has a page info and a cumulative product. // There is no 'page address' in the page info for page 0, but this 'free' slot is // used to store the number of pages. require( publicMemoryPages.length == nPages * (PAGE_INFO_SIZE + 1), "Invalid publicMemoryPages length." ); // Process public memory. ( uint256 publicMemoryLength, uint256 memoryHash, uint256 prod ) = registerPublicMemoryMainPage(taskMetadata, cairoAuxInput, selectedBuiltins); // Make sure the first page is valid. // If the size or the hash are invalid, it may indicate that there is a mismatch // between the prover and the verifier on the bootloader program or bootloader config. require( publicMemoryPages[PAGE_INFO_SIZE_OFFSET] == publicMemoryLength, "Invalid size for memory page 0." ); require( publicMemoryPages[PAGE_INFO_HASH_OFFSET] == memoryHash, "Invalid hash for memory page 0." ); require( publicMemoryPages[nPages * PAGE_INFO_SIZE] == prod, "Invalid cumulative product for memory page 0." ); } // NOLINTNEXTLINE: reentrancy-benign. cairoVerifier.verifyProofExternal(proofParams, proof, (uint256[])(cairoPublicInput)); registerGpsFacts(taskMetadata, publicMemoryPages, cairoAuxInput[OFFSET_OUTPUT_BEGIN_ADDR]); } /* Registers the fact for memory page 0, which includes: 1. The bootloader program, 2. Arguments and return values of main() 3. Some of the data required for computing the task facts. which is represented in taskMetadata. Returns information on the registered fact. Arguments: selectedBuiltins: A bit-map of builtins that are present in the layout. See CairoVerifierContract.sol for more information. taskMetadata: Per task metadata. cairoAuxInput: Auxiliary input for the cairo verifier. Assumptions: cairoAuxInput is connected to the public input, which is verified by cairoVerifierContractAddresses. Guarantees: taskMetadata is consistent with the public memory, with some sanity checks. */ function registerPublicMemoryMainPage( uint256[] calldata taskMetadata, uint256[] calldata cairoAuxInput, uint256 selectedBuiltins ) private returns ( uint256 publicMemoryLength, uint256 memoryHash, uint256 prod ) { uint256 nTasks = taskMetadata[0]; // Ensure 'nTasks' is bounded as a sanity check (the bound is somewhat arbitrary). require(nTasks < 2**30, "Invalid number of tasks."); // Public memory length. publicMemoryLength = (PROGRAM_SIZE + // return fp and pc = 2 + N_MAIN_ARGS + N_MAIN_RETURN_VALUES + // Bootloader config size = 3 + // Number of tasks cell = 1 + 2 * nTasks); uint256[] memory publicMemory = new uint256[](MEMORY_PAIR_SIZE * publicMemoryLength); uint256 offset = 0; // Write public memory, which is a list of pairs (address, value). { // Program segment. uint256[PROGRAM_SIZE] memory bootloaderProgram = bootloaderProgramContractAddress .getCompiledProgram(); for (uint256 i = 0; i < bootloaderProgram.length; i++) { // Force that memory[i + INITIAL_PC] = bootloaderProgram[i]. publicMemory[offset] = i + INITIAL_PC; publicMemory[offset + 1] = bootloaderProgram[i]; offset += 2; } } { // Execution segment - Make sure [initial_fp - 2] = initial_fp and . // This is required for the "safe call" feature (that is, all "call" instructions will // return, even if the called function is malicious). // It guarantees that it's not possible to create a cycle in the call stack. uint256 initialFp = cairoAuxInput[OFFSET_EXECUTION_BEGIN_ADDR]; require(initialFp >= 2, "Invalid execution begin address."); publicMemory[offset + 0] = initialFp - 2; publicMemory[offset + 1] = initialFp; // Make sure [initial_fp - 1] = 0. publicMemory[offset + 2] = initialFp - 1; publicMemory[offset + 3] = 0; offset += 4; // Execution segment: Enforce main's arguments and return values. // Note that the page hash depends on the order of the (address, value) pair in the // publicMemory and consequently the arguments must be written before the return values. uint256 returnValuesAddress = cairoAuxInput[OFFSET_EXECUTION_STOP_PTR] - N_BUILTINS; uint256 builtinSegmentInfoOffset = OFFSET_OUTPUT_BEGIN_ADDR; for (uint256 i = 0; i < N_BUILTINS; i++) { // Write argument address. publicMemory[offset] = initialFp + i; uint256 returnValueOffset = offset + 2 * N_BUILTINS; // Write return value address. publicMemory[returnValueOffset] = returnValuesAddress + i; // Write values. if ((selectedBuiltins & 1) != 0) { // Set the argument to the builtin start pointer. publicMemory[offset + 1] = cairoAuxInput[builtinSegmentInfoOffset]; // Set the return value to the builtin stop pointer. publicMemory[returnValueOffset + 1] = cairoAuxInput[ builtinSegmentInfoOffset + 1 ]; builtinSegmentInfoOffset += 2; } else { // Builtin is not present in layout, set the argument value and return value to 0. publicMemory[offset + 1] = 0; publicMemory[returnValueOffset + 1] = 0; } offset += 2; selectedBuiltins >>= 1; } require(selectedBuiltins == 0, "SELECTED_BUILTINS_VECTOR_IS_TOO_LONG"); // Skip the return values which were already written. offset += 2 * N_BUILTINS; } // Program output. { { uint256 outputAddress = cairoAuxInput[OFFSET_OUTPUT_BEGIN_ADDR]; // Force that memory[outputAddress: outputAddress + 3] contain the bootloader config // (which is 3 words size). publicMemory[offset + 0] = outputAddress; publicMemory[offset + 1] = simpleBootloaderProgramHash_; publicMemory[offset + 2] = outputAddress + 1; publicMemory[offset + 3] = applicativeBootloaderProgramHash_; publicMemory[offset + 4] = outputAddress + 2; publicMemory[offset + 5] = hashedSupportedCairoVerifiers_; // Force that memory[outputAddress + 3] = nTasks. publicMemory[offset + 6] = outputAddress + 3; publicMemory[offset + 7] = nTasks; offset += 8; outputAddress += 4; uint256[] calldata taskMetadataSlice = taskMetadata[METADATA_TASKS_OFFSET:]; for (uint256 task = 0; task < nTasks; task++) { uint256 outputSize = taskMetadataSlice[METADATA_OFFSET_TASK_OUTPUT_SIZE]; // Ensure 'outputSize' is at least 2 and bounded from above as a sanity check // (the bound is somewhat arbitrary). require(2 <= outputSize && outputSize < 2**30, "Invalid task output size."); uint256 programHash = taskMetadataSlice[METADATA_OFFSET_TASK_PROGRAM_HASH]; uint256 nTreePairs = taskMetadataSlice[METADATA_OFFSET_TASK_N_TREE_PAIRS]; // Ensure 'nTreePairs' is at least 1 and bounded from above as a sanity check // (the bound is somewhat arbitrary). require( 1 <= nTreePairs && nTreePairs < 2**20, "Invalid number of pairs in the Merkle tree structure." ); // Force that memory[outputAddress] = outputSize. publicMemory[offset + 0] = outputAddress; publicMemory[offset + 1] = outputSize; // Force that memory[outputAddress + 1] = programHash. publicMemory[offset + 2] = outputAddress + 1; publicMemory[offset + 3] = programHash; offset += 4; outputAddress += outputSize; taskMetadataSlice = taskMetadataSlice[METADATA_TASK_HEADER_SIZE + 2 * nTreePairs:]; } require(taskMetadataSlice.length == 0, "Invalid length of taskMetadata."); require( cairoAuxInput[OFFSET_OUTPUT_STOP_PTR] == outputAddress, "Inconsistent program output length." ); } } require(publicMemory.length == offset, "Not all Cairo public inputs were written."); uint256 z = cairoAuxInput[cairoAuxInput.length - 2]; uint256 alpha = cairoAuxInput[cairoAuxInput.length - 1]; bytes32 factHash; (factHash, memoryHash, prod) = memoryPageFactRegistry.registerRegularMemoryPage( publicMemory, z, alpha, K_MODULUS ); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity >=0.6.12; /* Common Utility Libraries. I. Addresses (extending address). */ library Addresses { /* Note: isContract function has some known limitation. See https://github.com/OpenZeppelin/ openzeppelin-contracts/blob/master/contracts/utils/Address.sol. */ function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function performEthTransfer(address recipient, uint256 amount) internal { if (amount == 0) return; (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls. require(success, "ETH_TRANSFER_FAILED"); } /* Safe wrapper around ERC20/ERC721 calls. This is required because many deployed ERC20 contracts don't return a value. See https://github.com/ethereum/solidity/issues/4116. */ function safeTokenContractCall(address tokenAddress, bytes memory callData) internal { require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS"); // NOLINTNEXTLINE: low-level-calls. (bool success, bytes memory returndata) = tokenAddress.call(callData); require(success, string(returndata)); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED"); } } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // ---------- The following code was auto-generated. PLEASE DO NOT EDIT. ---------- // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; contract CairoBootloaderProgramSize { uint256 internal constant PROGRAM_SIZE = 794; } contract CairoBootloaderProgram is CairoBootloaderProgramSize { function getCompiledProgram() external pure returns (uint256[PROGRAM_SIZE] memory) { return [ 290341444919459839, 11, 1226245742482522112, 778, 74168662805676031, 0, 2345108766317314046, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 5198420613823102976, 3618502788666131213697322783095070105623107215331596699973092056135872020479, 2345108766317314046, 146226256843603965, 4, 5191102238658887680, 2345108766317314046, 290341444919459839, 3, 4632937381316558848, 4612671182992932865, 4612671182992998402, 146226256843603968, 4, 74168662805676031, 4, 4612671182993063937, 4612671182993129474, 5198983563776196608, 1, 5198983563776262144, 1, 5200109459388203008, 5200109459388268544, 5198983563776458752, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020458, 2345108766317314046, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020449, 5207990763031068672, 10, 5198420613823168512, 12, 5191102230068953088, 5191102234363920384, 5191102242953854976, 5201798292068466688, 5191102238658887680, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020444, 4623648689905041407, 291467327646433279, 2345108766317314046, 5199827962936983548, 5208553695804948479, 4612389708016287743, 5198983563776262144, 1, 2345108766317314046, 146226256843603965, 4, 5191102230068953088, 2345108766317314046, 5191102230068953088, 5188850460319711232, 5188850460319776768, 5188850460319842304, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020467, 5198983563776262144, 1, 5198983563776327680, 1, 5198983563776393216, 1, 5198983563776458752, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020463, 2345108766317314046, 5189976364521848832, 0, 5189976364521848832, 0, 5189976364521848832, 0, 5191102247248822272, 5191102238658887680, 290341444919459839, 1, 145944781866893311, 4, 74168662805676031, 58, 5188287510366486528, 5201798304953368576, 4611826758062997503, 5188287514661322752, 5201798304953303040, 4611826762357833727, 4611826766652801016, 5188287523251191808, 5188287518956093440, 5201798304953696256, 4611826783832473599, 5188287527545962496, 5188287523250864128, 5201798304953696256, 4611826788127244287, 5188287531840733184, 4611826792422146047, 5188287549020536832, 5188287527545569280, 5201798304953696256, 4611826809601818623, 5188287553315307520, 5188287531840339968, 5201798304953696256, 4611826813896589311, 5188287557610078208, 4611826818191491071, 5188287574789881856, 5188287536135045120, 5201798304953696256, 4611826835371163647, 5188287579084652544, 5188287540429815808, 5201798304953696256, 4611826839665934335, 5188287583379423232, 4611826843960836095, 5188287600559226880, 5188287544724520960, 5201798304953696256, 4611826861140508671, 5188287604853997568, 5188287549019291648, 5201798304953696256, 4611826865435279359, 5188287609148768256, 4611826869730181119, 5188287626328571904, 5188287630623473664, 5188287634918375424, 5198420613820743680, 10, 5198420613820743680, 30, 74168662805676031, 3618502788666131213697322783095070105623107215331596699973092056135872020421, 290341444919459839, 1, 145944781866893311, 4, 74168662805676031, 18, 5188287510366420992, 5201798304953303040, 4611826758062931967, 5188287514661257216, 5201798304953237504, 4611826762357768191, 4611826766652735479, 5188287523251126272, 5188287527546028032, 5188287531840929792, 5198420613822513152, 2, 5198420613822513152, 6, 74168662805676031, 3618502788666131213697322783095070105623107215331596699973092056135872020399, 5200109442208464896, 5201798287773958143, 145944781866893311, 11, 5198420613822644224, 1, 4611826758062866431, 4611826762357833719, 4611826766652801016, 5198420613822840832, 6, 5188287523251126272, 2345108766317314046, 4613515612218425343, 1, 5188287510366289920, 5201798304953171968, 4611826758062800895, 5198420613822578688, 1, 4611826762357702655, 4611826766652669942, 5198420613822709760, 6, 5188287523250995200, 2345108766317314046, 5188850460319907840, 5202361254907052032, 5191102242953854976, 5188287510366552064, 5188287506071519232, 5188287510366486527, 4611826762357964797, 5198420613822906368, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 5198420613822906368, 3, 5188287518956224512, 4623085744246521853, 145944781866893308, 3618502788666131213697322783095070105623107215331596699973092056135872020472, 2345108766317314046, 5198983563776458752, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 145944781866893311, 12, 5191102238658887680, 5188850460319842304, 5198983563776393216, 1, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020339, 5191102234363920384, 5193354047062507520, 5193354047062507520, 2345108766317314046, 5191102234363920384, 5191102242953854976, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020449, 5193354051357474816, 5191102238658887680, 5193354047062507520, 2345108766317314046, 290341444919459839, 30, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020248, 4617174774030761984, 4612671182992932866, 5189976364521848832, 0, 4612389712311713791, 5188850464614612992, 5188850490384416768, 5191102264428691456, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020446, 4612389712311779327, 4622804286450008067, 4, 4612671195878359044, 5200109476568596480, 5188850468910104576, 4625619027626983429, 4622804286450073606, 2, 4617174761145860103, 4612671191582867464, 4612671195877834761, 4612671200172802058, 4612671204467769355, 4612671208762736652, 4617174765440827405, 4612671217352671246, 4612671221647638543, 4612671225942605840, 5191102238658887680, 5198983563776655360, 6, 5189976364521848832, 11, 5191102273018626048, 5191102277313593344, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020241, 1191342862550269952, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020207, 4623648724266090495, 5191102238658887680, 5198983563776655360, 18, 5191102273018626048, 5191102333148168192, 5189976364521848832, 11, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020202, 4623648719970271231, 5191102234363920384, 5198983563776655360, 6, 5198983563776655360, 18, 5191102242953854976, 5189976364521848832, 11, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020239, 4623930190653653010, 4612671182993522717, 5198983563776655360, 18, 5193354051357474816, 2345108766317314046, 290341444919459839, 35, 4622804286449090561, 1, 4614922931267403778, 4614922982807011331, 4614922939857338372, 4614922944152305669, 4614922948447272966, 4614922952742240263, 4614922957037207560, 4614922961332174857, 4614922965627142154, 4614922969922109451, 4613797087195136012, 122550255383924, 4613797087195136013, 8098989891770344814, 4613797087195136014, 138277649577220228665140075, 4613797087195136015, 435459224417, 4613797087195136016, 27700496658166629, 4613797087195136017, 435458895728, 4613797087195136018, 118083203326315, 4613797087195136019, 8101821134059892590, 4613797087195136020, 9062164042692704905798619969846, 4613797087195136021, 27413455001448292, 4613797087195136022, 30809880779386724, 4613797087195136023, 1, 4613797087195136024, 3, 4613797087195136025, 1, 4613797087195136026, 2, 4613797087195136027, 5, 4613797087195136028, 7, 4613797087195136029, 16, 4613797087195136030, 6, 4613797087195136031, 1, 4613797087195136032, 7, 4613797087195136033, 7, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020119, 5198420613823102976, 1, 5191102212889083904, 5198420613822971904, 12, 5198420613822906368, 23, 5188850460319252480, 1226245742482522112, 38, 4614641507830300671, 4617174774030762018, 5188850468912267264, 5201798300658860031, 5189976364521848832, 64, 1226245742482522112, 14, 5188850460322332672, 5188850464617299968, 5188850468912267264, 5188850473207234560, 5188850477502201856, 5188850481797169152, 5188850486092136448, 5188850490387103744, 5188850494682071040, 5188850498977038336, 5188850503272005632, 2345108766317314046, 146226256843603965, 5, 4613797087195135996, 0, 2345108766317314046, 290341444919459839, 1, 5201798304953761792, 5202079779930537980, 4634344751905079295, 5193354047062507520, 5198983563776458752, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020468, 2345108766317314046, 146226256843603965, 5, 5191102230068953088, 5191102234363920384, 2345108766317314046, 290341444919459839, 1, 5191102230068953088, 5191102234363920384, 5191102238658887680, 5191102242953854976, 5193354038472572928, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020290, 5191102238658887680, 5191102242953854976, 5198983563776458752, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020463, 2345108766317314046, 4612671182993129469, 5198983563776393216, 1, 2345108766317314046, 5191102238658887680, 5199827967231950845, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020475, 2345108766317314046, 5191102238658887680, 5191102242953854976, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020470, 5191102242953854976, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020470, 2345108766317314046, 290341444919459839, 1, 5191102230068953088, 5191102260133724160, 5198983563776393216, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020466, 5209116658642944000, 5202361254906855424, 4612108233039904765, 5193354047062507520, 5193354051357474816, 2345108766317314046, 4612671182993063932, 4612671187288031229, 5198983563776327680, 3, 5188850468909711360, 2345108766317314046, 290341444919459839, 2, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020010, 4613797087195136000, 0, 4613797087195136001, 0, 5193354051357474816, 2345108766317314046, 290341444919459839, 2, 5191102234363920384, 5191102242953854976, 5191102247248822272, 5188850460319776768, 1226245742482522112, 16, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872019994, 4617174769735794688, 5188850464614744064, 4623367219223429121, 5193354038472572928, 5193354042767540224, 2345108766317314046, 5191102242953854976, 5188850460319907840, 5188850464614875136, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020446, 2345108766317314046, 146226256843603964, 5, 5191102234363920384, 5191102247248822272, 2345108766317314046, 290341444919459839, 1, 5198983563776393216, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 4626181977580208128, 5191102238658887680, 5191102234363920384, 5191102247248822272, 5202079771340603392, 4611826758063063038, 5188287510366420992, 4611826762357964799, 5198420613822906368, 1, 5198420613822906368, 3, 5188287518956224512, 145944781866893307, 3618502788666131213697322783095070105623107215331596699973092056135872020472, 2345108766317314046, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020424, 5191102238658887680, 5193354051357474816, 5191102242953854976, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020428, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020442, 2345108766317314046, 146226256843603965, 3, 2345108766317314046, 5191102238658887680, 5191102242953854976, 5188287510366617600, 4611826758063063039, 5198420613823037441, 1, 5198420613823037441, 1, 722405534170316798, 3618502788666131213697322783095070105623107215331596699973092056135872020475, 4623648689905041407, 2345108766317314046, 290341444919459839, 14, 5191102260133724160, 5191102208594116608, 5191102212889083904, 5191102217184051200, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5191102234363920384, 5191102238658887680, 5191102242953854976, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020220, 4617174743965990913, 4617174748260958210, 4617174752555925507, 4617174756850892804, 4617174761145860101, 4617174765440827398, 4617174769735794695, 4617174774030761992, 4617174778325729289, 4617174735376056330, 4614922926972436492, 5191102204299149312, 5193354012702769152, 5191102307378364416, 1226245742482522112, 75, 4617174774030761997, 5198420613823102976, 1, 5193354051357474816, 5191102285903527936, 5191102264428691456, 5189976364521848832, 0, 5198983563776655360, 1, 5191102307378364416, 5188850460320104448, 5191102311673331712, 1226245742482522112, 16, 4617174778325729290, 4612389708017532926, 5193354034177605632, 5193354034177605632, 5193354038472572928, 5191102268723658752, 5191102273018626048, 5191102277313593344, 5191102281608560640, 5193354012702769152, 5191102290198495232, 5191102294493462528, 5191102298788429824, 2345108766317314046, 146226256843603964, 9, 5191102212889083904, 5191102217184051200, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5191102234363920384, 2345108766317314046, 290341444919459839, 0, 290341444919459839, 1, 145944781866893311, 14, 5191102212889083904, 5191102217184051200, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5191102234363920384, 5191102238658887680, 5191102247248822272, 1226245742482522112, 39, 74168662805676031, 12, 5191102212889083904, 5191102217184051200, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5191102234363920384, 5191102238658887680, 5191102247248822272, 1226245742482522112, 74, 5191102238658887680, 5198983563776393216, 3618502788666131213697322783095070105623107215331596699973092056135872020480, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020440, 2345108766317314046, 5188850460319907840, 4612389708016353279, 5188850473204809728, 4612389712311320575, 5191102242953854976, 5188850468909842432, 5188850464614875136, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020344, 4612389716606287871, 5198983563776327680, 3, 5193354047062507520, 2345108766317314046, 5198983563776458752, 2, 5191102247248822272, 2345108766317314046, 290341444919459839, 4, 5191102225773985792, 5191102264428691456, 5191102260133724160, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872019877, 5191102238658887680, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020469, 5189976364521848832, 4, 4611826758063128575, 5191102230068953088, 5188850468909776896, 5189976364521848832, 1, 5188850464614809600, 5188287514661257216, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020237, 5188850460319842304, 4611826758060965887, 4611826762355933145, 4622241336494227458, 2, 4614922982807011331, 5191102217184051200, 5191102221479018496, 5193353879558782976, 5193354034177605632, 5191102234363920384, 5198983563776655360, 1, 5191102242953854976, 5188850460320104448, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020382, 4623648711380271103, 5193354034177605632, 5193354034177605632, 5193354034177605632, 5193354034177605632, 5193354034177605632, 5191102268723658752, 2345108766317314046, 290341444919459839, 4, 5191102238658887680, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020427, 4617174774030761984, 5188287514661584896, 5188850473204744192, 5201798304953827326, 145944781866893311, 16, 4613797087195136003, 4, 5188287510366420992, 4623648719970074623, 4612671182993391618, 5198983563776655360, 1, 5191102247248822272, 5189976364521848832, 3, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020276, 74168662805676031, 6, 4612108233039708161, 4612108237334675458, 4613797087195136003, 0, 4612671182992736257, 4612671187287703554, 5198983563776000000, 2, 5200109472273432576, 5198983563776720896, 3618502788666131213697322783095070105623107215331596699973092056135872020479, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020261, 5198983563776000000, 2, 5198983563776720896, 3618502788666131213697322783095070105623107215331596699973092056135872020479, 5200109472273432576, 5198983563776720896, 3618502788666131213697322783095070105623107215331596699973092056135872020479, 5201798296363630592, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5198983563776262144, 1, 5201798283478532096, 2345108766317314046, 5191102204299149312, 5191102208594116608, 5191102212889083904, 5191102217184051200, 5191102221479018496, 5191102225773985792, 5191102230068953088, 5191102234363920384, 5191102238658887680, 5191102242953854976, 5191102247248822272, 1226245742482522112, 3618502788666131213697322783095070105623107215331596699973092056135872020248, 2345108766317314046 ]; } } // ---------- End of auto-generated code. ----------
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract CairoVerifierContract { function verifyProofExternal( uint256[] calldata proofParams, uint256[] calldata proof, uint256[] calldata publicInput ) external virtual; /* Returns information that is related to the layout. publicMemoryOffset is the offset of the public memory pages' information in the public input. selectedBuiltins is a bit-map of builtins that are present in the layout. */ function getLayoutInfo() external pure virtual returns (uint256 publicMemoryOffset, uint256 selectedBuiltins); uint256 internal constant OUTPUT_BUILTIN_BIT = 0; uint256 internal constant PEDERSEN_BUILTIN_BIT = 1; uint256 internal constant RANGE_CHECK_BUILTIN_BIT = 2; uint256 internal constant ECDSA_BUILTIN_BIT = 3; uint256 internal constant BITWISE_BUILTIN_BIT = 4; uint256 internal constant EC_OP_BUILTIN_BIT = 5; uint256 internal constant KECCAK_BUILTIN_BIT = 6; uint256 internal constant POSEIDON_BUILTIN_BIT = 7; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // ---------- The following code was auto-generated. PLEASE DO NOT EDIT. ---------- // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "./PageInfo.sol"; contract CpuPublicInputOffsetsBase is PageInfo { // The following constants are offsets of data expected in the public input. uint256 internal constant OFFSET_N_VERIFIER_FRIENDLY_LAYERS = 0; uint256 internal constant OFFSET_LOG_N_STEPS = 1; uint256 internal constant OFFSET_RC_MIN = 2; uint256 internal constant OFFSET_RC_MAX = 3; uint256 internal constant OFFSET_LAYOUT_CODE = 4; uint256 internal constant OFFSET_PROGRAM_BEGIN_ADDR = 5; uint256 internal constant OFFSET_PROGRAM_STOP_PTR = 6; uint256 internal constant OFFSET_EXECUTION_BEGIN_ADDR = 7; uint256 internal constant OFFSET_EXECUTION_STOP_PTR = 8; uint256 internal constant OFFSET_OUTPUT_BEGIN_ADDR = 9; uint256 internal constant OFFSET_OUTPUT_STOP_PTR = 10; uint256 internal constant OFFSET_PEDERSEN_BEGIN_ADDR = 11; uint256 internal constant OFFSET_PEDERSEN_STOP_PTR = 12; uint256 internal constant OFFSET_RANGE_CHECK_BEGIN_ADDR = 13; uint256 internal constant OFFSET_RANGE_CHECK_STOP_PTR = 14; // The program segment starts from 1, so that memory address 0 is kept for the null pointer. uint256 internal constant INITIAL_PC = 1; // The first Cairo instructions are: // ap += n_args; call main; jmp rel 0. // As the first two instructions occupy 2 cells each, the "jmp rel 0" instruction is at // offset 4 relative to INITIAL_PC. uint256 internal constant FINAL_PC = INITIAL_PC + 4; } // ---------- End of auto-generated code. ----------
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../interfaces/IQueryableFactRegistry.sol"; contract FactRegistry is IQueryableFactRegistry { // Mapping: fact hash -> true. mapping(bytes32 => bool) private verifiedFact; // Indicates whether the Fact Registry has at least one fact registered. bool anyFactRegistered = false; /* Checks if a fact was registered. */ function isValid(bytes32 fact) external view virtual override returns (bool) { return internalIsValid(fact); } /* The internal implementation that checks if the fact was registered. */ function internalIsValid(bytes32 fact) internal view virtual returns (bool) { return verifiedFact[fact]; } function registerFact(bytes32 factHash) internal { // This function stores the fact hash in the mapping. verifiedFact[factHash] = true; // Mark first time off. if (!anyFactRegistered) { anyFactRegistered = true; } } /* Indicates whether at least one fact was registered. */ function hasRegisteredFact() external view override returns (bool) { return anyFactRegistered; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../../components/ReferableFactRegistry.sol"; import "../cpu/CpuPublicInputOffsetsBase.sol"; /* A utility contract to parse the GPS output. See registerGpsFacts for more details. */ contract GpsOutputParser is CpuPublicInputOffsetsBase, ReferableFactRegistry { uint256 internal constant METADATA_TASKS_OFFSET = 1; uint256 internal constant METADATA_OFFSET_TASK_OUTPUT_SIZE = 0; uint256 internal constant METADATA_OFFSET_TASK_PROGRAM_HASH = 1; uint256 internal constant METADATA_OFFSET_TASK_N_TREE_PAIRS = 2; uint256 internal constant METADATA_TASK_HEADER_SIZE = 3; uint256 internal constant METADATA_OFFSET_TREE_PAIR_N_PAGES = 0; uint256 internal constant METADATA_OFFSET_TREE_PAIR_N_NODES = 1; uint256 internal constant NODE_STACK_OFFSET_HASH = 0; uint256 internal constant NODE_STACK_OFFSET_END = 1; // The size of each node in the node stack. uint256 internal constant NODE_STACK_ITEM_SIZE = 2; uint256 internal constant FIRST_CONTINUOUS_PAGE_INDEX = 1; /* Logs the program output fact together with the relevant continuous memory pages' hashes. The event is emitted for each registered fact. */ event LogMemoryPagesHashes(bytes32 programOutputFact, bytes32[] pagesHashes); constructor(address refFactRegistry, uint256 referralDuration) public ReferableFactRegistry(refFactRegistry, referralDuration) {} /* Parses the GPS program output (using taskMetadata, which should be verified by the caller), and registers the facts of the tasks which were executed. The first entry in taskMetadata is the number of tasks. For each task, the structure is as follows: 1. Size (including the size and hash fields). 2. Program hash. 3. The number of pairs in the Merkle tree structure (see below). 4. The Merkle tree structure (see below). The fact of each task is stored as a (non-binary) Merkle tree. Leaf nodes are labeled with the hash of their data. Each non-leaf node is labeled as 1 + the hash of (node0, end0, node1, end1, ...) where node* is a label of a child children and end* is the total number of data words up to and including that node and its children (including the previous sibling nodes). We add 1 to the result of the hash to prevent an attacker from using a preimage of a leaf node as a preimage of a non-leaf hash and vice versa. The structure of the tree is passed as a list of pairs (n_pages, n_nodes), and the tree is constructed using a stack of nodes (initialized to an empty stack) by repeating for each pair: 1. Add n_pages to the stack of nodes. 2. Pop the top n_nodes, construct a parent node for them, and push it back to the stack. After applying the steps above, the stack much contain exactly one node, which will constitute the root of the Merkle tree. For example, [(2, 2)] will create a Merkle tree with a root and two direct children, while [(3, 2), (0, 2)] will create a Merkle tree with a root whose left child is a leaf and right child has two leaf children. Assumptions: taskMetadata and cairoAuxInput are verified externally. */ function registerGpsFacts( uint256[] calldata taskMetadata, uint256[] memory publicMemoryPages, uint256 outputStartAddress ) internal { uint256 totalNumPages = publicMemoryPages[0]; // Allocate some of the loop variables here to avoid the stack-too-deep error. uint256 task; uint256 nTreePairs; uint256 nTasks = taskMetadata[0]; // Contains fact hash with the relevant memory pages' hashes. // Size is bounded from above with the total number of pages. Three extra places are // dedicated for the fact hash and the array address and length. uint256[] memory pageHashesLogData = new uint256[](totalNumPages + 3); // Relative address to the beginning of the memory pages' hashes in the array. pageHashesLogData[1] = 0x40; uint256 taskMetadataOffset = METADATA_TASKS_OFFSET; // Skip the first 6 output cells, which contain the bootloader config (3 cells), the number // of tasks and the size and program hash of the first task. curAddr points to the output of // the first task. uint256 curAddr = outputStartAddress + 6; // Skip the main page. uint256 curPage = FIRST_CONTINUOUS_PAGE_INDEX; // Bound the size of the stack by the total number of pages. // TODO(lior, 15/04/2022): Get a better bound on the size of the stack. uint256[] memory nodeStack = new uint256[](NODE_STACK_ITEM_SIZE * totalNumPages); // Copy to memory to workaround the "stack too deep" error. uint256[] memory taskMetadataCopy = taskMetadata; uint256[PAGE_INFO_SIZE] memory pageInfoPtr; assembly { // Skip the array length and the first page. pageInfoPtr := add(add(publicMemoryPages, 0x20), PAGE_INFO_SIZE_IN_BYTES) } // Register the fact for each task. for (task = 0; task < nTasks; task++) { uint256 curOffset = 0; uint256 firstPageOfTask = curPage; nTreePairs = taskMetadataCopy[taskMetadataOffset + METADATA_OFFSET_TASK_N_TREE_PAIRS]; // Build the Merkle tree using a stack (see the function documentation) to compute // the fact. uint256 nodeStackLen = 0; for (uint256 treePair = 0; treePair < nTreePairs; treePair++) { // Add nPages to the stack of nodes. uint256 nPages = taskMetadataCopy[ taskMetadataOffset + METADATA_TASK_HEADER_SIZE + 2 * treePair + METADATA_OFFSET_TREE_PAIR_N_PAGES ]; // Ensure 'nPages' is bounded from above as a sanity check // (the bound is somewhat arbitrary). require(nPages < 2**20, "Invalid value of n_pages in tree structure."); for (uint256 i = 0; i < nPages; i++) { (uint256 pageSize, uint256 pageHash) = pushPageToStack( pageInfoPtr, curAddr, curOffset, nodeStack, nodeStackLen ); pageHashesLogData[curPage - firstPageOfTask + 3] = pageHash; curPage += 1; nodeStackLen += 1; curAddr += pageSize; curOffset += pageSize; assembly { pageInfoPtr := add(pageInfoPtr, PAGE_INFO_SIZE_IN_BYTES) } } // Pop the top n_nodes, construct a parent node for them, and push it back to the // stack. uint256 nNodes = taskMetadataCopy[ taskMetadataOffset + METADATA_TASK_HEADER_SIZE + 2 * treePair + METADATA_OFFSET_TREE_PAIR_N_NODES ]; if (nNodes != 0) { nodeStackLen = constructNode(nodeStack, nodeStackLen, nNodes); } } require(nodeStackLen == 1, "Node stack must contain exactly one item."); uint256 programHash = taskMetadataCopy[ taskMetadataOffset + METADATA_OFFSET_TASK_PROGRAM_HASH ]; // Verify that the sizes of the pages correspond to the task output, to make // sure that the computed hash is indeed the hash of the entire output of the task. { uint256 outputSize = taskMetadataCopy[ taskMetadataOffset + METADATA_OFFSET_TASK_OUTPUT_SIZE ]; require( nodeStack[NODE_STACK_OFFSET_END] + 2 == outputSize, "The sum of the page sizes does not match output size." ); } uint256 programOutputFact = nodeStack[NODE_STACK_OFFSET_HASH]; bytes32 fact = keccak256(abi.encode(programHash, programOutputFact)); // Update taskMetadataOffset. taskMetadataOffset += METADATA_TASK_HEADER_SIZE + 2 * nTreePairs; { // Log the output Merkle root with the hashes of the relevant memory pages. // Instead of emit, we use log1 https://docs.soliditylang.org/en/v0.4.24/assembly.html, // https://docs.soliditylang.org/en/v0.6.2/abi-spec.html#use-of-dynamic-types. bytes32 logHash = keccak256("LogMemoryPagesHashes(bytes32,bytes32[])"); assembly { let buf := add(pageHashesLogData, 0x20) // Number of memory pages that are relevant for this fact. let length := sub(curPage, firstPageOfTask) mstore(buf, programOutputFact) mstore(add(buf, 0x40), length) log1(buf, mul(add(length, 3), 0x20), logHash) } } registerFact(fact); // Move curAddr to the output of the next task (skipping the size and hash fields). curAddr += 2; } require(totalNumPages == curPage, "Not all memory pages were processed."); } /* Push one page (curPage) to the top of the node stack. curAddr is the memory address, curOffset is the offset from the beginning of the task output. Verifies that the page has the right start address and returns the page size and the page hash. */ function pushPageToStack( uint256[PAGE_INFO_SIZE] memory pageInfoPtr, uint256 curAddr, uint256 curOffset, uint256[] memory nodeStack, uint256 nodeStackLen ) private pure returns (uint256 pageSize, uint256 pageHash) { // Read the first address, page size and hash. uint256 pageAddr = pageInfoPtr[PAGE_INFO_ADDRESS_OFFSET]; pageSize = pageInfoPtr[PAGE_INFO_SIZE_OFFSET]; pageHash = pageInfoPtr[PAGE_INFO_HASH_OFFSET]; // Ensure 'pageSize' is bounded as a sanity check (the bound is somewhat arbitrary). require(pageSize < 2**30, "Invalid page size."); require(pageAddr == curAddr, "Invalid page address."); nodeStack[NODE_STACK_ITEM_SIZE * nodeStackLen + NODE_STACK_OFFSET_END] = curOffset + pageSize; nodeStack[NODE_STACK_ITEM_SIZE * nodeStackLen + NODE_STACK_OFFSET_HASH] = pageHash; } /* Pops the top nNodes nodes from the stack and pushes one parent node instead. Returns the new value of nodeStackLen. */ function constructNode( uint256[] memory nodeStack, uint256 nodeStackLen, uint256 nNodes ) private pure returns (uint256) { require(nNodes <= nodeStackLen, "Invalid value of n_nodes in tree structure."); // The end of the node is the end of the last child. uint256 newNodeEnd = nodeStack[ NODE_STACK_ITEM_SIZE * (nodeStackLen - 1) + NODE_STACK_OFFSET_END ]; uint256 newStackLen = nodeStackLen - nNodes; // Compute node hash. uint256 nodeStart = 0x20 + newStackLen * NODE_STACK_ITEM_SIZE * 0x20; uint256 newNodeHash; assembly { newNodeHash := keccak256( add(nodeStack, nodeStart), mul( nNodes, // NODE_STACK_ITEM_SIZE * 0x20 = 0x40 ) ) } nodeStack[NODE_STACK_ITEM_SIZE * newStackLen + NODE_STACK_OFFSET_END] = newNodeEnd; // Add one to the new node hash to distinguish it from the hash of a leaf (a page). nodeStack[NODE_STACK_ITEM_SIZE * newStackLen + NODE_STACK_OFFSET_HASH] = newNodeHash + 1; return newStackLen + 1; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity >=0.6.12; /* The Fact Registry design pattern is a way to separate cryptographic verification from the business logic of the contract flow. A fact registry holds a hash table of verified "facts" which are represented by a hash of claims that the registry hash check and found valid. This table may be queried by accessing the isValid() function of the registry with a given hash. In addition, each fact registry exposes a registry specific function for submitting new claims together with their proofs. The information submitted varies from one registry to the other depending of the type of fact requiring verification. For further reading on the Fact Registry design pattern see this `StarkWare blog post <https://medium.com/starkware/the-fact-registry-a64aafb598b6>`_. */ interface IFactRegistry { /* Returns true if the given fact was previously registered in the contract. */ function isValid(bytes32 fact) external view returns (bool); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; struct MemoryPageEntry { uint256 startAddr; uint256[] values; uint256 z; uint256 alpha; uint256 prime; } interface IMemoryPageRegistry { function registerContinuousMemoryPage( uint256 startAddr, uint256[] memory values, uint256 z, uint256 alpha, uint256 prime ) external returns ( bytes32, uint256, uint256 ); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "./IFactRegistry.sol"; /* Extends the IFactRegistry interface with a query method that indicates whether the fact registry has successfully registered any fact or is still empty of such facts. */ interface IQueryableFactRegistry is IFactRegistry { /* Returns true if at least one fact has been registered. */ function hasRegisteredFact() external view returns (bool); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity >=0.6.12; interface Identity { /* Allows a caller to ensure that the provided address is of the expected type and version. */ function identify() external pure returns (string memory); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "./IMemoryPageRegistry.sol"; import "../../components/FactRegistry.sol"; contract MemoryPageFactRegistryConstants { // A page based on a list of pairs (address, value). // In this case, memoryHash = hash(address, value, address, value, address, value, ...). uint256 internal constant REGULAR_PAGE = 0; // A page based on adjacent memory cells, starting from a given address. // In this case, memoryHash = hash(value, value, value, ...). uint256 internal constant CONTINUOUS_PAGE = 1; } /* A fact registry for the claim: I know n pairs (addr, value) for which the hash of the pairs is memoryHash, and the cumulative product: \prod_i( z - (addr_i + alpha * value_i) ) is prod. The exact format of the hash depends on the type of the page (see MemoryPageFactRegistryConstants). The fact consists of (pageType, prime, n, z, alpha, prod, memoryHash, address). Note that address is only available for CONTINUOUS_PAGE, and otherwise it is 0. */ contract MemoryPageFactRegistry is FactRegistry, MemoryPageFactRegistryConstants, IMemoryPageRegistry { event LogMemoryPageFactRegular(bytes32 factHash, uint256 memoryHash, uint256 prod); event LogMemoryPageFactContinuous(bytes32 factHash, uint256 memoryHash, uint256 prod); /* Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE). */ function registerRegularMemoryPage( uint256[] calldata memoryPairs, uint256 z, uint256 alpha, uint256 prime ) external returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { // Ensure 'memoryPairs.length' is bounded as a sanity check (the bound is somewhat arbitrary). require(memoryPairs.length < 2**20, "Too many memory values."); require(memoryPairs.length % 2 == 0, "Size of memoryPairs must be even."); require(z < prime, "Invalid value of z."); require(alpha < prime, "Invalid value of alpha."); (factHash, memoryHash, prod) = computeFactHash(memoryPairs, z, alpha, prime); emit LogMemoryPageFactRegular(factHash, memoryHash, prod); registerFact(factHash); } function computeFactHash( uint256[] memory memoryPairs, uint256 z, uint256 alpha, uint256 prime ) private pure returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { uint256 memorySize = memoryPairs.length / 2; // NOLINT: divide-before-multiply. prod = 1; assembly { let memoryPtr := add(memoryPairs, 0x20) // Each value of memoryPairs is a pair: (address, value). let lastPtr := add(memoryPtr, mul(memorySize, 0x40)) for { let ptr := memoryPtr } lt(ptr, lastPtr) { ptr := add(ptr, 0x40) } { // Compute address + alpha * value. let address_value_lin_comb := addmod( // address= mload(ptr), mulmod( // value= mload(add(ptr, 0x20)), alpha, prime ), prime ) prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime) } memoryHash := keccak256( memoryPtr, mul( // 0x20 * 2. 0x40, memorySize ) ) } factHash = keccak256( abi.encodePacked( REGULAR_PAGE, prime, memorySize, z, alpha, prod, memoryHash, uint256(0) ) ); } /* Receives a list of MemoryPageEntry. Each element in the list holds arguments for a seperate call to registerContinuousMemoryPage. */ function registerContinuousPageBatch(MemoryPageEntry[] calldata memoryPageEntries) external { for (uint256 i = 0; i < memoryPageEntries.length; i++) { registerContinuousMemoryPage( memoryPageEntries[i].startAddr, memoryPageEntries[i].values, memoryPageEntries[i].z, memoryPageEntries[i].alpha, memoryPageEntries[i].prime ); } } /* Registers a fact based on the given values, assuming continuous addresses. values should be [value at startAddr, value at (startAddr + 1), ...]. */ function registerContinuousMemoryPage( // NOLINT: external-function. uint256 startAddr, uint256[] memory values, uint256 z, uint256 alpha, uint256 prime ) public override returns ( bytes32 factHash, uint256 memoryHash, uint256 prod ) { require(values.length < 2**20, "Too many memory values."); require(prime < 2**254, "prime is too big for the optimizations in this function."); require(z < prime, "Invalid value of z."); require(alpha < prime, "Invalid value of alpha."); // Ensure 'startAddr' less then prime and bounded as a sanity check (the bound is somewhat arbitrary). require((startAddr < prime) && (startAddr < 2**64), "Invalid value of startAddr."); uint256 nValues = values.length; assembly { // Initialize prod to 1. prod := 1 // Initialize valuesPtr to point to the first value in the array. let valuesPtr := add(values, 0x20) let minus_z := mod(sub(prime, z), prime) // Start by processing full batches of 8 cells, addr represents the last address in each // batch. let addr := add(startAddr, 7) let lastAddr := add(startAddr, nValues) for { } lt(addr, lastAddr) { addr := add(addr, 8) } { // Compute the product of (lin_comb - z) instead of (z - lin_comb), since we're // doing an even number of iterations, the result is the same. prod := mulmod( prod, mulmod( add(add(sub(addr, 7), mulmod(mload(valuesPtr), alpha, prime)), minus_z), add( add(sub(addr, 6), mulmod(mload(add(valuesPtr, 0x20)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 5), mulmod(mload(add(valuesPtr, 0x40)), alpha, prime)), minus_z ), add( add(sub(addr, 4), mulmod(mload(add(valuesPtr, 0x60)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 3), mulmod(mload(add(valuesPtr, 0x80)), alpha, prime)), minus_z ), add( add(sub(addr, 2), mulmod(mload(add(valuesPtr, 0xa0)), alpha, prime)), minus_z ), prime ), prime ) prod := mulmod( prod, mulmod( add( add(sub(addr, 1), mulmod(mload(add(valuesPtr, 0xc0)), alpha, prime)), minus_z ), add(add(addr, mulmod(mload(add(valuesPtr, 0xe0)), alpha, prime)), minus_z), prime ), prime ) valuesPtr := add(valuesPtr, 0x100) } // Handle leftover. // Translate addr to the beginning of the last incomplete batch. addr := sub(addr, 7) for { } lt(addr, lastAddr) { addr := add(addr, 1) } { let address_value_lin_comb := addmod( addr, mulmod(mload(valuesPtr), alpha, prime), prime ) prod := mulmod(prod, add(z, sub(prime, address_value_lin_comb)), prime) valuesPtr := add(valuesPtr, 0x20) } memoryHash := keccak256(add(values, 0x20), mul(0x20, nValues)) } factHash = keccak256( abi.encodePacked(CONTINUOUS_PAGE, prime, nValues, z, alpha, prod, memoryHash, startAddr) ); emit LogMemoryPageFactContinuous(factHash, memoryHash, prod); registerFact(factHash); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; contract PageInfo { uint256 public constant PAGE_INFO_SIZE = 3; // PAGE_INFO_SIZE_IN_BYTES cannot reference PAGE_INFO_SIZE as only direct constants are // supported in assembly. uint256 public constant PAGE_INFO_SIZE_IN_BYTES = 3 * 32; uint256 public constant PAGE_INFO_ADDRESS_OFFSET = 0; uint256 public constant PAGE_INFO_SIZE_OFFSET = 1; uint256 public constant PAGE_INFO_HASH_OFFSET = 2; // A regular page entry is a (address, value) pair stored as 2 uint256 words. uint256 internal constant MEMORY_PAIR_SIZE = 2; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; contract PrimeFieldElement0 { uint256 internal constant K_MODULUS = 0x800000000000011000000000000000000000000000000000000000000000001; uint256 internal constant K_MONTGOMERY_R = 0x7fffffffffffdf0ffffffffffffffffffffffffffffffffffffffffffffffe1; uint256 internal constant K_MONTGOMERY_R_INV = 0x40000000000001100000000000012100000000000000000000000000000000; uint256 internal constant GENERATOR_VAL = 3; uint256 internal constant ONE_VAL = 1; function fromMontgomery(uint256 val) internal pure returns (uint256 res) { // uint256 res = fmul(val, kMontgomeryRInv); assembly { res := mulmod(val, K_MONTGOMERY_R_INV, K_MODULUS) } return res; } function fromMontgomeryBytes(bytes32 bs) internal pure returns (uint256) { // Assuming bs is a 256bit bytes object, in Montgomery form, it is read into a field // element. uint256 res = uint256(bs); return fromMontgomery(res); } function toMontgomeryInt(uint256 val) internal pure returns (uint256 res) { //uint256 res = fmul(val, kMontgomeryR); assembly { res := mulmod(val, K_MONTGOMERY_R, K_MODULUS) } return res; } function fmul(uint256 a, uint256 b) internal pure returns (uint256 res) { //uint256 res = mulmod(a, b, kModulus); assembly { res := mulmod(a, b, K_MODULUS) } return res; } function fadd(uint256 a, uint256 b) internal pure returns (uint256 res) { // uint256 res = addmod(a, b, kModulus); assembly { res := addmod(a, b, K_MODULUS) } return res; } function fsub(uint256 a, uint256 b) internal pure returns (uint256 res) { // uint256 res = addmod(a, kModulus - b, kModulus); assembly { res := addmod(a, sub(K_MODULUS, b), K_MODULUS) } return res; } function fpow(uint256 val, uint256 exp) internal view returns (uint256) { return expmod(val, exp, K_MODULUS); } function expmod( uint256 base, uint256 exponent, uint256 modulus ) private view returns (uint256 res) { assembly { let p := mload(0x40) mstore(p, 0x20) // Length of Base. mstore(add(p, 0x20), 0x20) // Length of Exponent. mstore(add(p, 0x40), 0x20) // Length of Modulus. mstore(add(p, 0x60), base) // Base. mstore(add(p, 0x80), exponent) // Exponent. mstore(add(p, 0xa0), modulus) // Modulus. // Call modexp precompile. if iszero(staticcall(gas(), 0x05, p, 0xc0, p, 0x20)) { revert(0, 0) } res := mload(p) } } function inverse(uint256 val) internal view returns (uint256) { return expmod(val, K_MODULUS - 2, K_MODULUS); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "./FactRegistry.sol"; import "../libraries/Addresses.sol"; /* ReferableFactRegistry extends FactRegistry, so that it can be deployed with a reference FactRegistry. The reference FactRegistry is used as a secondary fact registry. When the contract is queried for fact validity using isValid(), if the queried fact is not in the local fact registry, the call is passed to the reference. The reference FactRegistry is active only for a pre-defined duration (in seconds). After that duration expires, the reference FactRegistry can not be queried anymore. */ contract ReferableFactRegistry is FactRegistry { IFactRegistry public referenceFactRegistry; uint256 public referralExpirationTime; using Addresses for address; constructor(address refFactRegistry, uint256 referralDurationSeconds) public { // Allow 0 address, i.e. no referral. if (refFactRegistry != address(0)) { referenceFactRegistry = IFactRegistry(refFactRegistry); // NOLINTNEXTLINE: no-block-members. referralExpirationTime = block.timestamp + referralDurationSeconds; require(referralExpirationTime >= block.timestamp, "DURATION_WRAP_AROUND"); require(refFactRegistry.isContract(), "REFERENCE_NOT_CONTRACT"); require(refFactRegistry != address(this), "SELF_ASSIGNMENT"); // NOLINTNEXTLINE: reentrancy-benign no-low-level-calls. (bool success, ) = refFactRegistry.staticcall( abi.encodeWithSelector( IFactRegistry(refFactRegistry).isValid.selector, bytes32(0x0) ) ); require(success, "REFERENCE_NOT_FACT_REGISTRY"); } } /* Checks if a fact was registered. */ function isValid(bytes32 fact) external view virtual override returns (bool) { if (internalIsValid(fact)) { return true; } return isValidOnReference(fact); } /* Checks if the fact is stored in the local fact registry. */ function localIsValid(bytes32 fact) external view returns (bool) { return internalIsValid(fact); } function isReferralActive() internal view returns (bool) { // solium-disable-next-line security/no-block-members return block.timestamp < referralExpirationTime; } /* Checks if a fact has been verified by the reference IFactRegistry. */ function isValidOnReference(bytes32 fact) internal view returns (bool) { if (!isReferralActive()) { return false; } return referenceFactRegistry.isValid(fact); } }
{ "metadata": { "useLiteralContent": true }, "libraries": {}, "remappings": [], "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"bootloaderProgramContract","type":"address"},{"internalType":"address","name":"memoryPageFactRegistry_","type":"address"},{"internalType":"address[]","name":"cairoVerifierContracts","type":"address[]"},{"internalType":"uint256","name":"simpleBootloaderProgramHash","type":"uint256"},{"internalType":"uint256","name":"applicativeBootloaderProgramHash","type":"uint256"},{"internalType":"uint256","name":"hashedSupportedCairoVerifiers","type":"uint256"},{"internalType":"address","name":"referenceVerifier","type":"address"},{"internalType":"uint256","name":"referralDurationSeconds","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"programOutputFact","type":"bytes32"},{"indexed":false,"internalType":"bytes32[]","name":"pagesHashes","type":"bytes32[]"}],"name":"LogMemoryPagesHashes","type":"event"},{"inputs":[],"name":"PAGE_INFO_ADDRESS_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAGE_INFO_HASH_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAGE_INFO_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAGE_INFO_SIZE_IN_BYTES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAGE_INFO_SIZE_OFFSET","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBootloaderConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasRegisteredFact","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"identify","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"fact","type":"bytes32"}],"name":"isValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"fact","type":"bytes32"}],"name":"localIsValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referenceFactRegistry","outputs":[{"internalType":"contract IFactRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralExpirationTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"proofParams","type":"uint256[]"},{"internalType":"uint256[]","name":"proof","type":"uint256[]"},{"internalType":"uint256[]","name":"taskMetadata","type":"uint256[]"},{"internalType":"uint256[]","name":"cairoAuxInput","type":"uint256[]"},{"internalType":"uint256","name":"cairoVerifierId","type":"uint256"}],"name":"verifyProofAndRegister","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100df5760003560e01c806361363e4e1161008c578063b7a771f711610066578063b7a771f714610323578063d6354e151461032b578063e5b62b2914610333578063eeb728661461033b576100df565b806361363e4e1461016d5780636a9385671461019e5780639b3b76cc146101bb576100df565b80632f4da80e116100bd5780632f4da80e146101375780634c14a6f91461015d5780635b4c41c214610165576100df565b80630301a2c3146100e457806329e10520146101155780632b3380611461012f575b600080fd5b6100ec6103b8565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61011d6103d9565b60408051918252519081900360200190f35b61011d6103de565b61013f6103e4565b60408051938452602084019290925282820152519081900360600190f35b61011d61044c565b61011d610451565b61018a6004803603602081101561018357600080fd5b5035610456565b604080519115158252519081900360200190f35b61018a600480360360208110156101b457600080fd5b5035610469565b610321600480360360a08110156101d157600080fd5b8101906020810181356401000000008111156101ec57600080fd5b8201836020820111156101fe57600080fd5b8035906020019184602083028401116401000000008311171561022057600080fd5b91939092909160208101903564010000000081111561023e57600080fd5b82018360208201111561025057600080fd5b8035906020019184602083028401116401000000008311171561027257600080fd5b91939092909160208101903564010000000081111561029057600080fd5b8201836020820111156102a257600080fd5b803590602001918460208302840111640100000000831117156102c457600080fd5b9193909290916020810190356401000000008111156102e257600080fd5b8201836020820111156102f457600080fd5b8035906020019184602083028401116401000000008311171561031657600080fd5b91935091503561048a565b005b61011d610a69565b61018a610a6e565b61011d610a77565b610343610a7c565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561037d578181015183820152602001610365565b50505050905090810190601f1680156103aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600154610100900473ffffffffffffffffffffffffffffffffffffffff1681565b600281565b60025481565b7f005ab580b04e3532b6b18f81cfa654a05e29dd8e2352d88df1e765a84072db077f02710558d1139041e1f6af4507603e4357f60ee6838a85f8814baa46aca4b1d37f022f3bd2fd7a5a131199e56a7e39a430cc287ed3df600a8288f90c1932a5e62e909192565b600381565b600181565b600061046182610aa2565b90505b919050565b600061047482610aa2565b1561048157506001610464565b61046182610ab7565b60055481106104fa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f636169726f56657269666965724964206973206f7574206f662072616e67652e604482015290519081900360640190fd5b60006005828154811061050957fe5b600091825260208220015473ffffffffffffffffffffffffffffffffffffffff169150369061055c7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe8601828789611d9d565b9150915060606000808573ffffffffffffffffffffffffffffffffffffffff16638080fdfb6040518163ffffffff1660e01b8152600401604080518083038186803b1580156105aa57600080fd5b505afa1580156105be573d6000803e3d6000fd5b505050506040513d60408110156105d457600080fd5b508051602090910151909250905081881161065057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f496e76616c696420636169726f417578496e707574206c656e6774682e000000604482015290519081900360640190fd5b61065c84838188611d9d565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052508451949750938793508492501515905061069f57fe5b60200260200101519050612710811061071957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f496e76616c6964206e50616765732e0000000000000000000000000000000000604482015290519081900360640190fd5b83516004820214610775576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611df26021913960400191505060405180910390fd5b60008060006107878f8f8f8f89610b70565b925092509250828760018151811061079b57fe5b60200260200101511461080f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e76616c69642073697a6520666f72206d656d6f7279207061676520302e00604482015290519081900360640190fd5b818760028151811061081d57fe5b60200260200101511461089157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e76616c6964206861736820666f72206d656d6f7279207061676520302e00604482015290519081900360640190fd5b808760038602815181106108a157fe5b6020026020010151146108ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180611e8b602d913960400191505060405180910390fd5b5050505050508373ffffffffffffffffffffffffffffffffffffffff16631cb7dd798e8e8e8e88886040518763ffffffff1660e01b81526004018080602001806020018060200184810384528a8a82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018581038452888152602090810191508990890280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169091018581038352868152602090810191508790870280828437600081840152601f19601f8201169050808301925050509950505050505050505050600060405180830381600087803b158015610a2357600080fd5b505af1158015610a37573d6000803e3d6000fd5b50505050610a5a8989838a8a6009818110610a4e57fe5b9050602002013561161e565b50505050505050505050505050565b606081565b60015460ff1690565b600081565b6060604051806060016040528060268152602001611f5f60269139905090565b3b151590565b60009081526020819052604090205460ff1690565b6000610ac1611ac4565b610acd57506000610464565b60018054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636a938567836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b3e57600080fd5b505afa158015610b52573d6000803e3d6000fd5b505050506040513d6020811015610b6857600080fd5b505192915050565b60008060008088886000818110610b8357fe5b90506020020135905063400000008110610bfe57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964206e756d626572206f66207461736b732e0000000000000000604482015290519081900360640190fd5b6002818102610336019450606090850267ffffffffffffffff81118015610c2457600080fd5b50604051908082528060200260200182016040528015610c4e578160200160208202803683370190505b5090506000610c5b611d5f565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634b6cee596040518163ffffffff1660e01b81526004016163406040518083038186803b158015610cc457600080fd5b505afa158015610cd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250616340811015610cfe57600080fd5b50905060005b61031a811015610d655760018101848481518110610d1e57fe5b602002602001018181525050818161031a8110610d3757fe5b6020020151848460010181518110610d4b57fe5b602090810291909101015260029290920191600101610d04565b5050600089896007818110610d7657fe5b9050602002013590506002811015610def57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f496e76616c696420657865637574696f6e20626567696e20616464726573732e604482015290519081900360640190fd5b60028103838360000181518110610e0257fe5b60200260200101818152505080838360010181518110610e1e57fe5b60200260200101818152505060018103838360020181518110610e3d57fe5b6020026020010181815250506000838360030181518110610e5a57fe5b6020026020010181815250506004820191506000600b8b8b6008818110610e7d57fe5b9050602002013503905060006009905060005b600b811015610f9757808401868681518110610ea857fe5b60209081029190910101528551601686019084830190889083908110610eca57fe5b602090810291909101015260018c1615610f48578d8d84818110610eea57fe5b90506020020135878760010181518110610f0057fe5b6020026020010181815250508d8d84600101818110610f1b57fe5b90506020020135878260010181518110610f3157fe5b602002602001018181525050600283019250610f83565b6000878760010181518110610f5957fe5b6020026020010181815250506000878260010181518110610f7657fe5b6020026020010181815250505b5060019a8b1c9a6002959095019401610e90565b508915610fef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611e676024913960400191505060405180910390fd5b50505060160160008989600981811061100457fe5b9050602002013590508083836000018151811061101d57fe5b6020026020010181815250507f005ab580b04e3532b6b18f81cfa654a05e29dd8e2352d88df1e765a84072db0783836001018151811061105957fe5b6020026020010181815250508060010183836002018151811061107857fe5b6020026020010181815250507f02710558d1139041e1f6af4507603e4357f60ee6838a85f8814baa46aca4b1d38383600301815181106110b457fe5b602002602001018181525050806002018383600401815181106110d357fe5b6020026020010181815250507f022f3bd2fd7a5a131199e56a7e39a430cc287ed3df600a8288f90c1932a5e62e83836005018151811061110f57fe5b6020026020010181815250508060030183836006018151811061112e57fe5b6020026020010181815250508383836007018151811061114a57fe5b6020026020010181815250506008820191506004810190503660008d8d600190809261117893929190611d9d565b9150915060005b868110156113595760008383600081811061119657fe5b905060200201359050806002111580156111b35750634000000081105b61121e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496e76616c6964207461736b206f75747075742073697a652e00000000000000604482015290519081900360640190fd5b60008484600181811061122d57fe5b90506020020135905060008585600281811061124557fe5b9050602002013590508060011115801561126157506210000081105b6112b6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180611f856035913960400191505060405180910390fd5b868989600001815181106112c657fe5b602002602001018181525050828989600101815181106112e257fe5b6020026020010181815250508660010189896002018151811061130157fe5b6020026020010181815250508189896003018151811061131d57fe5b6020908102919091010152600497909701969582019561134585600360028402018189611d9d565b95509550505050808060010191505061117f565b5080156113c757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e76616c6964206c656e677468206f66207461736b4d657461646174612e00604482015290519081900360640190fd5b828c8c600a8181106113d557fe5b9050602002013514611432576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611eb86023913960400191505060405180910390fd5b5050508082511461148e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611dc96029913960400191505060405180910390fd5b600089897ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe81018181106114be57fe5b90506020020135905060008a8a60018d8d9050038181106114db57fe5b9050602002013590506000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663405a63628685857f08000000000000110000000000000000000000000000000000000000000000016040518563ffffffff1660e01b81526004018080602001858152602001848152602001838152602001828103825286818151815260200191508051906020019060200280838360005b838110156115a9578181015183820152602001611591565b5050505090500195505050505050606060405180830381600087803b1580156115d157600080fd5b505af11580156115e5573d6000803e3d6000fd5b505050506040513d60608110156115fb57600080fd5b506020810151604090910151999f909e50989c50979a5050505050505050505050565b60008260008151811061162d57fe5b6020026020010151905060008060008787600081811061164957fe5b90506020020135905060608460030167ffffffffffffffff8111801561166e57600080fd5b50604051908082528060200260200182016040528015611698578160200160208202803683370190505b5090506040816001815181106116aa57fe5b60209081029190910101526001600687018160606002890267ffffffffffffffff811180156116d857600080fd5b50604051908082528060200260200182016040528015611702578160200160208202803683370190505b50905060608d8d808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509293506117479250611d7f915050565b506000985060808c015b878a1015611a5b5760008085905083600289018151811061176e57fe5b60200260200101519a506000805b8c8110156118a15760008660008360020260038e0101018151811061179d57fe5b60200260200101519050621000008110611802576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180611eff602b913960400191505060405180910390fd5b60005b8181101561185d5760008061181d898e8a8e8a611acc565b91509150808f888e036003018151811061183357fe5b6020908102919091010152509a8b019a60019a8b019a606098909801979601959384019301611805565b5060008760018460020260038f0101018151811061187757fe5b602002602001015190508060001461189757611894898583611c05565b93505b505060010161177c565b50806001146118fb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611e136029913960400191505060405180910390fd5b60008560018b018151811061190c57fe5b6020026020010151905060008660008c018151811061192757fe5b60200260200101519050808860018151811061193f57fe5b6020026020010151600201146119a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180611f2a6035913960400191505060405180910390fd5b506000876000815181106119b057fe5b602002602001015190506000828260405160200180838152602001828152602001925050506040516020818303038152906040528051906020012090508e6002026003018c019b5060007f73b132cb33951232d83dc0f1f81c2d10f9a2598f057404ed02756716092097bb905060208e01868c03848252806040830152826020600383010283a1505050611a4381611cef565b50506001909d019c5050506002959095019450611751565b838b14611ab3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611edb6024913960400191505060405180910390fd5b505050505050505050505050505050565b600254421090565b845160208601516040870151909163400000008310611b4c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420706167652073697a652e0000000000000000000000000000604482015290519081900360640190fd5b868114611bba57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f496e76616c6964207061676520616464726573732e0000000000000000000000604482015290519081900360640190fd5b828601856001866002020181518110611bcf57fe5b60200260200101818152505081856000866002020181518110611bee57fe5b602002602001018181525050509550959350505050565b600082821115611c60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180611e3c602b913960400191505060405180910390fd5b60008460018086036002020181518110611c7657fe5b6020026020010151905060008385039050600060028202602002602001905060006040860282890120905083886001856002020181518110611cb457fe5b60200260200101818152505080600101886000856002020181518110611cd657fe5b6020908102919091010152505060010195945050505050565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091555460ff16611d5c57600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790555b50565b60405180616340016040528061031a906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60008085851115611dac578182fd5b83861115611db8578182fd5b505060208302019391909203915056fe4e6f7420616c6c20436169726f207075626c696320696e707574732077657265207772697474656e2e496e76616c6964207075626c69634d656d6f72795061676573206c656e6774682e4e6f646520737461636b206d75737420636f6e7461696e2065786163746c79206f6e65206974656d2e496e76616c69642076616c7565206f66206e5f6e6f64657320696e2074726565207374727563747572652e53454c45435445445f4255494c54494e535f564543544f525f49535f544f4f5f4c4f4e47496e76616c69642063756d756c61746976652070726f6475637420666f72206d656d6f7279207061676520302e496e636f6e73697374656e742070726f6772616d206f7574707574206c656e6774682e4e6f7420616c6c206d656d6f727920706167657320776572652070726f6365737365642e496e76616c69642076616c7565206f66206e5f706167657320696e2074726565207374727563747572652e5468652073756d206f662074686520706167652073697a657320646f6573206e6f74206d61746368206f75747075742073697a652e537461726b576172655f47707353746174656d656e7456657269666965725f323032345f3130496e76616c6964206e756d626572206f6620706169727320696e20746865204d65726b6c652074726565207374727563747572652ea26469706673582212204b6d8d8163ccf303a2c261f48a20ce8def4b3ea1b55ef948a1cf12713e08774064736f6c634300060c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.