Integrity allows you to verify STARK proofs on Starknet. It also registers all verified proofs in its storage, so other Cairo contracts can access them. It is crucial to understand how programs are stored inside Integrity’s Fact Registry.
program_hash
and output_hash
. They are Poseidon hashes of corresponding memory sections. Then, those two hashes are hashed together to get fact_hash
.
fact_hash
(or better verification_hash
) to Integrity’s function. Usually you would verify proofs for some constant set of programs with arbitrary input and output, which means that you can hardcode program_hash
while calculating output_hash
and fact_hash
dynamically.
However, as is usually the case, the reality is more complicated. To reduce public memory size, Cairo programs are often bootloaded, which means that your program isn’t run directly, but rather a special program called “bootloader” is placed in program segment, which is responsible for loading your program (called child program) to memory, executing it and calculating program_hash
of the child program. This means that every bootloaded program will have the same program_hash
and the program_hash
of child program will only be present in bootloader’s output. This flow and hash calculation is represented in the following diagram:
calculate_fact_hash
and calculate_bootloaded_fact_hash
. For more details, see “Calls from Starknet contracts” section in Integrity documentation.
If you have fact_hash
calculated, you can call integrity’s get_all_verifications_for_fact_hash
function to check whether given fact_hash
has been verified. However, because Integrity accepts proofs with many settings and any number of security bits, you need to check if the proof has been verified with enough number of security bits. For that you can use is_fact_hash_valid_with_security
utility function.
Here is an example of how to use those functions:
verification_hash
, which is composed from fact_hash
, configuration and security bits. That means that no additional checks are needed.
verification_hash
:
program_hash
and output array, but also supports proof uploading, so you can get data directly from it.