Skip to main content

voprf_vx/
error.rs

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