voprf_ng/error.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Errors which are produced during an execution of the protocol
4
5/// [`Result`](core::result::Result) shorthand that uses [`Error`].
6pub type Result<T, E = Error> = core::result::Result<T, E>;
7
8/// Represents an error in the manipulation of internal cryptographic data
9#[derive(Clone, Copy, Debug, displaydoc::Display, Eq, Hash, Ord, PartialEq, PartialOrd)]
10pub enum Error {
11 /// Size of info is longer then [`u16::MAX`].
12 Info,
13 /// Size of input is empty or longer then [`u16::MAX`].
14 Input,
15 /// Size of info and seed together are longer then `u16::MAX - 3`.
16 DeriveKeyPair,
17 /// Failure to deserialize bytes
18 Deserialization,
19 /// Batched items are more then [`u16::MAX`] or length don't match.
20 Batch,
21 /// In verifiable mode, occurs when the proof failed to verify
22 ProofVerification,
23 /// The protocol has failed and can't be completed.
24 Protocol,
25 /// Random number generator failure.
26 Rng,
27}
28
29/// Only used to implement [`Group`](crate::Group).
30#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub enum InternalError {
32 /// Size of input is empty or longer then [`u16::MAX`].
33 Input,
34 /// `input` is longer then [`u16::MAX`].
35 I2osp,
36}
37
38impl core::error::Error for Error {}