Files
voprf-vx/src/error.rs
T

46 lines
1.6 KiB
Rust
Raw Normal View History

2023-05-22 23:04:39 -07:00
// Copyright (c) Meta Platforms, Inc. and affiliates.
2021-09-09 01:56:54 -07:00
//
2023-05-22 23:04:39 -07:00
// This source code is dual-licensed under either the MIT license found in the
// LICENSE-MIT file in the root directory of this source tree or the Apache
2021-09-27 18:53:06 -07:00
// License, Version 2.0 found in the LICENSE-APACHE file in the root directory
2023-05-22 23:04:39 -07:00
// of this source tree. You may select, at your option, one of the above-listed
// licenses.
2021-09-09 01:56:54 -07:00
2021-12-25 22:54:27 +01:00
//! Errors which are produced during an execution of the protocol
2021-09-09 01:56:54 -07:00
use displaydoc::Display;
2021-12-25 22:54:27 +01:00
/// [`Result`](core::result::Result) shorthand that uses [`Error`].
2022-01-25 05:55:02 +01:00
pub type Result<T, E = Error> = core::result::Result<T, E>;
2021-12-25 22:54:27 +01:00
2021-09-09 01:56:54 -07:00
/// Represents an error in the manipulation of internal cryptographic data
2021-12-21 20:17:02 +01:00
#[derive(Clone, Copy, Debug, Display, Eq, Hash, Ord, PartialEq, PartialOrd)]
2021-12-25 22:54:27 +01:00
pub enum Error {
2022-02-13 04:00:11 -08:00
/// Size of info is longer then [`u16::MAX`].
Info,
2022-01-25 05:55:02 +01:00
/// Size of input is empty or longer then [`u16::MAX`].
Input,
2022-02-13 04:00:11 -08:00
/// Size of info and seed together are longer then `u16::MAX - 3`.
DeriveKeyPair,
2022-01-25 05:55:02 +01:00
/// Failure to deserialize bytes
Deserialization,
/// Batched items are more then [`u16::MAX`] or length don't match.
Batch,
/// In verifiable mode, occurs when the proof failed to verify
2022-01-25 05:55:02 +01:00
ProofVerification,
2022-01-28 01:38:17 +01:00
/// The protocol has failed and can't be completed.
Protocol,
2022-01-25 05:55:02 +01:00
}
/// Only used to implement [`Group`](crate::Group).
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum InternalError {
/// Size of input is empty or longer then [`u16::MAX`].
Input,
/// `input` is longer then [`u16::MAX`].
I2osp,
2021-09-09 01:56:54 -07:00
}
#[cfg(feature = "std")]
2021-12-25 22:54:27 +01:00
impl std::error::Error for Error {}