ETH Price: $2,483.06 (+1.79%)

Contract

0xe74999fBc71455462C8143b56797D3Bb84C1064b
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0142435587
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0156278187
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0200164387
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0221065287
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0241918287
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0263130687
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.028405587
Verify FRI131309752021-08-31 3:40:251138 days ago1630381225IN
ImmutableX: FRI Statement
0 ETH0.0305078587
Verify FRI131257062021-08-30 8:08:271139 days ago1630310907IN
ImmutableX: FRI Statement
0 ETH0.0101028663
Verify FRI131257062021-08-30 8:08:271139 days ago1630310907IN
ImmutableX: FRI Statement
0 ETH0.013251663
Verify FRI131257062021-08-30 8:08:271139 days ago1630310907IN
ImmutableX: FRI Statement
0 ETH0.014555862
Verify FRI131257062021-08-30 8:08:271139 days ago1630310907IN
ImmutableX: FRI Statement
0 ETH0.0160416362
Verify FRI131257052021-08-30 8:08:231139 days ago1630310903IN
ImmutableX: FRI Statement
0 ETH0.0178339163
Verify FRI131256972021-08-30 8:06:121139 days ago1630310772IN
ImmutableX: FRI Statement
0 ETH0.0212862569.3
Verify FRI131256952021-08-30 8:05:431139 days ago1630310743IN
ImmutableX: FRI Statement
0 ETH0.020858163
Verify FRI131256952021-08-30 8:05:431139 days ago1630310743IN
ImmutableX: FRI Statement
0 ETH0.0220305262
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0072469845
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0079683345
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0102317845
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0113112445
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0123957445
Verify FRI131201672021-08-29 11:39:371140 days ago1630237177IN
ImmutableX: FRI Statement
0 ETH0.0134826745
Verify FRI131201622021-08-29 11:38:141140 days ago1630237094IN
ImmutableX: FRI Statement
0 ETH0.0174520153.9
Verify FRI131201572021-08-29 11:37:461140 days ago1630237066IN
ImmutableX: FRI Statement
0 ETH0.0183685352.8
Verify FRI131155082021-08-28 18:24:281141 days ago1630175068IN
ImmutableX: FRI Statement
0 ETH0.0125073778
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FriStatementContract

Compiler Version
v0.5.15+commit.6a57276f

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity Multiple files format)

File 1 of 8: FriStatementContract.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

import "FactRegistry.sol";
import "FriLayer.sol";

contract FriStatementContract is FriLayer, FactRegistry {
    /*
      Compute a single FRI layer of size friStepSize at evaluationPoint starting from input
      friQueue, and the extra witnesses in the "proof" channel. Also check that the input and
      witnesses belong to a Merkle tree with root expectedRoot, again using witnesses from "proof".
      After verification, register the FRI fact hash, which is:
      keccak256(
          evaluationPoint,
          friStepSize,
          keccak256(friQueue_input),
          keccak256(friQueue_output),  // The FRI queue after proccessing the FRI layer
          expectedRoot
      )

      Note that this function is used as external, but declared public to avoid copying the arrays.
    */
    function verifyFRI(
        uint256[] memory proof,
        uint256[] memory friQueue,
        uint256 evaluationPoint,
        uint256 friStepSize,
        uint256 expectedRoot) public {

        require (friStepSize <= FRI_MAX_FRI_STEP, "FRI step size too large");
        /*
          The friQueue should have of 3*nQueries + 1 elements, beginning with nQueries triplets
          of the form (query_index, FRI_value, FRI_inverse_point), and ending with a single buffer
          cell set to 0, which is accessed and read during the computation of the FRI layer.
        */
        require (
            friQueue.length % 3 == 1,
            "FRI Queue must be composed of triplets plus one delimiter cell");
        require (friQueue.length >= 4, "No query to process");

        uint256 mmFriCtxSize = FRI_CTX_SIZE;
        uint256 nQueries = friQueue.length / 3;
        friQueue[3*nQueries] = 0;  // NOLINT: divide-before-multiply.
        uint256 merkleQueuePtr;
        uint256 friQueuePtr;
        uint256 channelPtr;
        uint256 friCtx;
        uint256 dataToHash;

        // Verify evaluation point within valid range.
        require(evaluationPoint < K_MODULUS, "INVALID_EVAL_POINT");

        // Queries need to be in the range [2**height .. 2**(height+1)-1] strictly incrementing.
        // i.e. we need to check that Qi+1 > Qi for each i,
        // but regarding the height range - it's sufficient to check that
        // (Q1 ^ Qn) < Q1 Which affirms that all queries are within the same logarithmic step.

        // Verify FRI values and inverses are within valid range.
        // and verify that queries are strictly incrementing.
        uint256 prevQuery = 0; // If we pass height, change to: prevQuery = 1 << height - 1;
        for (uint256 i = 0; i < nQueries; i++) {
            require(friQueue[3*i] > prevQuery, "INVALID_QUERY_VALUE");
            require(friQueue[3*i+1] < K_MODULUS, "INVALID_FRI_VALUE");
            require(friQueue[3*i+2] < K_MODULUS, "INVALID_FRI_INVERSE_POINT");
            prevQuery = friQueue[3*i];
        }

        // Verify all queries are on the same logarithmic step.
        // NOLINTNEXTLINE: divide-before-multiply.
        require((friQueue[0] ^ friQueue[3*nQueries-3]) < friQueue[0], "INVALID_QUERIES_RANGE");

        // Allocate memory queues: channelPtr, merkleQueue, friCtx, dataToHash.
        assembly {
            friQueuePtr := add(friQueue, 0x20)
            channelPtr := mload(0x40) // Free pointer location.
            mstore(channelPtr, add(proof, 0x20))
            merkleQueuePtr := add(channelPtr, 0x20)
            friCtx := add(merkleQueuePtr, mul(0x40, nQueries))
            dataToHash := add(friCtx, mmFriCtxSize)
            mstore(0x40, add(dataToHash, 0xa0)) // Advance free pointer.

            mstore(dataToHash, evaluationPoint)
            mstore(add(dataToHash, 0x20), friStepSize)
            mstore(add(dataToHash, 0x80), expectedRoot)

            // Hash FRI inputs and add to dataToHash.
            mstore(add(dataToHash, 0x40), keccak256(friQueuePtr, mul(0x60, nQueries)))
        }

        initFriGroups(friCtx);

        nQueries = computeNextLayer(
            channelPtr, friQueuePtr, merkleQueuePtr, nQueries, evaluationPoint,
            2**friStepSize, /* friCosetSize = 2**friStepSize */
            friCtx);

        verify(channelPtr, merkleQueuePtr, bytes32(expectedRoot), nQueries);

        bytes32 factHash;
        assembly {
            // Hash FRI outputs and add to dataToHash.
            mstore(add(dataToHash, 0x60), keccak256(friQueuePtr, mul(0x60, nQueries)))
            factHash := keccak256(dataToHash, 0xa0)
        }

        registerFact(factHash);
    }
}

File 2 of 8: FactRegistry.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

import "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;

    /*
      Checks if a fact has been verified.
    */
    function isValid(bytes32 fact)
        external view
        returns(bool)
    {
        return _factCheck(fact);
    }


    /*
      This is an internal method to check if the fact is already registered.
      In current implementation of FactRegistry it's identical to isValid().
      But the check is against the local fact registry,
      So for a derived referral fact registry, it's not the same.
    */
    function _factCheck(bytes32 fact)
        internal view
        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
        returns(bool)
    {
        return anyFactRegistered;
    }

}

File 3 of 8: FriLayer.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

import "MerkleVerifier.sol";
import "PrimeFieldElement0.sol";

/*
  The main component of FRI is the FRI step which takes
  the i-th layer evaluations on a coset c*<g> and produces a single evaluation in layer i+1.

  To this end we have a friCtx that holds the following data:
  evaluations:    holds the evaluations on the coset we are currently working on.
  group:          holds the group <g> in bit reversed order.
  halfInvGroup:   holds the group <g^-1>/<-1> in bit reversed order.
                  (We only need half of the inverse group)

  Note that due to the bit reversed order, a prefix of size 2^k of either group
  or halfInvGroup has the same structure (but for a smaller group).
*/
contract FriLayer is MerkleVerifier, PrimeFieldElement0 {
    event LogGas(string name, uint256 val);

    uint256 constant internal FRI_MAX_FRI_STEP = 4;
    uint256 constant internal MAX_COSET_SIZE = 2**FRI_MAX_FRI_STEP;
    // Generator of the group of size MAX_COSET_SIZE: GENERATOR_VAL**((PRIME - 1)/MAX_COSET_SIZE).
    uint256 constant internal FRI_GROUP_GEN =
    0x5ec467b88826aba4537602d514425f3b0bdf467bbf302458337c45f6021e539;

    uint256 constant internal FRI_GROUP_SIZE = 0x20 * MAX_COSET_SIZE;
    uint256 constant internal FRI_CTX_TO_COSET_EVALUATIONS_OFFSET = 0;
    uint256 constant internal FRI_CTX_TO_FRI_GROUP_OFFSET = FRI_GROUP_SIZE;
    uint256 constant internal FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET =
    FRI_CTX_TO_FRI_GROUP_OFFSET + FRI_GROUP_SIZE;

    uint256 constant internal FRI_CTX_SIZE =
    FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET + (FRI_GROUP_SIZE / 2);

    function nextLayerElementFromTwoPreviousLayerElements(
        uint256 fX, uint256 fMinusX, uint256 evalPoint, uint256 xInv)
        internal pure
        returns (uint256 res)
    {
        // Folding formula:
        // f(x)  = g(x^2) + xh(x^2)
        // f(-x) = g((-x)^2) - xh((-x)^2) = g(x^2) - xh(x^2)
        // =>
        // 2g(x^2) = f(x) + f(-x)
        // 2h(x^2) = (f(x) - f(-x))/x
        // => The 2*interpolation at evalPoint is:
        // 2*(g(x^2) + evalPoint*h(x^2)) = f(x) + f(-x) + evalPoint*(f(x) - f(-x))*xInv.
        //
        // Note that multiplying by 2 doesn't affect the degree,
        // so we can just agree to do that on both the prover and verifier.
        assembly {
            // PRIME is PrimeFieldElement0.K_MODULUS.
            let PRIME := 0x800000000000011000000000000000000000000000000000000000000000001
            // Note that whenever we call add(), the result is always less than 2*PRIME,
            // so there are no overflows.
            res := addmod(add(fX, fMinusX),
                   mulmod(mulmod(evalPoint, xInv, PRIME),
                   add(fX, /*-fMinusX*/sub(PRIME, fMinusX)), PRIME), PRIME)
        }
    }

    /*
      Reads 4 elements, and applies 2 + 1 FRI transformations to obtain a single element.

      FRI layer n:                              f0 f1  f2 f3
      -----------------------------------------  \ / -- \ / -----------
      FRI layer n+1:                              f0    f2
      -------------------------------------------- \ ---/ -------------
      FRI layer n+2:                                 f0

      The basic FRI transformation is described in nextLayerElementFromTwoPreviousLayerElements().
    */
    function do2FriSteps(
        uint256 friHalfInvGroupPtr, uint256 evaluationsOnCosetPtr, uint256 cosetOffset_,
        uint256 friEvalPoint)
    internal pure returns (uint256 nextLayerValue, uint256 nextXInv) {
        assembly {
            let PRIME := 0x800000000000011000000000000000000000000000000000000000000000001
            let friEvalPointDivByX := mulmod(friEvalPoint, cosetOffset_, PRIME)

            let f0 := mload(evaluationsOnCosetPtr)
            {
                let f1 := mload(add(evaluationsOnCosetPtr, 0x20))

                // f0 < 3P ( = 1 + 1 + 1).
                f0 := add(add(f0, f1),
                             mulmod(friEvalPointDivByX,
                                    add(f0, /*-fMinusX*/sub(PRIME, f1)),
                                    PRIME))
            }

            let f2 := mload(add(evaluationsOnCosetPtr, 0x40))
            {
                let f3 := mload(add(evaluationsOnCosetPtr, 0x60))
                f2 := addmod(add(f2, f3),
                             mulmod(add(f2, /*-fMinusX*/sub(PRIME, f3)),
                                    mulmod(mload(add(friHalfInvGroupPtr, 0x20)),
                                           friEvalPointDivByX,
                                           PRIME),
                                    PRIME),
                             PRIME)
            }

            {
                let newXInv := mulmod(cosetOffset_, cosetOffset_, PRIME)
                nextXInv := mulmod(newXInv, newXInv, PRIME)
            }

            // f0 + f2 < 4P ( = 3 + 1).
            nextLayerValue := addmod(add(f0, f2),
                          mulmod(mulmod(friEvalPointDivByX, friEvalPointDivByX, PRIME),
                                 add(f0, /*-fMinusX*/sub(PRIME, f2)),
                                 PRIME),
                          PRIME)
        }
    }

    /*
      Reads 8 elements, and applies 4 + 2 + 1 FRI transformation to obtain a single element.

      See do2FriSteps for more detailed explanation.
    */
    function do3FriSteps(
        uint256 friHalfInvGroupPtr, uint256 evaluationsOnCosetPtr, uint256 cosetOffset_,
        uint256 friEvalPoint)
    internal pure returns (uint256 nextLayerValue, uint256 nextXInv) {
        assembly {
            let PRIME := 0x800000000000011000000000000000000000000000000000000000000000001
            let MPRIME := 0x8000000000000110000000000000000000000000000000000000000000000010
            let f0 := mload(evaluationsOnCosetPtr)

            let friEvalPointDivByX := mulmod(friEvalPoint, cosetOffset_, PRIME)
            let friEvalPointDivByXSquared := mulmod(friEvalPointDivByX, friEvalPointDivByX, PRIME)
            let imaginaryUnit := mload(add(friHalfInvGroupPtr, 0x20))

            {
                let f1 := mload(add(evaluationsOnCosetPtr, 0x20))

                // f0 < 3P ( = 1 + 1 + 1).
                f0 := add(add(f0, f1),
                          mulmod(friEvalPointDivByX,
                                 add(f0, /*-fMinusX*/sub(PRIME, f1)),
                                 PRIME))
            }
            {
                let f2 := mload(add(evaluationsOnCosetPtr, 0x40))
                {
                    let f3 := mload(add(evaluationsOnCosetPtr, 0x60))

                    // f2 < 3P ( = 1 + 1 + 1).
                    f2 := add(add(f2, f3),
                              mulmod(add(f2, /*-fMinusX*/sub(PRIME, f3)),
                                     mulmod(friEvalPointDivByX, imaginaryUnit, PRIME),
                                     PRIME))
                }

                // f0 < 7P ( = 3 + 3 + 1).
                f0 := add(add(f0, f2),
                          mulmod(friEvalPointDivByXSquared,
                                 add(f0, /*-fMinusX*/sub(MPRIME, f2)),
                                 PRIME))
            }
            {
                let f4 := mload(add(evaluationsOnCosetPtr, 0x80))
                {
                    let friEvalPointDivByX2 := mulmod(friEvalPointDivByX,
                                                    mload(add(friHalfInvGroupPtr, 0x40)), PRIME)
                    {
                        let f5 := mload(add(evaluationsOnCosetPtr, 0xa0))

                        // f4 < 3P ( = 1 + 1 + 1).
                        f4 := add(add(f4, f5),
                                  mulmod(friEvalPointDivByX2,
                                         add(f4, /*-fMinusX*/sub(PRIME, f5)),
                                         PRIME))
                    }

                    let f6 := mload(add(evaluationsOnCosetPtr, 0xc0))
                    {
                        let f7 := mload(add(evaluationsOnCosetPtr, 0xe0))

                        // f6 < 3P ( = 1 + 1 + 1).
                        f6 := add(add(f6, f7),
                                  mulmod(add(f6, /*-fMinusX*/sub(PRIME, f7)),
                                         // friEvalPointDivByX2 * imaginaryUnit ==
                                         // friEvalPointDivByX * mload(add(friHalfInvGroupPtr, 0x60)).
                                         mulmod(friEvalPointDivByX2, imaginaryUnit, PRIME),
                                         PRIME))
                    }

                    // f4 < 7P ( = 3 + 3 + 1).
                    f4 := add(add(f4, f6),
                              mulmod(mulmod(friEvalPointDivByX2, friEvalPointDivByX2, PRIME),
                                     add(f4, /*-fMinusX*/sub(MPRIME, f6)),
                                     PRIME))
                }

                // f0, f4 < 7P -> f0 + f4 < 14P && 9P < f0 + (MPRIME - f4) < 23P.
                nextLayerValue :=
                   addmod(add(f0, f4),
                          mulmod(mulmod(friEvalPointDivByXSquared, friEvalPointDivByXSquared, PRIME),
                                 add(f0, /*-fMinusX*/sub(MPRIME, f4)),
                                 PRIME),
                          PRIME)
            }

            {
                let xInv2 := mulmod(cosetOffset_, cosetOffset_, PRIME)
                let xInv4 := mulmod(xInv2, xInv2, PRIME)
                nextXInv := mulmod(xInv4, xInv4, PRIME)
            }


        }
    }

    /*
      This function reads 16 elements, and applies 8 + 4 + 2 + 1 fri transformation
      to obtain a single element.

      See do2FriSteps for more detailed explanation.
    */
    function do4FriSteps(
        uint256 friHalfInvGroupPtr, uint256 evaluationsOnCosetPtr, uint256 cosetOffset_,
        uint256 friEvalPoint)
    internal pure returns (uint256 nextLayerValue, uint256 nextXInv) {
        assembly {
            let friEvalPointDivByXTessed
            let PRIME := 0x800000000000011000000000000000000000000000000000000000000000001
            let MPRIME := 0x8000000000000110000000000000000000000000000000000000000000000010
            let f0 := mload(evaluationsOnCosetPtr)

            let friEvalPointDivByX := mulmod(friEvalPoint, cosetOffset_, PRIME)
            let imaginaryUnit := mload(add(friHalfInvGroupPtr, 0x20))

            {
                let f1 := mload(add(evaluationsOnCosetPtr, 0x20))

                // f0 < 3P ( = 1 + 1 + 1).
                f0 := add(add(f0, f1),
                          mulmod(friEvalPointDivByX,
                                 add(f0, /*-fMinusX*/sub(PRIME, f1)),
                                 PRIME))
            }
            {
                let f2 := mload(add(evaluationsOnCosetPtr, 0x40))
                {
                    let f3 := mload(add(evaluationsOnCosetPtr, 0x60))

                    // f2 < 3P ( = 1 + 1 + 1).
                    f2 := add(add(f2, f3),
                                mulmod(add(f2, /*-fMinusX*/sub(PRIME, f3)),
                                       mulmod(friEvalPointDivByX, imaginaryUnit, PRIME),
                                       PRIME))
                }
                {
                    let friEvalPointDivByXSquared := mulmod(friEvalPointDivByX, friEvalPointDivByX, PRIME)
                    friEvalPointDivByXTessed := mulmod(friEvalPointDivByXSquared, friEvalPointDivByXSquared, PRIME)

                    // f0 < 7P ( = 3 + 3 + 1).
                    f0 := add(add(f0, f2),
                              mulmod(friEvalPointDivByXSquared,
                                     add(f0, /*-fMinusX*/sub(MPRIME, f2)),
                                     PRIME))
                }
            }
            {
                let f4 := mload(add(evaluationsOnCosetPtr, 0x80))
                {
                    let friEvalPointDivByX2 := mulmod(friEvalPointDivByX,
                                                      mload(add(friHalfInvGroupPtr, 0x40)), PRIME)
                    {
                        let f5 := mload(add(evaluationsOnCosetPtr, 0xa0))

                        // f4 < 3P ( = 1 + 1 + 1).
                        f4 := add(add(f4, f5),
                                  mulmod(friEvalPointDivByX2,
                                         add(f4, /*-fMinusX*/sub(PRIME, f5)),
                                         PRIME))
                    }

                    let f6 := mload(add(evaluationsOnCosetPtr, 0xc0))
                    {
                        let f7 := mload(add(evaluationsOnCosetPtr, 0xe0))

                        // f6 < 3P ( = 1 + 1 + 1).
                        f6 := add(add(f6, f7),
                                  mulmod(add(f6, /*-fMinusX*/sub(PRIME, f7)),
                                         // friEvalPointDivByX2 * imaginaryUnit ==
                                         // friEvalPointDivByX * mload(add(friHalfInvGroupPtr, 0x60)).
                                         mulmod(friEvalPointDivByX2, imaginaryUnit, PRIME),
                                         PRIME))
                    }

                    // f4 < 7P ( = 3 + 3 + 1).
                    f4 := add(add(f4, f6),
                              mulmod(mulmod(friEvalPointDivByX2, friEvalPointDivByX2, PRIME),
                                     add(f4, /*-fMinusX*/sub(MPRIME, f6)),
                                     PRIME))
                }

                // f0 < 15P ( = 7 + 7 + 1).
                f0 := add(add(f0, f4),
                          mulmod(friEvalPointDivByXTessed,
                                 add(f0, /*-fMinusX*/sub(MPRIME, f4)),
                                 PRIME))
            }
            {
                let f8 := mload(add(evaluationsOnCosetPtr, 0x100))
                {
                    let friEvalPointDivByX4 := mulmod(friEvalPointDivByX,
                                                      mload(add(friHalfInvGroupPtr, 0x80)), PRIME)
                    {
                        let f9 := mload(add(evaluationsOnCosetPtr, 0x120))

                        // f8 < 3P ( = 1 + 1 + 1).
                        f8 := add(add(f8, f9),
                                  mulmod(friEvalPointDivByX4,
                                         add(f8, /*-fMinusX*/sub(PRIME, f9)),
                                         PRIME))
                    }

                    let f10 := mload(add(evaluationsOnCosetPtr, 0x140))
                    {
                        let f11 := mload(add(evaluationsOnCosetPtr, 0x160))
                        // f10 < 3P ( = 1 + 1 + 1).
                        f10 := add(add(f10, f11),
                                   mulmod(add(f10, /*-fMinusX*/sub(PRIME, f11)),
                                          // friEvalPointDivByX4 * imaginaryUnit ==
                                          // friEvalPointDivByX * mload(add(friHalfInvGroupPtr, 0xa0)).
                                          mulmod(friEvalPointDivByX4, imaginaryUnit, PRIME),
                                          PRIME))
                    }

                    // f8 < 7P ( = 3 + 3 + 1).
                    f8 := add(add(f8, f10),
                              mulmod(mulmod(friEvalPointDivByX4, friEvalPointDivByX4, PRIME),
                                     add(f8, /*-fMinusX*/sub(MPRIME, f10)),
                                     PRIME))
                }
                {
                    let f12 := mload(add(evaluationsOnCosetPtr, 0x180))
                    {
                        let friEvalPointDivByX6 := mulmod(friEvalPointDivByX,
                                                          mload(add(friHalfInvGroupPtr, 0xc0)), PRIME)
                        {
                            let f13 := mload(add(evaluationsOnCosetPtr, 0x1a0))

                            // f12 < 3P ( = 1 + 1 + 1).
                            f12 := add(add(f12, f13),
                                       mulmod(friEvalPointDivByX6,
                                              add(f12, /*-fMinusX*/sub(PRIME, f13)),
                                              PRIME))
                        }

                        let f14 := mload(add(evaluationsOnCosetPtr, 0x1c0))
                        {
                            let f15 := mload(add(evaluationsOnCosetPtr, 0x1e0))

                            // f14 < 3P ( = 1 + 1 + 1).
                            f14 := add(add(f14, f15),
                                       mulmod(add(f14, /*-fMinusX*/sub(PRIME, f15)),
                                              // friEvalPointDivByX6 * imaginaryUnit ==
                                              // friEvalPointDivByX * mload(add(friHalfInvGroupPtr, 0xe0)).
                                              mulmod(friEvalPointDivByX6, imaginaryUnit, PRIME),
                                              PRIME))
                        }

                        // f12 < 7P ( = 3 + 3 + 1).
                        f12 := add(add(f12, f14),
                                   mulmod(mulmod(friEvalPointDivByX6, friEvalPointDivByX6, PRIME),
                                          add(f12, /*-fMinusX*/sub(MPRIME, f14)),
                                          PRIME))
                    }

                    // f8 < 15P ( = 7 + 7 + 1).
                    f8 := add(add(f8, f12),
                              mulmod(mulmod(friEvalPointDivByXTessed, imaginaryUnit, PRIME),
                                     add(f8, /*-fMinusX*/sub(MPRIME, f12)),
                                     PRIME))
                }

                // f0, f8 < 15P -> f0 + f8 < 30P && 16P < f0 + (MPRIME - f8) < 31P.
                nextLayerValue :=
                    addmod(add(f0, f8),
                           mulmod(mulmod(friEvalPointDivByXTessed, friEvalPointDivByXTessed, PRIME),
                                  add(f0, /*-fMinusX*/sub(MPRIME, f8)),
                                  PRIME),
                           PRIME)
            }

            {
                let xInv2 := mulmod(cosetOffset_, cosetOffset_, PRIME)
                let xInv4 := mulmod(xInv2, xInv2, PRIME)
                let xInv8 := mulmod(xInv4, xInv4, PRIME)
                nextXInv := mulmod(xInv8, xInv8, PRIME)
            }
        }
    }

    /*
      Gathers the "cosetSize" elements that belong to the same coset
      as the item at the top of the FRI queue and stores them in ctx[MM_FRI_STEP_VALUES:].

      Returns
        friQueueHead - friQueueHead_ + 0x60  * (# elements that were taken from the queue).
        cosetIdx - the start index of the coset that was gathered.
        cosetOffset_ - the xInv field element that corresponds to cosetIdx.
    */
    function gatherCosetInputs(
        uint256 channelPtr, uint256 friCtx, uint256 friQueueHead_, uint256 cosetSize)
        internal pure returns (uint256 friQueueHead, uint256 cosetIdx, uint256 cosetOffset_) {

        uint256 evaluationsOnCosetPtr = friCtx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
        uint256 friGroupPtr = friCtx + FRI_CTX_TO_FRI_GROUP_OFFSET;

        friQueueHead = friQueueHead_;
        assembly {
            let queueItemIdx := mload(friQueueHead)
            // The coset index is represented by the most significant bits of the queue item index.
            cosetIdx := and(queueItemIdx, not(sub(cosetSize, 1)))
            let nextCosetIdx := add(cosetIdx, cosetSize)
            let PRIME := 0x800000000000011000000000000000000000000000000000000000000000001

            // Get the algebraic coset offset:
            // I.e. given c*g^(-k) compute c, where
            //      g is the generator of the coset group.
            //      k is bitReverse(offsetWithinCoset, log2(cosetSize)).
            //
            // To do this we multiply the algebraic coset offset at the top of the queue (c*g^(-k))
            // by the group element that corresponds to the index inside the coset (g^k).
            cosetOffset_ := mulmod(
                /*(c*g^(-k)*/ mload(add(friQueueHead, 0x40)),
                /*(g^k)*/     mload(add(friGroupPtr,
                                        mul(/*offsetWithinCoset*/sub(queueItemIdx, cosetIdx),
                                            0x20))),
                PRIME)

            let proofPtr := mload(channelPtr)

            for { let index := cosetIdx } lt(index, nextCosetIdx) { index := add(index, 1) } {
                // Inline channel operation:
                // Assume we are going to read the next element from the proof.
                // If this is not the case add(proofPtr, 0x20) will be reverted.
                let fieldElementPtr := proofPtr
                proofPtr := add(proofPtr, 0x20)

                // Load the next index from the queue and check if it is our sibling.
                if eq(index, queueItemIdx) {
                    // Take element from the queue rather than from the proof
                    // and convert it back to Montgomery form for Merkle verification.
                    fieldElementPtr := add(friQueueHead, 0x20)

                    // Revert the read from proof.
                    proofPtr := sub(proofPtr, 0x20)

                    // Reading the next index here is safe due to the
                    // delimiter after the queries.
                    friQueueHead := add(friQueueHead, 0x60)
                    queueItemIdx := mload(friQueueHead)
                }

                // Note that we apply the modulo operation to convert the field elements we read
                // from the proof to canonical representation (in the range [0, PRIME - 1]).
                mstore(evaluationsOnCosetPtr, mod(mload(fieldElementPtr), PRIME))
                evaluationsOnCosetPtr := add(evaluationsOnCosetPtr, 0x20)
            }

            mstore(channelPtr, proofPtr)
        }
    }

    /*
      Returns the bit reversal of num assuming it has the given number of bits.
      For example, if we have numberOfBits = 6 and num = (0b)1101 == (0b)001101,
      the function will return (0b)101100.
    */
    function bitReverse(uint256 num, uint256 numberOfBits)
    internal pure
        returns(uint256 numReversed)
    {
        assert((numberOfBits == 256) || (num < 2 ** numberOfBits));
        uint256 n = num;
        uint256 r = 0;
        for (uint256 k = 0; k < numberOfBits; k++) {
            r = (r * 2) | (n % 2);
            n = n / 2;
        }
        return r;
    }

    /*
      Initializes the FRI group and half inv group in the FRI context.
    */
    function initFriGroups(uint256 friCtx) internal view {
        uint256 friGroupPtr = friCtx + FRI_CTX_TO_FRI_GROUP_OFFSET;
        uint256 friHalfInvGroupPtr = friCtx + FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET;

        // FRI_GROUP_GEN is the coset generator.
        // Raising it to the (MAX_COSET_SIZE - 1) power gives us the inverse.
        uint256 genFriGroup = FRI_GROUP_GEN;

        uint256 genFriGroupInv = fpow(genFriGroup, (MAX_COSET_SIZE - 1));

        uint256 lastVal = ONE_VAL;
        uint256 lastValInv = ONE_VAL;
        uint256 prime = PrimeFieldElement0.K_MODULUS;
        assembly {
            // ctx[mmHalfFriInvGroup + 0] = ONE_VAL;
            mstore(friHalfInvGroupPtr, lastValInv)
            // ctx[mmFriGroup + 0] = ONE_VAL;
            mstore(friGroupPtr, lastVal)
            // ctx[mmFriGroup + 1] = fsub(0, ONE_VAL);
            mstore(add(friGroupPtr, 0x20), sub(prime, lastVal))
        }

        // To compute [1, -1 (== g^n/2), g^n/4, -g^n/4, ...]
        // we compute half the elements and derive the rest using negation.
        uint256 halfCosetSize = MAX_COSET_SIZE / 2;
        for (uint256 i = 1; i < halfCosetSize; i++) {
            lastVal = fmul(lastVal, genFriGroup);
            lastValInv = fmul(lastValInv, genFriGroupInv);
            uint256 idx = bitReverse(i, FRI_MAX_FRI_STEP-1);

            assembly {
                // ctx[mmHalfFriInvGroup + idx] = lastValInv;
                mstore(add(friHalfInvGroupPtr, mul(idx, 0x20)), lastValInv)
                // ctx[mmFriGroup + 2*idx] = lastVal;
                mstore(add(friGroupPtr, mul(idx, 0x40)), lastVal)
                // ctx[mmFriGroup + 2*idx + 1] = fsub(0, lastVal);
                mstore(add(friGroupPtr, add(mul(idx, 0x40), 0x20)), sub(prime, lastVal))
            }
        }
    }

    /*
      Operates on the coset of size friFoldedCosetSize that start at index.

      It produces 3 outputs:
        1. The field elements that result from doing FRI reductions on the coset.
        2. The pointInv elements for the location that corresponds to the first output.
        3. The root of a Merkle tree for the input layer.

      The input is read either from the queue or from the proof depending on data availability.
      Since the function reads from the queue it returns an updated head pointer.
    */
    function doFriSteps(
        uint256 friCtx, uint256 friQueueTail, uint256 cosetOffset_, uint256 friEvalPoint,
        uint256 friCosetSize, uint256 index, uint256 merkleQueuePtr)
        internal pure {
        uint256 friValue;

        uint256 evaluationsOnCosetPtr = friCtx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
        uint256 friHalfInvGroupPtr = friCtx + FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET;

        // Compare to expected FRI step sizes in order of likelihood, step size 3 being most common.
        if (friCosetSize == 8) {
            (friValue, cosetOffset_) = do3FriSteps(
                friHalfInvGroupPtr, evaluationsOnCosetPtr, cosetOffset_, friEvalPoint);
        } else if (friCosetSize == 4) {
            (friValue, cosetOffset_) = do2FriSteps(
                friHalfInvGroupPtr, evaluationsOnCosetPtr, cosetOffset_, friEvalPoint);
        } else if (friCosetSize == 16) {
            (friValue, cosetOffset_) = do4FriSteps(
                friHalfInvGroupPtr, evaluationsOnCosetPtr, cosetOffset_, friEvalPoint);
        } else {
            require(false, "Only step sizes of 2, 3 or 4 are supported.");
        }

        uint256 lhashMask = getHashMask();
        assembly {
            let indexInNextStep := div(index, friCosetSize)
            mstore(merkleQueuePtr, indexInNextStep)
            mstore(add(merkleQueuePtr, 0x20), and(lhashMask, keccak256(evaluationsOnCosetPtr,
                                                                          mul(0x20,friCosetSize))))

            mstore(friQueueTail, indexInNextStep)
            mstore(add(friQueueTail, 0x20), friValue)
            mstore(add(friQueueTail, 0x40), cosetOffset_)
        }
    }

    /*
      Computes the FRI step with eta = log2(friCosetSize) for all the live queries.
      The input and output data is given in array of triplets:
          (query index, FRI value, FRI inversed point)
      in the address friQueuePtr (which is &ctx[mmFriQueue:]).

      The function returns the number of live queries remaining after computing the FRI step.

      The number of live queries decreases whenever multiple query points in the same
      coset are reduced to a single query in the next FRI layer.

      As the function computes the next layer it also collects that data from
      the previous layer for Merkle verification.
    */
    function computeNextLayer(
        uint256 channelPtr, uint256 friQueuePtr, uint256 merkleQueuePtr, uint256 nQueries,
        uint256 friEvalPoint, uint256 friCosetSize, uint256 friCtx)
        internal pure returns (uint256 nLiveQueries) {
        uint256 merkleQueueTail = merkleQueuePtr;
        uint256 friQueueHead = friQueuePtr;
        uint256 friQueueTail = friQueuePtr;
        uint256 friQueueEnd = friQueueHead + (0x60 * nQueries);

        do {
            uint256 cosetOffset;
            uint256 index;
            (friQueueHead, index, cosetOffset) = gatherCosetInputs(
                channelPtr, friCtx, friQueueHead, friCosetSize);

            doFriSteps(
                friCtx, friQueueTail, cosetOffset, friEvalPoint, friCosetSize, index,
                merkleQueueTail);

            merkleQueueTail += 0x40;
            friQueueTail += 0x60;
        } while (friQueueHead < friQueueEnd);
        return (friQueueTail - friQueuePtr) / 0x60;
    }

}

