EVM Verification Contract V0

Stork provides a stateless signature verification contract for EVM-compatible chains that can be used to verify if a provided signature was signed by the relevant, permitted publisher.
This contract is deployed at the following addresses:

Testnet

  • ETH Goerli Testnet: 0x73d7E67F39a4f0831292e90aBA925d70E3432b28
  • Arbitrum Goerli Testnet: 0x1e2922DcFc7922576Cc6DD68AD80CF345eaF15Ad
  • Avalanche Fuji Testnet: 0x2eDF1CfD907faA5c2B68F76C3dcBB92278a5C366

Mainnet

  • Avalanche: 0x1e2922DcFc7922576Cc6DD68AD80CF345eaF15Ad
  • Arbitrum: 0x1e2922DcFc7922576Cc6DD68AD80CF345eaF15Ad
For additional chains, please email [email protected]
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.5.0 <0.9.0;
contract Verify {
function getEthSignedMessageHash32(bytes32 message) private pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", message));
}
function getMessageHash(
address oracle_name,
string memory asset_pair_id,
uint256 timestamp,
uint256 price
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(oracle_name, asset_pair_id, timestamp, price));
}
function getSigner(
bytes32 signed_message_hash,
bytes32 r,
bytes32 s,
uint8 v
) private pure returns (address) {
return ecrecover(signed_message_hash, v, r, s);
}
function verifySignature(
address oracle_pubkey,
string memory asset_pair_id,
uint256 timestamp,
uint256 price,
bytes32 r,
bytes32 s,
uint8 v
) public pure returns (bool) {
bytes32 msg_hash = getMessageHash(oracle_pubkey, asset_pair_id, timestamp, price);
bytes32 signed_message_hash = getEthSignedMessageHash32(msg_hash);
// Verify hash was generated by the actual user
address signer = getSigner(signed_message_hash, r, s, v);
return (signer == oracle_pubkey) ? true : false;
}
}