doughnut_rs/error.rs
1// Copyright 2023-2024 Futureverse Corporation Limited
2
3#![allow(clippy::module_name_repetitions)]
4
5/// Error type for codec failures
6#[derive(PartialEq, Eq, Clone, Debug)]
7pub enum CodecError {
8 /// The doughnut version is unsupported by the current codec
9 UnsupportedVersion,
10 /// Invalid encoded format found while decoding
11 BadEncoding,
12}
13
14/// Error type for validation failures
15#[derive(PartialEq, Eq, Clone, Debug)]
16pub enum ValidationError {
17 /// Public key attempting to use a doughnut does not match the issued holder
18 HolderIdentityMismatched,
19 /// The doughnut has expired against the current timestamp
20 Expired,
21 /// Doughnut use precedes it's 'not before' timestamp, thus it has not matured yet.
22 Premature,
23 /// A type conversion failed during validation e.g overflow
24 Conversion,
25}
26
27/// A signature verification error
28#[derive(PartialEq, Debug)]
29pub enum VerifyError {
30 /// Unsupported signature version
31 UnsupportedVersion,
32 /// Signature format is invalid
33 BadSignatureFormat,
34 /// PublicKey format is invalid
35 BadPublicKeyFormat,
36 /// Message payload format is invalid
37 BadPayloadFormat,
38 /// The signature does not verify the payload from signer
39 Invalid,
40}
41
42/// A signature signing error
43#[derive(PartialEq, Debug)]
44pub enum SigningError {
45 /// Provided public/secret key is invalid ed25519 signing
46 InvalidEd25519Key,
47 /// Provided public key is invalid for sr25519 signing
48 InvalidSr25519PublicKey,
49 /// Provided secret key is invalid for sr25519 signing
50 InvalidSr25519SecretKey,
51 /// Provided secret key is invalid for ECDSA signing
52 InvalidECDSASecretKey,
53 /// Provided payload is invalid
54 InvalidPayload,
55 /// Not supported
56 NotSupported,
57}