Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x825a2ee2af3af4d24936637d378e40d951f15857e604bea57d3b4331022bdeda | 0x61150861 | 54934299 | 242 days 16 hrs ago | 0x70ea9b5d0c5b0f73fd3574f0f3620ff515aa31ed | IN | Create: Pairing | 0 ETH | 0.00047984 |
[ Download CSV Export ]
Contract Name:
Pairing
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// Copyright 2017 Christian Reitwiessner // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // The following Pairing library is a modified version adapted to Semaphore. // // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; library Pairing { error Semaphore__InvalidProof(); // The prime q in the base field F_q for G1 uint256 constant BASE_MODULUS = 21888242871839275222246405745257275088696311157297823662689037894645226208583; // The prime moludus of the scalar field of G1. uint256 constant SCALAR_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617; struct G1Point { uint256 X; uint256 Y; } // Encoding of field elements is: X[0] * z + X[1] struct G2Point { uint256[2] X; uint256[2] Y; } /// @return the generator of G1 function P1() public pure returns (G1Point memory) { return G1Point(1, 2); } /// @return the generator of G2 function P2() public pure returns (G2Point memory) { return G2Point( [ 11559732032986387107991004021392285783925812861821192530917403151452391805634, 10857046999023057135944570762232829481370756359578518086990519993285655852781 ], [ 4082367875863433681332203403145435568316851327593401208105741076214120093531, 8495653923123431417604973247489272438418190587263600148770280649306958101930 ] ); } /// @return r the negation of p, i.e. p.addition(p.negate()) should be zero. function negate(G1Point memory p) public pure returns (G1Point memory r) { if (p.X == 0 && p.Y == 0) { return G1Point(0, 0); } // Validate input or revert if (p.X >= BASE_MODULUS || p.Y >= BASE_MODULUS) { revert Semaphore__InvalidProof(); } // We know p.Y > 0 and p.Y < BASE_MODULUS. return G1Point(p.X, BASE_MODULUS - p.Y); } /// @return r the sum of two points of G1 function addition(G1Point memory p1, G1Point memory p2) public view returns (G1Point memory r) { // By EIP-196 all input is validated to be less than the BASE_MODULUS and form points // on the curve. uint256[4] memory input; input[0] = p1.X; input[1] = p1.Y; input[2] = p2.X; input[3] = p2.Y; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) } if (!success) { revert Semaphore__InvalidProof(); } } /// @return r the product of a point on G1 and a scalar, i.e. /// p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p. function scalar_mul(G1Point memory p, uint256 s) public view returns (G1Point memory r) { // By EIP-196 the values p.X and p.Y are verified to less than the BASE_MODULUS and // form a valid point on the curve. But the scalar is not verified, so we do that explicitelly. if (s >= SCALAR_MODULUS) { revert Semaphore__InvalidProof(); } uint256[3] memory input; input[0] = p.X; input[1] = p.Y; input[2] = s; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) } if (!success) { revert Semaphore__InvalidProof(); } } /// Asserts the pairing check /// e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 /// For example pairing([P1(), P1().negate()], [P2(), P2()]) should succeed function pairingCheck(G1Point[] memory p1, G2Point[] memory p2) public view { // By EIP-197 all input is verified to be less than the BASE_MODULUS and form elements in their // respective groups of the right order. if (p1.length != p2.length) { revert Semaphore__InvalidProof(); } uint256 elements = p1.length; uint256 inputSize = elements * 6; uint256[] memory input = new uint256[](inputSize); for (uint256 i = 0; i < elements; i++) { input[i * 6 + 0] = p1[i].X; input[i * 6 + 1] = p1[i].Y; input[i * 6 + 2] = p2[i].X[0]; input[i * 6 + 3] = p2[i].X[1]; input[i * 6 + 4] = p2[i].Y[0]; input[i * 6 + 5] = p2[i].Y[1]; } uint256[1] memory out; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) } if (!success || out[0] != 1) { revert Semaphore__InvalidProof(); } } }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"name":"Semaphore__InvalidProof","type":"error"},{"inputs":[],"name":"P1","outputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"P2","outputs":[{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"p1","type":"tuple"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"p2","type":"tuple"}],"name":"addition","outputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"r","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"p","type":"tuple"}],"name":"negate","outputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"r","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point[]","name":"p1","type":"tuple[]"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point[]","name":"p2","type":"tuple[]"}],"name":"pairingCheck","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"p","type":"tuple"},{"internalType":"uint256","name":"s","type":"uint256"}],"name":"scalar_mul","outputs":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"r","type":"tuple"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
611508610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061006c5760003560e01c806318c77c95146100715780631de21b76146100a15780632f3ed539146100bf57806330332aea146100db5780636e1b6990146100f9578063a680077514610129575b600080fd5b61008b6004803603810190610086919061108a565b610159565b60405161009891906111de565b60405180910390f35b6100a96102da565b6040516100b691906111de565b60405180910390f35b6100d960048036038101906100d49190610ff5565b6102fe565b005b6100e3610951565b6040516100f091906111f9565b60405180910390f35b610113600480360381019061010e91906110c6565b610a1b565b60405161012091906111de565b60405180910390f35b610143600480360381019061013e9190611061565b610ba9565b60405161015091906111de565b60405180910390f35b610161610cca565b610169610ce4565b8360000151816000600481106101a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020181815250508360200151816001600481106101f0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050826000015181600260048110610238577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050826020015181600360048110610280577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050600060608360c08460066107d05a03fa9050806102d2576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b6102e2610cca565b6040518060400160405280600181526020016002815250905090565b8051825114610339576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600082519050600060068261034e919061133a565b905060008167ffffffffffffffff811115610392577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156103c05781602001602082028036833780820191505090505b50905060005b838110156108a557858181518110610407577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160000151826000600684610423919061133a565b61042d91906112e4565b81518110610464577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508581815181106104a9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151602001518260016006846104c5919061133a565b6104cf91906112e4565b81518110610506577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505084818151811061054b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160000151600060028110610590577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201518260026006846105a5919061133a565b6105af91906112e4565b815181106105e6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505084818151811061062b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160000151600160028110610670577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151826003600684610685919061133a565b61068f91906112e4565b815181106106c6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505084818151811061070b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160200151600060028110610750577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151826004600684610765919061133a565b61076f91906112e4565b815181106107a6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508481815181106107eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160200151600160028110610830577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151826005600684610845919061133a565b61084f91906112e4565b81518110610886577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001018181525050808061089d90611403565b9150506103c6565b506108ae610d06565b6000602082602086026020860160086107d05a03fa90508015806109115750600182600060018110610909577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015114155b15610948576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050505050565b610959610d28565b604051806040016040528060405180604001604052807f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c281526020017f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed815250815260200160405180604001604052807f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b81526020017f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa815250815250905090565b610a23610cca565b7f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018210610a7c576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a84610d4e565b836000015181600060038110610ac3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050836020015181600160038110610b0b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020181815250508281600260038110610b4f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050600060608360808460076107d05a03fa905080610ba1576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b610bb1610cca565b60008260000151148015610bc9575060008260200151145b15610bec5760405180604001604052806000815260200160008152509050610cc5565b7f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd478260000151101580610c4357507f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47826020015110155b15610c7a576040517f4aa6bc4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405180604001604052808360000151815260200183602001517f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47610cbf9190611394565b81525090505b919050565b604051806040016040528060008152602001600081525090565b6040518060800160405280600490602082028036833780820191505090505090565b6040518060200160405280600190602082028036833780820191505090505090565b6040518060400160405280610d3b610d70565b8152602001610d48610d70565b81525090565b6040518060600160405280600390602082028036833780820191505090505090565b6040518060400160405280600290602082028036833780820191505090505090565b6000610da5610da084611239565b611214565b90508083825260208201905082856040860282011115610dc457600080fd5b60005b85811015610df45781610dda8882610f48565b845260208401935060408301925050600181019050610dc7565b5050509392505050565b6000610e11610e0c84611265565b611214565b90508083825260208201905082856080860282011115610e3057600080fd5b60005b85811015610e605781610e468882610f94565b845260208401935060808301925050600181019050610e33565b5050509392505050565b6000610e7d610e7884611291565b611214565b90508082856020860282011115610e9357600080fd5b60005b85811015610ec35781610ea98882610fe0565b845260208401935060208301925050600181019050610e96565b5050509392505050565b600082601f830112610ede57600080fd5b8135610eee848260208601610d92565b91505092915050565b600082601f830112610f0857600080fd5b8135610f18848260208601610dfe565b91505092915050565b600082601f830112610f3257600080fd5b6002610f3f848285610e6a565b91505092915050565b600060408284031215610f5a57600080fd5b610f646040611214565b90506000610f7484828501610fe0565b6000830152506020610f8884828501610fe0565b60208301525092915050565b600060808284031215610fa657600080fd5b610fb06040611214565b90506000610fc084828501610f21565b6000830152506040610fd484828501610f21565b60208301525092915050565b600081359050610fef816114bb565b92915050565b6000806040838503121561100857600080fd5b600083013567ffffffffffffffff81111561102257600080fd5b61102e85828601610ecd565b925050602083013567ffffffffffffffff81111561104b57600080fd5b61105785828601610ef7565b9150509250929050565b60006040828403121561107357600080fd5b600061108184828501610f48565b91505092915050565b6000806080838503121561109d57600080fd5b60006110ab85828601610f48565b92505060406110bc85828601610f48565b9150509250929050565b600080606083850312156110d957600080fd5b60006110e785828601610f48565b92505060406110f885828601610fe0565b9150509250929050565b600061110e83836111cf565b60208301905092915050565b611123816112c1565b61112d81846112d9565b9250611138826112b7565b8060005b838110156111695781516111508782611102565b965061115b836112cc565b92505060018101905061113c565b505050505050565b60408201600082015161118760008501826111cf565b50602082015161119a60208501826111cf565b50505050565b6080820160008201516111b6600085018261111a565b5060208201516111c9604085018261111a565b50505050565b6111d8816113c8565b82525050565b60006040820190506111f36000830184611171565b92915050565b600060808201905061120e60008301846111a0565b92915050565b600061121e61122f565b905061122a82826113d2565b919050565b6000604051905090565b600067ffffffffffffffff8211156112545761125361147b565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156112805761127f61147b565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156112ac576112ab61147b565b5b602082029050919050565b6000819050919050565b600060029050919050565b6000602082019050919050565b600081905092915050565b60006112ef826113c8565b91506112fa836113c8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561132f5761132e61144c565b5b828201905092915050565b6000611345826113c8565b9150611350836113c8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156113895761138861144c565b5b828202905092915050565b600061139f826113c8565b91506113aa836113c8565b9250828210156113bd576113bc61144c565b5b828203905092915050565b6000819050919050565b6113db826114aa565b810181811067ffffffffffffffff821117156113fa576113f961147b565b5b80604052505050565b600061140e826113c8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156114415761144061144c565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6114c4816113c8565b81146114cf57600080fd5b5056fea2646970667358221220f8a2750904ec6bdc8f5fe9ae5cda6a5c14e05cfc7b874f56ada5747fda0569b364736f6c63430008040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.