lambdaclass / cairo-vm

cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
https://lambdaclass.github.io/cairo-vm
Apache License 2.0
504 stars 138 forks source link

Feature: compute program hash chain #1647

Closed odesenfans closed 5 months ago

odesenfans commented 6 months ago

Problem: computing the hash of a program is useful to verify its integrity. This hash is also used for different purposes, like when loading a program with the bootloader.

Solution: add a program_hash module and the compute_program_hash_chain function that computes the hash of a stripped program, making it usable with Program and CairoPie objects.

Description of the pull request changes and motivation.

Checklist

odesenfans commented 6 months ago

Some more backporting from the bootloader hints. This new module allows to get the hash of a program to replace the functionality of the cairo-hash-program command. I'm integrating that feature in the new Stone CLI and I thought it made sense to integrate it here. Let me know what you think!

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 96.73913% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 96.71%. Comparing base (105ca3a) to head (09e4be2).

Files Patch % Lines
vm/src/program_hash.rs 96.73% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1647 +/- ## ========================================== + Coverage 96.70% 96.71% +0.01% ========================================== Files 95 96 +1 Lines 38154 38246 +92 ========================================== + Hits 36897 36990 +93 + Misses 1257 1256 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

odesenfans commented 5 months ago

This PR seems ready for merging, can anyone give it the second approval? @Oppen @juanbono