When it comes to smart contract development, one of the most important aspects is ensuring that the data being used is secure and tamper-proof. This is especially crucial in applications that involve random number generation, where the potential for manipulation can undermine the integrity of the entire system. This is where HashRanCh, a VRF (Verifiable Random Function) from Scry comes in, providing a secure and verifiable method for generating random numbers in smart contracts.
The VRF hashing process involves several steps, which we will explore in this post. Let's assume we have a value we want to generate a random number for, and a feedID to ensure uniqueness.
The first step is to use the private key (pk) from the oracle as the seed for the VRF hash. This ensures that the hash is unique to the oracle and cannot be manipulated by external factors. We then compute a sequence of hashes starting from the seed. The number of hashes that are computed is determined by subtracting the feedID from 100,000. This is because we want to generate a unique random number for each input value, but we don't want to reveal the seed for future values.
The reason we subtract feedID is that verifiers need to be able to use the proof hash to verify that it came from the same root as the hashes further in the chain without revealing parent seed hashes. By revealing hashes in reverse from last up towards seed we reveal the parent for all hashs that have also been committed to for easy verification that not only the requested data could not have been changed, but all children also could not have been manipulated. By knowing a hash at feedID 100000, you can verify that every hash in 0 to 99999 were created using the same seed.
Once we have computed the sequence of hashes, we hash the VRF seed with the request to get a value. This value can be used wherever needed in the smart contract. The verifiers can then check that the seed for their hash is the parent seed for all other hashes that have been committed but not for future hashes. This ensures that the oracle could not have known the value without knowing the salt that was going to be provided as well as which ID was going to request it at the very start of the oracle's deployment.
In conclusion, the HashRanCh hashing process provides a secure and verifiable method for generating random numbers in smart contracts. By using the private key as the seed and computing a sequence of hashes, we can ensure that the data being used is tamper-proof and cannot be manipulated by the oracle aswell as being guaranteed random. This is crucial for applications that require randomness to function, and ensures that the integrity of the entire system is maintained while decentralized.
Want to be a DLP? Want to source your data from custom oracles that you choose? Want to request any API endpoint, fully onchain, in realtime? https://docs.scry.finance/docs/morpheus/morpehus
Follow us
https://twitter.com/ScryProtocol
Need help?