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
//! Errors returned when converting or validating EIP-8141 fields.
use alloy_primitives::Address;
/// An invalid EIP-8141 field.
#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
pub enum Eip8141Error {
/// Unknown frame execution mode.
#[error("invalid frame mode: {0}")]
InvalidMode(u8),
/// Unknown approval scope.
#[error("invalid approval scope: {0}")]
InvalidScope(u8),
/// Unknown frame receipt status.
#[error("invalid frame status: {0}")]
InvalidStatus(u8),
/// Unknown signature scheme.
#[error("invalid signature scheme: {0}")]
InvalidScheme(u8),
/// An optional address must be empty or exactly 20 bytes.
#[error("invalid address length: {0}")]
InvalidAddressLength(usize),
/// A signature message must be empty or exactly 32 bytes.
#[error("invalid signature message length: {0}")]
InvalidMessageLength(usize),
/// An explicit zero digest is reserved for transaction-hash introspection.
#[error("explicit signature message must be nonzero")]
ZeroMessage,
/// Arbitrary signatures must not specify a signer.
#[error("arbitrary signature must have an empty signer")]
UnexpectedSigner,
/// A protocol signature has an incorrect byte length.
#[error("invalid signature length: expected {expected}, got {actual}")]
InvalidSignatureLength {
/// Required signature length.
expected: usize,
/// Actual signature length.
actual: usize,
},
/// Secp256k1 parity must be zero or one.
#[error("invalid signature parity: {0}")]
InvalidParity(u8),
/// A signature scalar is zero, out of range, or not low-s.
#[error("signature scalars must be canonical and low-s")]
InvalidSignatureScalar,
/// A P-256 public key does not hash to the resolved signer.
#[error("p256 public key resolves to {derived}, expected signer {expected}")]
P256SignerMismatch {
/// Signer resolved from the entry and the transaction sender.
expected: Address,
/// Address derived from the public key carried in the signature.
derived: Address,
},
}