Skip to content

fix(attestation): hash evidence counts as u64 on every platform - #262

Open
hyperpolymath wants to merge 1 commit into
mainfrom
claude/gallant-bell-4bo4oy-i-evidence-u64
Open

hyperpolymath wants to merge 1 commit into
mainfrom
claude/gallant-bell-4bo4oy-i-evidence-u64

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Closes the "evidence_hash hashes usize::to_le_bytes" follow-up from #247.

Problem

EvidenceAccumulator::finalize fed files_read to SHA-256 as usize::to_le_bytes. A 32-bit build hashed 4 bytes where a 64-bit build hashed 8, so the same scan produced different evidence hashes on different platforms, and a verifier on another platform couldn't recompute them.

Fix

  • files_read is widened to u64 before hashing, like bytes_read and wall_clock_ms already are.
  • On 64-bit platforms the hashed bytes are identical, so every existing evidence hash is unchanged. 32-bit builds now agree with them.
  • The computation moves to a public attestation::evidence::evidence_hash function, so a verifier can recompute it, and the doc comment now states the encoding.

Validation

  • New test evidence_hash_known_answer. The expected value comes from coreutils, not the crate:
    printf 'nonce\002\0\0\0\0\0\0\0\350\003\0\0\0\0\0\0rolling\007\0\0\0\0\0\0\0' | sha256sum
    
  • cargo fmt --check, plus cargo clippy --locked --all-targets -D warnings with and without --all-features: clean.
  • cargo test --locked --all-features: all suites green (lib: 524 passed).

Generated by Claude Code

The evidence hash fed files_read to SHA-256 as usize::to_le_bytes, so a
32-bit build hashed 4 bytes where a 64-bit build hashed 8, and the same
scan produced different evidence hashes. files_read is now widened to
u64 like bytes_read and wall_clock_ms. On 64-bit platforms the bytes,
and so every existing hash, are unchanged.

The computation moves to a pub evidence_hash function with a
known-answer test whose expected value comes from coreutils sha256sum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PFaqv6iBXrt3W5Akd1Fq5k
Copilot AI balanced review requested due to automatic review settings November 5, 2026 00:05
@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 5, 2026 00:05
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3c0b7399-202c-46b5-a8b2-48185c1864ab
Commits

Reviewing files that changed from the base of the PR and between 5175a68 and 7cadaa5.

Files selected for processing: 2

  • CHANGELOG.adoc
  • src/attestation/evidence.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T00:07:01.719302Z 7cadaa5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

3 participants