Verify Proof
To verify the proof on chain you'll need to integrate the verifyProof
function which has been separated into a second part, recoverSigner
for legibility.
How The Proof Validation Works
Proof validation involves a few key steps:
Recreating the Original Message:
The message that was signed to generate the proof is recreated. This message consists of the seed and request ID, which are unique to each randomness request.
Recovering the Signer Address:
Using the proof (which is the cryptographic signature), the contract can recover the address of the signer. This is done using the
ecrecover
function, a standard Ethereum operation that retrieves the signer address from a message and its corresponding signature.
Verifying the Signer:
The recovered address is then compared to the VRF public key. If they match, the proof is valid, meaning the random number was indeed generated by the VRF private key.
All these functions work together in the next complete example contract to provide you fully verified randomness on chain.
Last updated