Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checksum #17

Closed
wants to merge 6 commits into from
Closed

checksum #17

wants to merge 6 commits into from

Conversation

kaisbaccour
Copy link
Collaborator

@kaisbaccour kaisbaccour commented Jun 11, 2024

Copy link
Contributor

@nikkolasg nikkolasg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR:

  • Can we use standard tools (easier to write scripts as well on our side), and if not, something better than sha2
  • Can we have a single checksum for the whole directory.

Comment on lines +160 to +175
fn verify_checksum(file: &File, expected_checksum: &str) -> anyhow::Result<bool> {
let mut reader = std::io::BufReader::new(file);
let mut hasher = Sha256::new();
let mut buffer = Vec::new();
reader
.read_to_end(&mut buffer)
.context("Failed to read file for checksum verification")?;
hasher.update(&buffer);
let actual_checksum = format!("{:x}", hasher.finalize());
if actual_checksum != expected_checksum {
info!(
"Checksum mismatch: expected {}, but got {}",
expected_checksum, actual_checksum
);
}
Ok(actual_checksum == expected_checksum)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhhh can we maybe use standard tools for this ? it's gonna be easier to port accross platforms and easier to write scripts as well in bash. Like sha256sum or shasum i think. Also probably might be a bit faster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this case, we would have to download + save before checking checksum.
Which is fine for me btw.

Another solution would be to use blake3 which supports reading from mmap and even do stuff in parallel with rayon and blake3 is known to be much faster, even more for large files.

pub fn create_prover(
url: &str,
dir: &str,
circuit_file: &str,
circuit_file_checksum: &str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we simply do the checksum over the whole directory maybe ? Simpler ? It's best to be atomic on this stuff, we don't want to have different versions of the sub-parameters living the same place.

@@ -11,6 +11,7 @@ pub fn create_prover(
url: &str,
dir: &str,
file: &str,
checksum: &str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, can't we do it simply over the whole parameter directory and be done with it ? The individual provers shouldn't have to know about this, they should expect to already get the right version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants