-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy patherror.rs
More file actions
54 lines (47 loc) · 1.6 KB
/
error.rs
File metadata and controls
54 lines (47 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! VRF error types
//!
//! This module defines error handling types for Verifiable Random Function (VRF)
//! operations. The error type is intentionally minimal to prevent potential
//! side-channel leaks that could compromise the security of VRF-related
//! cryptographic operations.
use core::{error, fmt};
/// Result type.
///
/// A specialized result type alias for VRF operations, using the [`Error`] type
/// defined in this module.
pub type Result<T> = core::result::Result<T, Error>;
/// VRF errors.
///
/// This type represents errors that may occur during VRF operations. It is
/// designed to be opaque to avoid exposing internal details that could be
/// exploited in cryptographic attacks. Currently, it does not include a source
/// field, but it is marked as `non_exhaustive` to allow for future extensions.
#[derive(Default)]
#[non_exhaustive]
pub struct Error {}
impl Error {
/// Creates a new VRF error.
fn new() -> Self {
Self::default()
}
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("vrf::Error {}")
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("vrf::Error {}")
}
}
impl error::Error for Error {
/// Returns the source of the error, if any.
///
/// Since this implementation does not currently support a source, this
/// method always returns `None`. This behavior may change in future
/// iterations if the error type is extended.
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
None
}
}