Expand description
Error types for clock-curve-math.
This module defines the comprehensive error types used throughout the clock-curve-math library for cryptographic operations.
§Error Categories
Errors are categorized by the type of validation or operation failure:
§Input Validation Errors
MathError::InvalidBytes: Byte representation out of valid rangeMathError::InvalidInput: General invalid input parameterMathError::InvalidFieldElement: Field element not in [0, p)MathError::InvalidScalar: Scalar not in [0, l)MathError::InvalidExponent: Invalid exponent for exponentiationMathError::InvalidModulus: Invalid modulus for modular operationsMathError::InvalidEncoding: Invalid encoding format
§Buffer Errors
MathError::BufferTooSmall: Input buffer smaller than required sizeMathError::BufferTooLarge: Input buffer larger than required size
§Arithmetic Errors
MathError::DivisionByZero: Attempted division by zero or modular inverse of zeroMathError::Overflow: Arithmetic overflow in operationsMathError::Underflow: Arithmetic underflow in operations
§Future Extension Errors
MathError::PointNotOnCurve: Point not on elliptic curve (for future EC operations)MathError::InvalidMontgomeryForm: Invalid Montgomery form representation
§Error Handling
Most operations return Result<T, MathError> to allow callers to handle
errors appropriately. Some operations (like basic arithmetic) may panic
on invalid inputs for security reasons, while others provide checked
variants that return errors.
use clock_curve_math::{FieldElement, MathError};
// Operations that return errors
let result = FieldElement::from_bytes(&[0u8; 32]);
match result {
Ok(element) => println!("Valid field element: {:?}", element),
Err(MathError::InvalidFieldElement) => println!("Invalid field element"),
Err(e) => println!("Other error: {:?}", e),
}Enums§
- Math
Error - Errors that can occur in mathematical operations.