Verifying a trusted location proof on-chain consists of a call to the IoTeX location Verifier contract.
The official Verifier Contracts are deployed to the following addresses:
Using the Verifier
From inside your smart contract, you can import the deployed instance of the Verifier like below:
pragmasolidity ^0.8.0;import"../interface/IGeoLocationDataVerifier.sol";IGeoLocationDataVerifier public verifier;contract YourContractName { IGeoLocationDataVerifier public verifier;// Construct the contract using the official GeoStream Verifier addressconstructor(address_verifier) { verifier =IGeoLocationDataVerifier(_verifier); }// ... }
You should then use the Verifier in the section of your contract logic where the Proof of Location is required:
// ...function_someLogicThatNeedsProofOfLocation(address deviceowner,int256 latitude,int256 longitude,uint256 distance,bytes32 deviceHash,uint256 fromTimestamp,uint256 toTimestamp,bytesmemory signature ) {// Generate the hash of the proofbytes32 digest = verifier.generateLocationDistanceDigest( deviceOwner, latitude, longitude, distance, deviceHash, fromTimestamp, toTimestamp);// Require the proof is validrequire(verifier.verify(digest, signature),"Invalid proof signature");// Your custom logic here// ...
Learn more: Verifier Contract Source
The source code of the Verifier contract can be found on GitHub: