Links

How to Verify the Result

The result includes two signatures: the allocator signature and the validator signature. Developers should verify both signatures based on the other returned fields.

Verify Allocator Signature

Encode the allocator message struct

import Web3 from "web3"
const web3 = new Web3()
const taskIdHex = Web3.utils.stringToHex(taskId)
const schemaIdHex = Web3.utils.stringToHex(schemaId)
const encodeParams = web3.eth.abi.encodeParameters(
["bytes32", "bytes32", "address"],
[taskIdHex, schemaIdHex, validatorAddress]
)
const paramsHash = Web3.utils.soliditySha3(encodeParams)

Recover the allocator address

const signedAllocatorAddress = web3.eth.accounts.recover(paramsHash, allocatorSignature)

Check if the signed allocator address is registered. The current allocator address is fixed.

return signedAllocatorAddress === "0x19a567b3b212a5b35bA0E3B600FbEd5c2eE9083d"

Verify Validator Signature

Encode the validator message

import Web3 from "web3"
const web3 = new Web3()
const taskIdHex = Web3.utils.stringToHex(taskId)
const schemaIdHex = Web3.utils.stringToHex(schemaId)
const encodeParams = web3.eth.abi.encodeParameters(
["bytes32", "bytes32", "bytes32", "bytes32"],
[taskIdHex, schemaIdHex, uHash, publicFieldsHash]
)
const paramsHash = Web3.utils.soliditySha3(encodeParams)

Recover the validator address

const signedValidatorAddress = web3.eth.accounts.recover(paramsHash, validatorSignature)

Verify if the signed validator address matches the address assigned by the allocator

return signedValidatorAddress === validatorAddress
Here, we've only given the reference code for off-chain verification. However, the result can also be verified on-chain.
Feel free to contact us if you have any ideas