File 4 of 8: IFactRegistry.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

/*
  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>`_.
*/
contract IFactRegistry {
    /*
      Returns true if the given fact was previously registered in the contract.
    */
    function isValid(bytes32 fact)
        external view
        returns(bool);
}

File 5 of 8: IMerkleVerifier.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

contract IMerkleVerifier {
    uint256 constant internal MAX_N_MERKLE_VERIFIER_QUERIES =  128;

    function verify(
        uint256 channelPtr,
        uint256 queuePtr,
        bytes32 root,
        uint256 n)
        internal view
        returns (bytes32 hash);
}

File 6 of 8: IQueryableFactRegistry.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

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.
*/
contract IQueryableFactRegistry is IFactRegistry {

    /*
      Returns true if at least one fact has been registered.
    */
    function hasRegisteredFact()
        external view
        returns(bool);

}

File 7 of 8: MerkleVerifier.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

import "IMerkleVerifier.sol";

contract MerkleVerifier is IMerkleVerifier {

    function getHashMask() internal pure returns(uint256) {
        // Default implementation.
        return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000;
    }

    /*
      Verifies a Merkle tree decommitment for n leaves in a Merkle tree with N leaves.

      The inputs data sits in the queue at queuePtr.
      Each slot in the queue contains a 32 bytes leaf index and a 32 byte leaf value.
      The indices need to be in the range [N..2*N-1] and strictly incrementing.
      Decommitments are read from the channel in the ctx.

      The input data is destroyed during verification.
    */
    function verify(
        uint256 channelPtr,
        uint256 queuePtr,
        bytes32 root,
        uint256 n)
        internal view
        returns (bytes32 hash)
    {
        uint256 lhashMask = getHashMask();
        require(n <= MAX_N_MERKLE_VERIFIER_QUERIES, "TOO_MANY_MERKLE_QUERIES");

        assembly {
            // queuePtr + i * 0x40 gives the i'th index in the queue.
            // hashesPtr + i * 0x40 gives the i'th hash in the queue.
            let hashesPtr := add(queuePtr, 0x20)
            let queueSize := mul(n, 0x40)
            let slotSize := 0x40

            // The items are in slots [0, n-1].
            let rdIdx := 0
            let wrIdx := 0 // = n % n.

            // Iterate the queue until we hit the root.
            let index := mload(add(rdIdx, queuePtr))
            let proofPtr := mload(channelPtr)

            // while(index > 1).
            for { } gt(index, 1) { } {
                let siblingIndex := xor(index, 1)
                // sibblingOffset := 0x20 * lsb(siblingIndex).
                let sibblingOffset := mulmod(siblingIndex, 0x20, 0x40)

                // Store the hash corresponding to index in the correct slot.
                // 0 if index is even and 0x20 if index is odd.
                // The hash of the sibling will be written to the other slot.
                mstore(xor(0x20, sibblingOffset), mload(add(rdIdx, hashesPtr)))
                rdIdx := addmod(rdIdx, slotSize, queueSize)

                // Inline channel operation:
                // Assume we are going to read a new hash from the proof.
                // If this is not the case add(proofPtr, 0x20) will be reverted.
                let newHashPtr := proofPtr
                proofPtr := add(proofPtr, 0x20)

                // Push index/2 into the queue, before reading the next index.
                // The order is important, as otherwise we may try to read from an empty queue (in
                // the case where we are working on one item).
                // wrIdx will be updated after writing the relevant hash to the queue.
                mstore(add(wrIdx, queuePtr), div(index, 2))

                // Load the next index from the queue and check if it is our sibling.
                index := mload(add(rdIdx, queuePtr))
                if eq(index, siblingIndex) {
                    // Take sibling from queue rather than from proof.
                    newHashPtr := add(rdIdx, hashesPtr)
                    // Revert reading from proof.
                    proofPtr := sub(proofPtr, 0x20)
                    rdIdx := addmod(rdIdx, slotSize, queueSize)

                    // Index was consumed, read the next one.
                    // Note that the queue can't be empty at this point.
                    // The index of the parent of the current node was already pushed into the
                    // queue, and the parent is never the sibling.
                    index := mload(add(rdIdx, queuePtr))
                }

                mstore(sibblingOffset, mload(newHashPtr))

                // Push the new hash to the end of the queue.
                mstore(add(wrIdx, hashesPtr), and(lhashMask, keccak256(0x00, 0x40)))
                wrIdx := addmod(wrIdx, slotSize, queueSize)
            }
            hash := mload(add(rdIdx, hashesPtr))

            // Update the proof pointer in the context.
            mstore(channelPtr, proofPtr)
        }
        // emit LogBool(hash == root);
        require(hash == root, "INVALID_MERKLE_PROOF");
    }
}

File 8 of 8: PrimeFieldElement0.sol
/*
  Copyright 2019,2020 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.
*/
pragma solidity ^0.5.2;

contract PrimeFieldElement0 {
    uint256 constant internal K_MODULUS =
    0x800000000000011000000000000000000000000000000000000000000000001;
    uint256 constant internal K_MODULUS_MASK =
    0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
    uint256 constant internal K_MONTGOMERY_R =
    0x7fffffffffffdf0ffffffffffffffffffffffffffffffffffffffffffffffe1;
    uint256 constant internal K_MONTGOMERY_R_INV =
    0x40000000000001100000000000012100000000000000000000000000000000;
    uint256 constant internal GENERATOR_VAL = 3;
    uint256 constant internal ONE_VAL = 1;
    uint256 constant internal GEN1024_VAL =
    0x659d83946a03edd72406af6711825f5653d9e35dc125289a206c054ec89c4f1;

    function fromMontgomery(uint256 val) internal pure returns (uint256 res) {
        // uint256 res = fmul(val, kMontgomeryRInv);
        assembly {
            res := mulmod(val,
                          0x40000000000001100000000000012100000000000000000000000000000000,
                          0x800000000000011000000000000000000000000000000000000000000000001)
        }
        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,
                          0x7fffffffffffdf0ffffffffffffffffffffffffffffffffffffffffffffffe1,
                          0x800000000000011000000000000000000000000000000000000000000000001)
        }
        return res;
    }

    function fmul(uint256 a, uint256 b) internal pure returns (uint256 res) {
        //uint256 res = mulmod(a, b, kModulus);
        assembly {
            res := mulmod(a, b,
                0x800000000000011000000000000000000000000000000000000000000000001)
        }
        return res;
    }

    function fadd(uint256 a, uint256 b) internal pure returns (uint256 res) {
        // uint256 res = addmod(a, b, kModulus);
        assembly {
            res := addmod(a, b,
                0x800000000000011000000000000000000000000000000000000000000000001)
        }
        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(0x800000000000011000000000000000000000000000000000000000000000001, b),
                0x800000000000011000000000000000000000000000000000000000000000001)
        }
        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)
        internal 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);
    }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"uint256","name":"val","type":"uint256"}],"name":"LogGas","type":"event"},{"constant":true,"inputs":[],"name":"hasRegisteredFact","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"fact","type":"bytes32"}],"name":"isValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256[]","name":"proof","type":"uint256[]"},{"internalType":"uint256[]","name":"friQueue","type":"uint256[]"},{"internalType":"uint256","name":"evaluationPoint","type":"uint256"},{"internalType":"uint256","name":"friStepSize","type":"uint256"},{"internalType":"uint256","name":"expectedRoot","type":"uint256"}],"name":"verifyFRI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50611163806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80636a93856714610046578063d6354e1514610077578063e85a6a281461007f575b600080fd5b6100636004803603602081101561005c57600080fd5b50356101b3565b604080519115158252519081900360200190f35b6100636101c4565b6101b1600480360360a081101561009557600080fd5b8101906020810181356401000000008111156100b057600080fd5b8201836020820111156100c257600080fd5b803590602001918460208302840111640100000000831117156100e457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561013457600080fd5b82018360208201111561014657600080fd5b8035906020019184602083028401116401000000008311171561016857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050823593505050602081013590604001356101cd565b005b60006101be8261071c565b92915050565b60015460ff1690565b600482111561023d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f46524920737465702073697a6520746f6f206c61726765000000000000000000604482015290519081900360640190fd5b600384518161024857fe5b066001146102a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e8152602001806110f1603e913960400191505060405180910390fd5b60048451101561031257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4e6f20717565727920746f2070726f6365737300000000000000000000000000604482015290519081900360640190fd5b835161050090600380820491600091889190840290811061032f57fe5b60200260200101818152505060008060008060007f08000000000000110000000000000000000000000000000000000000000000018a106103d157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f494e56414c49445f4556414c5f504f494e540000000000000000000000000000604482015290519081900360640190fd5b6000805b878110156105d357818d82600302815181106103ed57fe5b60200260200101511161046157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f51554552595f56414c554500000000000000000000000000604482015290519081900360640190fd5b7f08000000000000110000000000000000000000000000000000000000000000018d826003026001018151811061049457fe5b60200260200101511061050857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f494e56414c49445f4652495f56414c5545000000000000000000000000000000604482015290519081900360640190fd5b7f08000000000000110000000000000000000000000000000000000000000000018d826003026002018151811061053b57fe5b6020026020010151106105af57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f494e56414c49445f4652495f494e56455253455f504f494e5400000000000000604482015290519081900360640190fd5b8c81600302815181106105be57fe5b602090810291909101015191506001016103d5565b508b6000815181106105e157fe5b60200260200101518c60038960030203815181106105fb57fe5b60200260200101518d60008151811061061057fe5b6020026020010151181061068557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f515545524945535f52414e47450000000000000000000000604482015290519081900360640190fd5b60208c019450604051935060208d0184526020840195508660400286019250878301915060a082016040528a825289602083015288608083015286606002852060408301526106d383610731565b6106e58486888a8f8f60020a8961081c565b96506106f384878b8a610879565b50606080880286209083015260a0822061070c81610a20565b5050505050505050505050505050565b60009081526020819052604090205460ff1690565b610200810161040082017f05ec467b88826aba4537602d514425f3b0bdf467bbf302458337c45f6021e539600061076982600f610a90565b60018085528086527f08000000000000110000000000000000000000000000000000000000000000006020870152909150807f08000000000000110000000000000000000000000000000000000000000000016008825b81811015610810576107d28588610ac4565b94506107de8487610ac4565b935060006107ed826003610af1565b60208082028b0187905260409091028b01878152878603910152506001016107c0565b50505050505050505050565b60008587806060880281015b6000806108378e89878c610b2f565b919650909250905061084e8885848d8d868c610c18565b60408601955060608401935050508083106108285760608b8303049c9b505050505050505050505050565b600080610884610cf1565b905060808311156108f657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f544f4f5f4d414e595f4d45524b4c455f51554552494553000000000000000000604482015290519081900360640190fd5b60208501604084026040600080898201518b515b600182111561099a5760018218604060208209888601518160201852878787086002909404858f01528d84015193955060208301928285141561097d57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201918589018888880896508e87015194505b8051825260406000208b168a87015288888708955050505061090a565b9290950151918b5250945050508483149050610a1757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f494e56414c49445f4d45524b4c455f50524f4f46000000000000000000000000604482015290519081900360640190fd5b50949350505050565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091555460ff16610a8d57600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790555b50565b6000610abd83837f0800000000000011000000000000000000000000000000000000000000000001610d15565b9392505050565b60007f08000000000000110000000000000000000000000000000000000000000000018284099392505050565b6000816101001480610b0557508160020a83105b610b0b57fe5b826000805b84811015610a1757600291820260018416179183049250600101610b10565b81517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820119811680820360200285016102009081015160408601518694600093899390840192868901917f0800000000000011000000000000000000000000000000000000000000000001918291900995508b51875b83811015610c0457602082019181861415610bf0575060608a018051909a9095507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020015b518390068752602090960195600101610ba6565b50808d525050505050509450945094915050565b60008761040081016008861415610c3e57610c3581838a8a610d59565b98509250610cb9565b8560041415610c5357610c3581838a8a610e65565b8560101415610c6857610c3581838a8a610eee565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806110c6602b913960400191505060405180910390fd5b6000610cc3610cf1565b9587900480865260209788029093209095169386019390935287529286019290925250505060409091015250565b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090565b600060405160208152602080820152602060408201528460608201528360808201528260a082015260208160c08360055afa610d5057600080fd5b51949350505050565b6000807f08000000000000110000000000000000000000000000000000000000000000017f80000000000001100000000000000000000000000000000000000000000000108651828787098381820960208b015160208b0151868188038601850960408d015160608e01519690920101948780848709828a0384010991010186818703860184098186010194505060808b01518660408e0151850960a08d015188818a03840183098184010192505060c08d015160e08e0151898a868509828c038401099101018881890384018184800909818401019250505086878288038701898687090982870108985050858a8b0986818209878182099850505050505050505094509492505050565b6000807f08000000000000110000000000000000000000000000000000000000000000018085850986516020880151838185038301840981830101915050604088015160608901518485868660208f0151098388038501098284010891505083888909848182099550508384828603840186868709098284010895505050505094509492505050565b60008060007f08000000000000110000000000000000000000000000000000000000000000017f800000000000011000000000000000000000000000000000000000000000001087518288880960208b015160208b0151858187038501840960408d015160608e01519590920101938680848609828903840109910101858380098681820997508682870386018209828601019450505060808b01518560408e0151840960a08d015187818903840183098184010192505060c08d015160e08e01518889868509828b03840109910101878188038401818480090981840101925050508581860385018809818501019350506101008b01518560808e015184096101208d01518781890384018309818401019250506101408d01516101608e01518889868509828b03840109910101878188038401818480090981840101925050506101808c01518660c08f015185096101a08e015188818a0384018309818401019250506101c08e01516101e08f0151898a878509828c038401099101018881890384018184800909818401019250505086818703830188858b090991010185808287038601818a80090982860108985050848a8b0985818209868182098781820999505050505050505050509450949250505056fe4f6e6c7920737465702073697a6573206f6620322c2033206f7220342061726520737570706f727465642e465249205175657565206d75737420626520636f6d706f736564206f6620747269706c65747320706c7573206f6e652064656c696d697465722063656c6ca265627a7a72315820e14a9200510570075fc0caea87bdc267444cce101b681e3365d0ad59a7cfc18e64736f6c634300050f0032

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100415760003560e01c80636a93856714610046578063d6354e1514610077578063e85a6a281461007f575b600080fd5b6100636004803603602081101561005c57600080fd5b50356101b3565b604080519115158252519081900360200190f35b6100636101c4565b6101b1600480360360a081101561009557600080fd5b8101906020810181356401000000008111156100b057600080fd5b8201836020820111156100c257600080fd5b803590602001918460208302840111640100000000831117156100e457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561013457600080fd5b82018360208201111561014657600080fd5b8035906020019184602083028401116401000000008311171561016857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050823593505050602081013590604001356101cd565b005b60006101be8261071c565b92915050565b60015460ff1690565b600482111561023d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f46524920737465702073697a6520746f6f206c61726765000000000000000000604482015290519081900360640190fd5b600384518161024857fe5b066001146102a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e8152602001806110f1603e913960400191505060405180910390fd5b60048451101561031257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4e6f20717565727920746f2070726f6365737300000000000000000000000000604482015290519081900360640190fd5b835161050090600380820491600091889190840290811061032f57fe5b60200260200101818152505060008060008060007f08000000000000110000000000000000000000000000000000000000000000018a106103d157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f494e56414c49445f4556414c5f504f494e540000000000000000000000000000604482015290519081900360640190fd5b6000805b878110156105d357818d82600302815181106103ed57fe5b60200260200101511161046157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f51554552595f56414c554500000000000000000000000000604482015290519081900360640190fd5b7f08000000000000110000000000000000000000000000000000000000000000018d826003026001018151811061049457fe5b60200260200101511061050857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f494e56414c49445f4652495f56414c5545000000000000000000000000000000604482015290519081900360640190fd5b7f08000000000000110000000000000000000000000000000000000000000000018d826003026002018151811061053b57fe5b6020026020010151106105af57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f494e56414c49445f4652495f494e56455253455f504f494e5400000000000000604482015290519081900360640190fd5b8c81600302815181106105be57fe5b602090810291909101015191506001016103d5565b508b6000815181106105e157fe5b60200260200101518c60038960030203815181106105fb57fe5b60200260200101518d60008151811061061057fe5b6020026020010151181061068557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f515545524945535f52414e47450000000000000000000000604482015290519081900360640190fd5b60208c019450604051935060208d0184526020840195508660400286019250878301915060a082016040528a825289602083015288608083015286606002852060408301526106d383610731565b6106e58486888a8f8f60020a8961081c565b96506106f384878b8a610879565b50606080880286209083015260a0822061070c81610a20565b5050505050505050505050505050565b60009081526020819052604090205460ff1690565b610200810161040082017f05ec467b88826aba4537602d514425f3b0bdf467bbf302458337c45f6021e539600061076982600f610a90565b60018085528086527f08000000000000110000000000000000000000000000000000000000000000006020870152909150807f08000000000000110000000000000000000000000000000000000000000000016008825b81811015610810576107d28588610ac4565b94506107de8487610ac4565b935060006107ed826003610af1565b60208082028b0187905260409091028b01878152878603910152506001016107c0565b50505050505050505050565b60008587806060880281015b6000806108378e89878c610b2f565b919650909250905061084e8885848d8d868c610c18565b60408601955060608401935050508083106108285760608b8303049c9b505050505050505050505050565b600080610884610cf1565b905060808311156108f657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f544f4f5f4d414e595f4d45524b4c455f51554552494553000000000000000000604482015290519081900360640190fd5b60208501604084026040600080898201518b515b600182111561099a5760018218604060208209888601518160201852878787086002909404858f01528d84015193955060208301928285141561097d57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201918589018888880896508e87015194505b8051825260406000208b168a87015288888708955050505061090a565b9290950151918b5250945050508483149050610a1757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f494e56414c49445f4d45524b4c455f50524f4f46000000000000000000000000604482015290519081900360640190fd5b50949350505050565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091555460ff16610a8d57600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790555b50565b6000610abd83837f0800000000000011000000000000000000000000000000000000000000000001610d15565b9392505050565b60007f08000000000000110000000000000000000000000000000000000000000000018284099392505050565b6000816101001480610b0557508160020a83105b610b0b57fe5b826000805b84811015610a1757600291820260018416179183049250600101610b10565b81517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820119811680820360200285016102009081015160408601518694600093899390840192868901917f0800000000000011000000000000000000000000000000000000000000000001918291900995508b51875b83811015610c0457602082019181861415610bf0575060608a018051909a9095507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020015b518390068752602090960195600101610ba6565b50808d525050505050509450945094915050565b60008761040081016008861415610c3e57610c3581838a8a610d59565b98509250610cb9565b8560041415610c5357610c3581838a8a610e65565b8560101415610c6857610c3581838a8a610eee565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806110c6602b913960400191505060405180910390fd5b6000610cc3610cf1565b9587900480865260209788029093209095169386019390935287529286019290925250505060409091015250565b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090565b600060405160208152602080820152602060408201528460608201528360808201528260a082015260208160c08360055afa610d5057600080fd5b51949350505050565b6000807f08000000000000110000000000000000000000000000000000000000000000017f80000000000001100000000000000000000000000000000000000000000000108651828787098381820960208b015160208b0151868188038601850960408d015160608e01519690920101948780848709828a0384010991010186818703860184098186010194505060808b01518660408e0151850960a08d015188818a03840183098184010192505060c08d015160e08e0151898a868509828c038401099101018881890384018184800909818401019250505086878288038701898687090982870108985050858a8b0986818209878182099850505050505050505094509492505050565b6000807f08000000000000110000000000000000000000000000000000000000000000018085850986516020880151838185038301840981830101915050604088015160608901518485868660208f0151098388038501098284010891505083888909848182099550508384828603840186868709098284010895505050505094509492505050565b60008060007f08000000000000110000000000000000000000000000000000000000000000017f800000000000011000000000000000000000000000000000000000000000001087518288880960208b015160208b0151858187038501840960408d015160608e01519590920101938680848609828903840109910101858380098681820997508682870386018209828601019450505060808b01518560408e0151840960a08d015187818903840183098184010192505060c08d015160e08e01518889868509828b03840109910101878188038401818480090981840101925050508581860385018809818501019350506101008b01518560808e015184096101208d01518781890384018309818401019250506101408d01516101608e01518889868509828b03840109910101878188038401818480090981840101925050506101808c01518660c08f015185096101a08e015188818a0384018309818401019250506101c08e01516101e08f0151898a878509828c038401099101018881890384018184800909818401019250505086818703830188858b090991010185808287038601818a80090982860108985050848a8b0985818209868182098781820999505050505050505050509450949250505056fe4f6e6c7920737465702073697a6573206f6620322c2033206f7220342061726520737570706f727465642e465249205175657565206d75737420626520636f6d706f736564206f6620747269706c65747320706c7573206f6e652064656c696d697465722063656c6ca265627a7a72315820e14a9200510570075fc0caea87bdc267444cce101b681e3365d0ad59a7cfc18e64736f6c634300050f0032

Deployed Bytecode Sourcemap

672:4449:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;672:4449:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;963:119:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;963:119:0;;:::i;:::-;;;;;;;;;;;;;;;;;;1889:118;;;:::i;1422:3697:2:-;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;1422:3697:2;;;;;;;;21:11:-1;5:28;;2:2;;;46:1;43;36:12;2:2;1422:3697:2;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;1422:3697:2;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;39:11;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;1422:3697:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;1422:3697:2;;;;;;;;-1:-1:-1;1422:3697:2;;-1:-1:-1;;21:11;5:28;;2:2;;;46:1;43;36:12;2:2;1422:3697:2;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;1422:3697:2;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;39:11;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;1422:3697:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;1422:3697:2;;-1:-1:-1;;1422:3697:2;;;-1:-1:-1;;;1422:3697:2;;;;;;;;;:::i;:::-;;963:119:0;1032:4;1059:16;1070:4;1059:10;:16::i;:::-;1052:23;963:119;-1:-1:-1;;963:119:0:o;1889:118::-;1983:17;;;;1889:118;:::o;1422:3697:2:-;1474:1:1;1628:11:2;:31;;1619:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2047:1;2029:8;:15;:19;;;;;;2052:1;2029:24;2007:125;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2170:1;2151:8;:15;:20;;2142:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2270:15;;2148:59:1;;2288:1:2;2270:19;;;;2206:20;;2270:15;;2308:10;;;;2299:20;;;;;;;;;;;:24;;;;;2369:22;2401:19;2430:18;2458:14;2482:18;697:65:7;2574:15:2;:27;2566:58;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3090:17;;3183:310;3207:8;3203:1;:12;3183:310;;;3260:9;3244:8;3255:1;3253;:3;3244:13;;;;;;;;;;;;;;:25;3236:57;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;697:65:7;3315:8:2;3326:1;3324;:3;3328:1;3324:5;3315:15;;;;;;;;;;;;;;:27;3307:57;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;697:65:7;3386:8:2;3397:1;3395;:3;3399:1;3395:5;3386:15;;;;;;;;;;;;;;:27;3378:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3469:8;3480:1;3478;:3;3469:13;;;;;;;;;;;;;;;;;;;-1:-1:-1;3217:3:2;;3183:310;;;;3667:8;3676:1;3667:11;;;;;;;;;;;;;;3641:8;3661:1;3652:8;3650:1;:10;:12;3641:22;;;;;;;;;;;;;;3627:8;3636:1;3627:11;;;;;;;;;;;;;;:36;3626:52;3618:86;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3847:4;3837:8;3833:19;3818:34;;3885:4;3879:11;3865:25;;3959:4;3952:5;3948:16;3936:10;3929:36;4012:4;4000:10;3996:21;3978:39;;4070:8;4064:4;4060:19;4044:14;4040:40;4030:50;;4119:12;4111:6;4107:25;4093:39;;4174:4;4162:10;4158:21;4152:4;4145:35;4238:15;4226:10;4219:35;4297:11;4290:4;4278:10;4274:21;4267:42;4352:12;4345:4;4333:10;4329:21;4322:43;4496:8;4490:4;4486:19;4473:11;4463:43;4456:4;4444:10;4440:21;4433:74;4527:21;4541:6;4527:13;:21::i;:::-;4570:181;4600:10;4612:11;4625:14;4641:8;4651:15;4683:11;4680:1;:14;4744:6;4570:16;:181::i;:::-;4559:192;-1:-1:-1;4762:67:2;4769:10;4781:14;4805:12;4559:192;4762:6;:67::i;:::-;-1:-1:-1;5001:4:2;4997:19;;;4974:43;;4951:21;;;4944:74;5065:4;5043:27;;5090:22;5043:27;5090:12;:22::i;:::-;1422:3697;;;;;;;;;;;;;;:::o;1379:124:0:-;1451:4;1478:18;;;;;;;;;;;;;;1379:124::o;23120:1803:1:-;1809:21;23205:36;;2052:44;23280:45;;1694:65;23183:19;23534:39;1694:65;23553:18;23534:4;:39::i;:::-;1211:1:7;23787:38:1;;;23884:28;;;24011:19;24004:4;23987:22;;23980:51;23509:64;;-1:-1:-1;1211:1:7;697:65;24212:18:1;1211:1:7;24240:677:1;24264:13;24260:1;:17;24240:677;;;24308:26;24313:7;24322:11;24308:4;:26::i;:::-;24298:36;;24361:32;24366:10;24378:14;24361:4;:32::i;:::-;24348:45;-1:-1:-1;24407:11:1;24421:33;24432:1;24435:18;24421:10;:33::i;:::-;24598:4;24589:14;;;24565:39;;24558:59;;;24721:4;24712:14;;;24695:32;;24688:49;;;24873:19;;;24828:43;;24821:72;-1:-1:-1;24279:3:1;;24240:677;;;;23120:1803;;;;;;;;;:::o;27803:970::-;28020:20;28078:14;28125:11;;28228:4;:15;;28212:32;;28255:460;28272:19;28305:13;28369:82;28404:10;28416:6;28424:12;28438;28369:17;:82::i;:::-;28332:119;;-1:-1:-1;28332:119:1;;-1:-1:-1;28332:119:1;-1:-1:-1;28466:130:1;28494:6;28502:12;28332:119;28529:12;28543;28332:119;28580:15;28466:10;:130::i;:::-;28630:4;28611:23;;;;28664:4;28648:20;;;;28255:460;;28702:11;28687:12;:26;28255:460;;28762:4;28732:26;;;28731:35;;27803:970;-1:-1:-1;;;;;;;;;;;;27803:970:1:o;1322:3536:6:-;1473:12;1501:17;1521:13;:11;:13::i;:::-;1501:33;;711:3:4;1552:1:6;:34;;1544:70;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1819:4;1809:8;1805:19;1861:4;1858:1;1854:12;1895:4;1974:1;2001;2114:8;2107:5;2103:20;2097:27;2159:10;2153:17;2217:2384;2235:1;2228:5;2225:12;2217:2384;;;2291:1;2284:5;2280:13;2422:4;2416;2402:12;2395:32;2716:9;2709:5;2705:21;2699:28;2682:14;2676:4;2672:25;2665:63;2778:9;2768:8;2761:5;2754:34;3466:1;3455:13;;;3433:20;;;3426:43;3588:20;;;3582:27;2745:43;;-1:-1:-1;3075:4:6;3061:19;;;3629:23;;;3626:2;;;-1:-1:-1;3864:19:6;;;;;3760:21;;;3937:9;3927:8;3764:5;3913:34;3904:43;;4292:8;4285:5;4281:20;4275:27;4266:36;;3626:2;4367:10;4361:17;4345:14;4338:41;4520:4;4514;4504:21;4493:9;4489:37;4477:9;4470:5;4466:21;4459:68;4577:9;4567:8;4560:5;4553:34;4544:43;;2242:2359;;;2217:2384;;;4628:21;;;;4622:28;4720;;;-1:-1:-1;4622:28:6;-1:-1:-1;;;4814:12:6;;;;-1:-1:-1;4806:45:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1322:3536;;;;;;;:::o;1509:302:0:-;1660:12;:22;;;;;;;;;;:29;;;;1685:4;1660:29;;;;;;1737:17;1660:29;1737:17;1732:73;;1790:4;1770:24;;;;;;;;1732:73;1509:302;:::o;3419:123:7:-;3482:7;3508:27;3515:3;3520;697:65;3508:6;:27::i;:::-;3501:34;3419:123;-1:-1:-1;;;3419:123:7:o;2410:291::-;2469:11;2599:65;2580:1;2577;2570:95;2563:102;2410:291;-1:-1:-1;;;2410:291:7:o;22653:376:1:-;22742:19;22785:12;22801:3;22785:19;22784:50;;;;22821:12;22816:1;:17;22810:3;:23;22784:50;22777:58;;;;22857:3;22845:9;;22893:112;22917:12;22913:1;:16;22893:112;;;22969:1;22955:5;;;22965;;;22954:17;;22965:1;22989:5;;-1:-1:-1;22931:3:1;;22893:112;;19299:3130;19753:19;;19919:17;;;19915:22;19897:41;;20740:27;;;1809:4;20715:103;20658:161;;1809:21;20658:161;;;20652:168;20614:4;20596:23;;20590:30;19687:13;;19444:20;;19549:6;;19625:36;;;;19971:24;;;;20021:65;;;;20652:168;20552:292;20536:308;;20880:10;20874:17;20924:8;20905:1466;20945:12;20938:5;20935:23;20905:1466;;;21284:4;21270:19;;;21396:23;;;21393:2;;;-1:-1:-1;21931:4:1;21913:23;;21973:19;;21913:23;;21973:19;;-1:-1:-1;21734:19:1;;;;;21644:4;21626:23;21393:2;22252:22;22248:34;;;22218:65;;22352:4;22325:32;;;;20981:1;20970:13;20905:1466;;;20909:25;22404:8;22392:10;22385:28;19719:2704;;;;;;;;;;;;;;:::o;25456:1686::-;25668:16;25727:6;2052:44;25810:45;;25987:1;25971:17;;25967:627;;;26031:99;26060:18;26080:21;26103:12;26117;26031:11;:99::i;:::-;26004:126;-1:-1:-1;26004:126:1;-1:-1:-1;25967:627:1;;;26151:12;26167:1;26151:17;26147:447;;;26211:99;26240:18;26260:21;26283:12;26297;26211:11;:99::i;26147:447::-;26331:12;26347:2;26331:18;26327:267;;;26392:99;26421:18;26441:21;26464:12;26478;26392:11;:99::i;26327:267::-;26522:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26604:17;26624:13;:11;:13::i;:::-;26693:24;;;;26730:39;;;26942:4;26938:22;;;26831:130;;;26816:146;;;26789:25;;;26782:181;;;;26977:37;;27034:23;;;27027:41;;;;-1:-1:-1;;;27106:4:1;27088:23;;;27081:45;-1:-1:-1;26656:480:1:o;702:179:6:-;808:66;702:179;:::o;3548:725:7:-;3644:11;3709:4;3703:11;3737:4;3734:1;3727:15;3812:4;3805;3802:1;3798:12;3791:26;3880:4;3873;3870:1;3866:12;3859:26;3947:4;3940;3937:1;3933:12;3926:26;4001:8;3994:4;3991:1;3987:12;3980:30;4059:7;4052:4;4049:1;4045:12;4038:29;4178:4;4175:1;4169:4;4166:1;4160:4;4155:3;4144:39;4134:2;;4213:1;4210;4203:12;4134:2;4249:8;;3680:587;-1:-1:-1;;;;3680:587:7:o;5937:4148:1:-;6105:22;6129:16;6193:65;6285:66;6380:21;6374:28;6477:5;6463:12;6449;6442:41;6576:5;6556:18;6536;6529:53;6646:4;6626:18;6622:29;6616:36;6727:4;6704:21;6700:32;6694:39;6973:5;6934:2;6927:5;6923:14;6907:2;6903:35;6850:18;6843:136;7068:4;7041:32;;7035:39;7156:4;7129:32;;7123:39;6804:11;;;;6800:180;;7452:5;;7392:13;7372:18;7365:48;7322:2;7315:5;7311:14;7295:2;7291:35;7284:174;7241:11;;7237:222;7725:5;7674:15;;;7654:36;;7594:25;7587:144;7556:2;7552;7548:11;7544:188;7538:194;;7007:739;7820:4;7797:21;7793:32;7787:39;8009:5;8001:4;7981:18;7977:29;7971:36;7899:18;7892:123;8105:4;8082:21;8078:32;8072:39;8392:5;8345:2;8338:5;8334:14;8318:2;8314:35;8252:19;8245:153;8206:2;8202;8198:11;8194:205;8188:211;;8036:385;8486:4;8463:21;8459:32;8453:39;8582:4;8559:21;8555:32;8549:39;9085:5;9036;9021:13;9000:19;8993:49;8760:2;8753:5;8749:14;8733:2;8729:35;8722:369;8675:11;;8671:421;9412:5;9357:15;;;9337:36;;9412:5;9271:19;;9243:55;9236:182;9201:2;9197;9193:11;9189:230;9183:236;;7843:1594;;9834:5;9800;9761:2;9753:6;9749:15;9733:2;9729:36;9688:5;9661:25;9634;9627:67;9620:186;9589:2;9585;9581:11;9574:266;9537:303;;7759:2095;9934:5;9920:12;9906;9899:41;9991:5;9984;9977;9970:27;10047:5;10040;10033;10026:27;10014:39;;9868:199;;6166:3913;;;;;;;;;;;;;:::o;3919:1851::-;4087:22;4111:16;4175:65;4314:5;4300:12;4286;4279:41;4350:21;4344:28;4446:4;4423:21;4419:32;4413:39;4701:5;4659:2;4652:5;4648:14;4632:2;4628:35;4572:18;4565:142;4531:2;4527;4523:11;4519:189;4513:195;;4385:337;4779:4;4756:21;4752:32;4746:39;4859:4;4836:21;4832:32;4826:39;5249:5;5212;5168;5105:18;5054:4;5034:18;5030:29;5024:36;5017:157;4975:2;4968:5;4964:14;4948:2;4944:35;4937:281;4903:2;4899;4895:11;4888:367;4882:373;;4798:471;5351:5;5337:12;5323;5316:41;5411:5;5402:7;5393;5386:31;5374:43;;5283:148;5748:5;5714;5675:2;5668:5;5664:14;5648:2;5644:35;5603:5;5583:18;5563;5556:53;5549:171;5518:2;5514;5510:11;5503:251;5485:269;;4148:1616;;;;;;;;;;;:::o;10277:8592::-;10445:22;10469:16;10277:8592;10574:65;10666:66;10761:21;10755:28;10858:5;10844:12;10830;10823:41;10928:4;10908:18;10904:29;10898:36;11009:4;10986:21;10982:32;10976:39;11255:5;11216:2;11209:5;11205:14;11189:2;11185:35;11132:18;11125:136;11350:4;11323:32;;11317:39;11438:4;11411:32;;11405:39;11086:11;;;;11082:180;;11740:5;;11678:13;11658:18;11651:48;11606:2;11599:5;11595:14;11579:2;11575:35;11568:178;11523:11;;11519:228;11884:5;11864:18;;11837:53;12000:5;11973:25;11946;11939:67;11911:95;;12274:5;12231:2;12223:6;12219:15;12203:2;12199:36;12135:25;12128:152;12093:2;12089;12085:11;12081:200;12075:206;;11782:517;11289:1024;12387:4;12364:21;12360:32;12354:39;12578:5;12570:4;12550:18;12546:29;12540:36;12466:18;12459:125;12674:4;12651:21;12647:32;12641:39;12961:5;12914:2;12907:5;12903:14;12887:2;12883:35;12821:19;12814:153;12775:2;12771;12767:11;12763:205;12757:211;;12605:385;13055:4;13032:21;13028:32;13022:39;13151:4;13128:21;13124:32;13118:39;13654:5;13605;13590:13;13569:19;13562:49;13329:2;13322:5;13318:14;13302:2;13298:35;13291:369;13244:11;;13240:421;13981:5;13926:15;;;13906:36;;13981:5;13840:19;;13812:55;13805:182;13770:2;13766;13762:11;13758:230;13752:236;;12410:1596;;14254:5;14215:2;14207:6;14203:15;14187:2;14183:36;14124:24;14117:143;14086:2;14082;14078:11;14074:187;14068:193;;12326:1949;14349:5;14326:21;14322:33;14316:40;14541:5;14533:4;14513:18;14509:29;14503:36;14429:18;14422:125;14637:5;14614:21;14610:33;14604:40;14925:5;14878:2;14871:5;14867:14;14851:2;14847:35;14785:19;14778:153;14739:2;14735;14731:11;14727:205;14721:211;;14568:386;15020:5;14997:21;14993:33;14987:40;15118:5;15095:21;15091:33;15085:40;15632:5;15582;15567:13;15546:19;15539:49;15302:3;15295:5;15291:15;15274:3;15270:37;15263:375;15213:13;;15209:430;15961:5;15905:16;;;15885:37;;15961:5;15819:19;;15791:55;15784:183;15748:3;15744:2;15740:12;15736:232;15730:238;;14373:1613;;16069:5;16046:21;16042:33;16036:40;16273:5;16265:4;16245:18;16241:29;16235:36;16157:18;16150:129;16378:5;16355:21;16351:33;16345:40;16695:5;16642:3;16635:5;16631:15;16614:3;16610:37;16543:19;16536:165;16491:3;16486;16482:13;16478:224;16471:231;;16304:424;16798:5;16775:21;16771:33;16765:40;16904:5;16881:21;16877:33;16871:40;17447:5;17393;17378:13;17357:19;17350:49;17101:3;17094:5;17090:15;17073:3;17069:37;17062:391;17008:13;;17004:450;17807:5;17746:16;;;17725:38;;17807:5;17654:19;;17626:55;17619:194;17578:3;17573;17569:13;17565:249;17558:256;;16097:1739;;18136:5;18092:3;18084:6;18080:16;18064:2;18060:37;18015:5;18000:13;17974:24;17967:54;17960:182;17916:12;;17912:231;18563:5;;18476:15;;;18456:36;;18563:5;18388:24;;18355:65;18348:186;18316:2;18312;18308:11;18301:268;18263:306;;14288:4295;18663:5;18649:12;18635;18628:41;18720:5;18713;18706;18699:27;18777:5;18770;18763;18756:27;18833:5;18826;18819;18812:27;18800:39;;18597:256;;;10506:8357;;;;;;;;;;;;;:::o

Swarm Source

bzzr://e14a9200510570075fc0caea87bdc267444cce101b681e3365d0ad59a7cfc18e

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.