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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Error types for the falcon-multisig library.
use thiserror::Error;
/// All errors that can be produced by this library.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
/// The supplied public key has an incorrect byte length.
///
/// Falcon-512 public keys must be exactly [`crate::PUBLIC_KEY_BYTES`] bytes.
#[error("invalid public key length: expected {expected} bytes, got {actual}")]
InvalidPublicKeyLength {
/// The required length.
expected: usize,
/// The actual length received.
actual: usize,
},
/// The supplied signature has an incorrect or out-of-range byte length.
#[error("invalid signature length: {actual} bytes (valid range {min}..={max})")]
InvalidSignatureLength {
/// Actual length received.
actual: usize,
/// Inclusive minimum valid length.
min: usize,
/// Inclusive maximum valid length.
max: usize,
},
/// Cryptographic verification of a Falcon-512 signature failed.
///
/// This is returned by [`crate::verify::verify_partial`] and
/// [`crate::session::SigningSession::add_signature`] when the raw
/// Falcon-512 check does not pass.
#[error("signature verification failed for signer index {index}")]
VerificationFailed {
/// Zero-based index of the signer whose signature failed.
index: usize,
},
/// The public key provided during signing does not belong to the configured committee.
#[error("signer index {index} is out of range for a {total}-member committee")]
SignerIndexOutOfRange {
/// The index that was supplied.
index: usize,
/// The total number of committee members.
total: usize,
},
/// A signature for this index has already been recorded in the session.
#[error("duplicate signature: index {index} has already been signed")]
DuplicateSignature {
/// The index that was supplied twice.
index: usize,
},
/// The threshold configuration is invalid.
///
/// `required` must be in the range `1..=total_keys`.
#[error("invalid threshold: required={required} must satisfy 1 <= required <= total_keys={total_keys}")]
InvalidThreshold {
/// The requested number of required signatures.
required: usize,
/// The total number of keys in the committee.
total_keys: usize,
},
/// The committee must have at least two members.
#[error("committee must have at least 2 members; got {count}")]
CommitteeTooSmall {
/// Number of keys provided.
count: usize,
},
/// The signing session has not yet collected enough valid signatures to
/// satisfy the configured threshold.
#[error("threshold not met: have {have} valid signatures, need {need}")]
ThresholdNotMet {
/// Number of valid signatures currently held.
have: usize,
/// Number required by the threshold policy.
need: usize,
},
/// Failed to parse a Falcon-512 public key from raw bytes.
#[error("failed to parse public key at index {index}")]
PublicKeyParseError {
/// Zero-based committee index of the key that failed to parse.
index: usize,
},
/// Failed to parse a Falcon-512 signature from raw bytes.
#[error("failed to parse signature at signer index {index}")]
SignatureParseError {
/// Zero-based committee index of the failing signature.
index: usize,
},
}