v0.8.0b2
This release focuses on enhanced security, memory management, and code clarity for the Post-Quantum Feldman VSS library.
Major Highlights:
- Enhanced Memory Management: Implemented a
MemoryMonitor
class and integrated memory safety checks throughout the code to prevent excessive memory allocation and potential denial-of-service vulnerabilities. This drastically improves the library's robustness, especially when dealing with large threshold values and bit lengths. - Improved Error Handling and Forensics: Enhanced exception handling throughout the codebase with more detailed forensic data included in exceptions for debugging/auditing purposes. Added
get_forensic_data
to errors for better debugging. Sanitized errors are used by default to prevent information leakage. - Enhanced Security: Further hardened constant-time operations, Byzantine fault tolerance, and memory safety. Enhanced comments and documentation for security-sensitive areas of the code.
Detailed Changes:
-
Core Security Enhancements:
constant_time_compare
: Added input validation forgmpy2.mpz
types.secure_redundant_execution
: Added a deterministically selected result to prevent timing side-channels, and added a more robust approach for gathering results inconcurrent.futures.ThreadPoolExecutor
._find_secure_pivot
: Updated with constant-time update to minimum value and added more secure swaps. Added improved error check- ensure we're not returning a row with a zero pivot._compute_combined_randomizer
Added type hints for function parameter._process_echo_consistency
: Added input validation and more comprehensive Byzantine evidence collection._detect_byzantine_behavior
: Added more explicit checks for malformed commitments and safer element access. Now explicitly requires passing the zero commitment check.- ``_generate_invalidity_evidence`: Added additional evidence about consistency checks.
secure_exp
: Optimization: For safe primes p=2q+1, reduce modulo q instead of p-1. Check memory safety before proceeding.create_polynomial_proof
: Removed the use ofid()
for commitment keys and replaced it with the use of a secure cryptographic hashing algorithm to generate commitment keys, significantly improving the uniqueness and security of the keys.
-
Memory Management:
MemoryMonitor
Class: Added aMemoryMonitor
class to track allocated memory and prevent exceeding limits.check_allocation
,allocate
,release
,get_usage_stats
: Implemented methods for memory tracking and management.check_memory_safety
: Added comprehensive memory safety checks throughout the code.estimate_mpz_size
: Added a function to estimate memory usage ofgmpy2.mpz
numbers.- Integrated memory safety checks within
CyclicGroup.exp
,CyclicGroup.efficient_multi_exp
,FeldmanVSS._evaluate_polynomial
, andFeldmanVSS._secure_matrix_solve
.
-
Error Handling & Forensic Data:
- Custom Exception Classes: Enhanced
SecurityError
,SerializationError
,VerificationError
, andParameterError
with fields likedetailed_info
,severity
,timestamp
,data_format
,checksum_info
,parameter_name
,parameter_value
, andexpected_type
for more comprehensive error reporting. Addedget_forensic_data
to errors for better debugging. - Detailed Error Messages: Added forensic data collection for debugging/auditing purposes.
- Sanitized Errors: Sanitized errors are used by default to prevent information leakage.
- Enhanced Input Validation: Added additional input validation and logging to various methods.
- Corrected potential errors: Fixed a potential error that might occur if the input was undefined
- Custom Exception Classes: Enhanced
-
Code Quality & Clarity:
- Type Hinting: Added type hints throughout the code for improved readability and maintainability.
- Docstring Improvements: Enhanced docstrings for better clarity and consistency.
- Removed Unnecessary Code: Removed code to free up memory in a class, as it is automatically handled by garbage collector.
- Function Renaming: Renamed memory_safe_mpz_mul to check_memory_safety for more clarity.
-
Bug Fixes:
- Fixed an error with the input type of a function.
-
Dependency Updates:
- Updated
requires-python
version. - Updated
dependencies
version.
- Updated
-
Documentation:
- Updated the documentation to accurately reflect the current codebase.
- Enhanced docstrings throughout the code for better clarity and consistency.
- Updated System Requirements section.
- Added PyPi link.
Breaking Changes:
- Some exceptions now inherit from the custom classes (
SecurityError
,SerializationError
,VerificationError
,ParameterError
) to provide additional diagnostic information. This should be backwards compatible in most cases, but code that specifically catchesException
may need to be updated.
Security Notes:
- This release addresses potential denial-of-service vulnerabilities related to excessive memory allocation.
- This release adds a deterministically selected result to prevent timing side-channels.
- This release adds a challenge consistency check to help detect malicious tampering.
- As a reminder, this library still has timing side-channel and fault injection vulnerabilities that cannot be adequately addressed in pure Python. These issues require implementation in a lower-level language like Rust to fix properly.
Upgrade Notes:
- It is highly recommended to upgrade to this version for improved security and stability.
- Pay special attention to the "Breaking Changes" section if your code relies on catching specific exception types.
Future Work:
- Further hardening of constant-time operations.
- More comprehensive testing and auditing.
- Fixing issues with Type Hints by creating custom stubs