Expand description
Formal Verification Helpers
This module provides utilities and helpers to support formal verification of cryptographic implementations, including property-based testing, invariant checking, and verification condition generation.
§Features
- Property-based testing: Automatic generation of test cases
- Invariant checking: Runtime verification of cryptographic properties
- Pre/post-condition checking: Function contract verification
- State machine verification: Verify state transitions are valid
- Symbolic execution helpers: Support for symbolic analysis
- Proof obligations: Generate verification conditions
§Example
use chie_crypto::formal_verify::{Invariant, PropertyChecker, check_invariant};
// Define an invariant
let inv = Invariant::new("key_length", |state: &[u8]| {
state.len() == 32
});
// Check the invariant
let key = [0u8; 32];
assert!(inv.check(&key));
// Property-based testing
let mut checker = PropertyChecker::new();
checker.add_property("encryption_decryption_roundtrip", |data: &[u8]| {
// Property: encrypt(decrypt(x)) == x
true // simplified example
});Structs§
- Invariant
- Invariant that must hold for a cryptographic operation
- Post
Condition - Post-condition for a function
- PreCondition
- Pre-condition for a function
- Property
Check Result - Result of property checking
- Property
Checker - Property-based test checker
- Property
Result - Result for a single property
- State
Machine - State machine verifier
- Verification
Condition - Verification condition
Functions§
- check_
invariant - Helper function to check an invariant and panic if it doesn’t hold
- check_
postcondition - Helper function to check a post-condition
- check_
precondition - Helper function to check a pre-condition