Skip to content

[z3-verifier] Formal verification of SHA-256 against FIPS 180-4#1386

Draft
0xAndoroid wants to merge 1 commit intomainfrom
sha256-formal-verification
Draft

[z3-verifier] Formal verification of SHA-256 against FIPS 180-4#1386
0xAndoroid wants to merge 1 commit intomainfrom
sha256-formal-verification

Conversation

@0xAndoroid
Copy link
Copy Markdown
Collaborator

@0xAndoroid 0xAndoroid commented Mar 30, 2026

This is an experiment. Ignore it for now

Summary

  • Adds Z3 bit-vector formal verification of Jolt's SHA-256 inline implementation against FIPS 180-4
  • Proves correctness of optimized primitives (ANDN-based Ch, (B&C)^(A&(B^C)) Maj) for all 32-bit inputs
  • Validates constants, sigma functions, message schedule, round function, and NIST test vectors
  • All 15 tests run in ~130ms total

What is verified

Property Method Status
K[], H[] constants match FIPS 180-4 Direct assertion PASS
Ch: (E&F)^(G&~E)(x∧y)⊕(¬x∧z) Z3 ∀-quantified BV32 PASS
Maj: (B&C)^(A&(B^C))(x∧y)⊕(x∧z)⊕(y∧z) Z3 ∀-quantified BV32 PASS
Σ₀, Σ₁, σ₀, σ₁ decomposition Z3 ∀-quantified BV32 PASS
Message schedule W expansion Z3 ∀-quantified BV32 PASS
Single round T1/T2/state update Z3 ∀-quantified BV32 PASS
Z3 spec model → NIST output Concrete BV evaluation PASS
exec.rs → NIST vectors (3 blocks) Concrete Rust computation PASS
Initial IV correctness Concrete comparison PASS
Full 64-round symbolic equivalence Z3 ∀-quantified (ignored, slow) Available

Test plan

  • cargo nextest run -p z3-verifier -E 'test(sha256)' — 15/15 pass
  • cargo clippy -p z3-verifier -- -D warnings — clean
  • cargo fmt -- --check — clean
  • Requires libz3 (brew install z3 pkg-config on macOS)

@0xAndoroid 0xAndoroid marked this pull request as draft March 30, 2026 21:48
Verify the Jolt SHA-256 inline implementation using Z3 bit-vector
theory. Properties proven for all 32-bit inputs:

- K[] and H[] constants match FIPS 180-4 §4.2.2 / §5.3.3
- Optimized Ch (ANDN-based) ≡ spec Ch(x,y,z) = (x∧y)⊕(¬x∧z)
- Optimized Maj ((B&C)⊕(A&(B⊕C))) ≡ spec Maj
- Σ₀, Σ₁, σ₀, σ₁ decompositions match spec
- Message schedule W expansion is correct
- Single-round T1/T2/state-update matches spec
- Z3 spec model produces correct NIST test vector outputs
- exec.rs compression matches NIST vectors (3 concrete tests)
- execute_sha256_compression_initial uses correct FIPS IV

Full 64-round symbolic equivalence is available as an ignored test
for manual runs (too slow for CI).
@0xAndoroid 0xAndoroid force-pushed the sha256-formal-verification branch from 50b8396 to 4d449ed Compare March 31, 2026 15:43
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.

1 participant