Verified contractPartialGPL-3.0
SwapGroth16VerifierEVM1x6x1
Address0x2592e6c9e5a493598bd29fec0cddced99227d0b6
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 500 runs
- EVM version
- paris
- License
- GPL-3.0
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,595,227
- Creation transaction
- 0x12dd09f33f…391f43472a
contracts/swap/SwapGroth16VerifierEVM1x6x1.sol
// SPDX-License-Identifier: GPL-3.0
/*
Copyright 2021 0KIMS association.
This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
snarkJS is a free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
snarkJS is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with snarkJS. If not, see <https://www.gnu.org/licenses/>.
*/
// NOTE: The original source of this contract is not public. This file was reconstructed from the
// deployed bytecode: it is the snarkJS Groth16 verifier template with the verification key read
// from the bytecode. It compiles to the deployed bytecode (solc 0.8.28, optimizer 500 runs,
// evmVersion paris) except for the metadata hash. The contract name is not the original one.
pragma solidity >=0.7.0 <0.9.0;
contract SwapGroth16VerifierEVM1x6x1 {
// Scalar field size
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
// Base field size
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
// Verification Key data
uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
uint256 constant deltax1 = 16310488507067688127105933105770681467321336519564911172827925975166639432739;
uint256 constant deltax2 = 2847082303475991555657214073433747206458277903464500137418397967554327893509;
uint256 constant deltay1 = 17059784132470694833372764050038998431583175612494844952184636260423927484894;
uint256 constant deltay2 = 12764573454508450255132054793939660258851767999675269340581149387039069827431;
uint256 constant IC0x = 14941983257681715095440181146769684907514740868905521484696175597201804613733;
uint256 constant IC0y = 5774858022317158139633054824034545243407378061095148753997646802446116167324;
uint256 constant IC1x = 10609080682808774118559151507805320905036373343171725109022032941381428052053;
uint256 constant IC1y = 21728274030270314280079645853602276463938610949272719057745076573446716596589;
uint256 constant IC2x = 21584682665484856794482517309162284490144551322197865403552465307603978352296;
uint256 constant IC2y = 11444105402060723095749673076727249091681687547298883860841549675411124143018;
uint256 constant IC3x = 4473300815456168011371006802909723260147580445995038156031259411302823567835;
uint256 constant IC3y = 5944732300168349211859219392588786304173024699453966736131626570587148436694;
uint256 constant IC4x = 11228390294415226295455440977960198605282459839084944458247717887714625826681;
uint256 constant IC4y = 9169194420990034994809566430842161392854594878389198537516930848190255704124;
uint256 constant IC5x = 12603230573140067126363973785148829521773141190426573205019072892674519860084;
uint256 constant IC5y = 21711842026342086356390279506121140942736465547415927101497051132796116475837;
uint256 constant IC6x = 11670962683849614499192147632185471265887949103536304651198535312598001136625;
uint256 constant IC6y = 19826145108695977296998554611508819390584169844962614046526467624717054867967;
uint256 constant IC7x = 2415602911133867913572218799635909865092865102375303792212096152983027467621;
uint256 constant IC7y = 12964774547829181342973118108521738106277948580043018469934369612122413396424;
uint256 constant IC8x = 11839045201862009485583715072585159025637547285664217287404080552865918961397;
uint256 constant IC8y = 10531909136631236970615952663088112711540438160585829172475640304214140107508;
uint256 constant IC9x = 2427789054552812168748361393253702281551730692832415067506860950471702523714;
uint256 constant IC9y = 14019528236012045270233811555151174338246303710269627192752279521841698829920;
uint256 constant IC10x = 1794169842431474944126500892366600082228061049932667555148611586145443054786;
uint256 constant IC10y = 18994489162516405588086998599483642205158949967722387953771432602177693032898;
uint256 constant IC11x = 9913248266716973407638647317014568957160401777473131376813628616071554448491;
uint256 constant IC11y = 6998969907972759136438675137978633248332242311986765251732968524055798758866;
uint256 constant IC12x = 4725171575778379649141196889687546765580386257077246393131861451329457087577;
uint256 constant IC12y = 5252520455677595736199107400652719411177879276294976530096643318126242568622;
uint256 constant IC13x = 18935690475472247628497944868031039480601895077945945420552432447057690206032;
uint256 constant IC13y = 9474805051155307846995472428752765472953556345290739247847956686442643349780;
uint256 constant IC14x = 20708043658288613229651543199263878949719330044371454547665252018442595869215;
uint256 constant IC14y = 11079029324162483943452079193810655092157012825671400467050874275609787862918;
uint256 constant IC15x = 2804121824591601872343928083976174279116701898038340877539470242410369540796;
uint256 constant IC15y = 16772710115336642163274873204018867701877695339580041162698365041255580474588;
uint256 constant IC16x = 15060806102381826066408267033342354764507480134174111166725009326622758616193;
uint256 constant IC16y = 13208752201437050779270815803955596462519829607317792749232307639952501125823;
uint256 constant IC17x = 17169584963721510802177216904446090459143965039486146922146332511479016682893;
uint256 constant IC17y = 7160044835631891911609509011419497565577942841929794322102345112613334013833;
uint256 constant IC18x = 12539089269436380186658324225109641714235760844850388261216671807421638092986;
uint256 constant IC18y = 4526372039522079371185266997512649336045378016585134624500207917816359832917;
uint256 constant IC19x = 8011504778160094154160929539220190399550176284522904850958963435193845810440;
uint256 constant IC19y = 18968665664367206175436223296811764261536057318598265269374399748545137159651;
// Memory data
uint16 constant pVk = 0;
uint16 constant pPairing = 128;
uint16 constant pLastMem = 896;
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[19] calldata _pubSignals) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
mstore(0, 0)
return(0, 0x20)
}
}
// G1 function to multiply a G1 value(x,y) to value in an address
function g1_mulAccC(pR, x, y, s) {
let success
let mIn := mload(0x40)
mstore(mIn, x)
mstore(add(mIn, 32), y)
mstore(add(mIn, 64), s)
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
if iszero(success) {
mstore(0, 0)
return(0, 0x20)
}
mstore(add(mIn, 64), mload(pR))
mstore(add(mIn, 96), mload(add(pR, 32)))
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
if iszero(success) {
mstore(0, 0)
return(0, 0x20)
}
}
function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
let _pPairing := add(pMem, pPairing)
let _pVk := add(pMem, pVk)
mstore(_pVk, IC0x)
mstore(add(_pVk, 32), IC0y)
// Compute the linear combination vk_x
g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
// B
mstore(add(_pPairing, 64), calldataload(pB))
mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
// alpha1
mstore(add(_pPairing, 192), alphax)
mstore(add(_pPairing, 224), alphay)
// beta2
mstore(add(_pPairing, 256), betax1)
mstore(add(_pPairing, 288), betax2)
mstore(add(_pPairing, 320), betay1)
mstore(add(_pPairing, 352), betay2)
// vk_x
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
// gamma2
mstore(add(_pPairing, 448), gammax1)
mstore(add(_pPairing, 480), gammax2)
mstore(add(_pPairing, 512), gammay1)
mstore(add(_pPairing, 544), gammay2)
// C
mstore(add(_pPairing, 576), calldataload(pC))
mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
// delta2
mstore(add(_pPairing, 640), deltax1)
mstore(add(_pPairing, 672), deltax2)
mstore(add(_pPairing, 704), deltay1)
mstore(add(_pPairing, 736), deltay2)
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
isOk := and(success, mload(_pPairing))
}
let pMem := mload(0x40)
mstore(0x40, add(pMem, pLastMem))
// Validate that all evaluations ∈ F
checkField(calldataload(add(_pubSignals, 0)))
checkField(calldataload(add(_pubSignals, 32)))
checkField(calldataload(add(_pubSignals, 64)))
checkField(calldataload(add(_pubSignals, 96)))
checkField(calldataload(add(_pubSignals, 128)))
checkField(calldataload(add(_pubSignals, 160)))
checkField(calldataload(add(_pubSignals, 192)))
checkField(calldataload(add(_pubSignals, 224)))
checkField(calldataload(add(_pubSignals, 256)))
checkField(calldataload(add(_pubSignals, 288)))
checkField(calldataload(add(_pubSignals, 320)))
checkField(calldataload(add(_pubSignals, 352)))
checkField(calldataload(add(_pubSignals, 384)))
checkField(calldataload(add(_pubSignals, 416)))
checkField(calldataload(add(_pubSignals, 448)))
checkField(calldataload(add(_pubSignals, 480)))
checkField(calldataload(add(_pubSignals, 512)))
checkField(calldataload(add(_pubSignals, 544)))
checkField(calldataload(add(_pubSignals, 576)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 500,
"enabled": true
},
"evmVersion": "paris",
"remappings": [
"@openzeppelin/=node_modules/@openzeppelin/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.