Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/ZKProofVerifier.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract ZKProofVerifier {
struct ProofData {
uint256[8] proof;
uint256[4] publicInputs;
bool verified;
uint256 timestamp;
address verifier;
}
mapping(bytes32 => ProofData) public proofs;
mapping(address => bytes32[]) public userProofs;
uint256 public proofCount;
address public owner;
bool public paused;
event ProofVerified(bytes32 indexed proofHash, address indexed verifier, bool success);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
error OnlyOwner();
error ZeroAddress();
error ContractPaused();
error InvalidProof();
modifier onlyOwner() {
if (msg.sender != owner) revert OnlyOwner();
_;
}
modifier whenNotPaused() {
if (paused) revert ContractPaused();
_;
}
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
function verifyProof(
uint256[8] calldata _proof,
uint256[4] calldata _publicInputs
) external whenNotPaused returns (bool) {
bytes32 proofHash = keccak256(abi.encodePacked(_proof, _publicInputs));
bool isValid = _proof[0] != 0 && _publicInputs[0] != 0;
if (!isValid) revert InvalidProof();
proofs[proofHash] = ProofData({
proof: _proof,
publicInputs: _publicInputs,
verified: isValid,
timestamp: block.timestamp,
verifier: msg.sender
});
userProofs[msg.sender].push(proofHash);
unchecked {
++proofCount;
}
emit ProofVerified(proofHash, msg.sender, isValid);
return isValid;
}
function getUserProofs(address user) external view returns (bytes32[] memory) {
return userProofs[user];
}
function setPaused(bool _paused) external onlyOwner {
paused = _paused;
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function getProof(bytes32 _proofHash) external view returns (ProofData memory) {
return proofs[_proofHash];
}
}"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true
}
}}
Submitted on: 2025-09-29 11:09:03
Comments
Log in to comment.
No comments yet.